Repository navigation
Closed
Description
I am not sure if this would cause any problems downstream, but I've noticed that when reading in tree sequence files, we don't check if the pedigree IDs are unique. Here's a MWE - first run this python script:
import pyslim, tskit, msprime
def make_tables(ind_ids):
t = tskit.TableCollection(sequence_length=10)
t.nodes.add_row(time=1.0)
t = pyslim.annotate_defaults(t.tree_sequence(), model_type='nonWF', slim_generation=1).tables
pop_md = pyslim.default_slim_metadata('population')
pop_md['slim_id'] = 0
t.populations.add_row(metadata=pop_md)
ind_md = pyslim.default_slim_metadata('individual')
ind_md['age'] = 4
ind_md['subpopulation'] = 0
node_md = pyslim.default_slim_metadata('node')
for ind_id in ind_ids:
ind_md['pedigree_id'] = ind_id
i = t.individuals.add_row(metadata=ind_md, flags=pyslim.INDIVIDUAL_ALIVE, location=[0.0] * 3)
node_md['slim_id'] = 2 * ind_id
t.nodes.add_row(time=0.0, population=0, individual=i, flags=1, metadata=node_md)
node_md['slim_id'] = 2 * ind_id + 1
t.nodes.add_row(time=0.0, population=0, individual=i, flags=1, metadata=node_md)
return t.tree_sequence()
ts = make_tables([0, 0])
ts.dump("dup_ids.trees")
and then this SLiM script:
initialize() {
initializeSLiMModelType("nonWF");
initializeSLiMOptions(keepPedigrees=T);
initializeTreeSeq();
initializeMutationType("m0", 0.5, "e", 1/100);
initializeGenomicElementType("g1", m0, 1);
initializeGenomicElement(g1, 0, 9);
initializeMutationRate(1e-10);
initializeRecombinationRate(0.0);
}
1 early() {
sim.readFromPopulationFile("dup_ids.trees");
for (pop in sim.subpopulations)
catn("pop" + pop.id + ": " + paste(pop.individuals.pedigreeID));
}
3 early() { sim.simulationFinished(); }
... produces no errors and confirms that both individuals have pedigreeID=0.
Is this ok? I suspect not.
Metadata
Metadata
Assignees
Labels
No labels
Activity
bhaller commentedon Apr 29, 2021
Yikes. That should definitely be illegal. Odd, I could have sworn I had a check for that in the code already. I'll look into it, thanks. Can you attach the .trees file here? I think I'm out of date with my msprime/pyslim install, and don't want to have to deal with updating it right now...