Skip to content

from_ts doesn't check for infinite coalescence time #649

@petrelharp

Description

@petrelharp

If there are different roots in different populations, then you can set things up so that simulate(..., from_ts=ts) has an infinite coalescence time (because of zero migration between populations), in a way that would be detected if we weren't using from_ts.

Here is a MWE:

import msprime
import random

# as in recapitate()
recomb = msprime.RecombinationMap(positions = [0.0, 1e3], 
                                  rates = [0.001, 0.0],
                                  num_loci = int(1e3))

ts = msprime.simulate(4, recombination_map=recomb,
                      random_seed=23, __tmp_max_time=0.1)

# get the roots so we can assign some to different populations
roots = []
for t in ts.trees():
    # verify that the trees have not coalesced
    print(t.draw(format='unicode'))
    roots.extend(t.roots)

roots = list(set(roots))

# assign roots to different populations
tables = ts.dump_tables()
tables.populations.add_row()
population = tables.nodes.population
population[:] = [random.sample([0,1], 1)[0] for _ in range(ts.num_nodes)]
assert(len(set(population[roots])) > 1)
tables.nodes.set_columns(flags=tables.nodes.flags, population=population,
        individual=tables.nodes.individual, time=tables.nodes.time,
        metadata=tables.nodes.metadata, 
        metadata_offset=tables.nodes.metadata_offset)
nts = tables.tree_sequence()

def do_recap(ts):
    population_configurations = [msprime.PopulationConfiguration() 
                                 for _ in range(ts.num_populations)]
    msprime.simulate(
                from_ts = ts,
                population_configurations = population_configurations,
                recombination_map = recomb,
                start_time = max(ts.tables.nodes.time))

rts = do_recap(ts)
rnts = do_recap(nts)

I will track this down.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions