Skip to content

saving without simplification results in mutations without metadata #648

Description

@petrelharp

The nice logic around retaining mutations or not means that we're throwing out uneeded bits in two ways: retaining mutations, and at simplification. However, retaining is assuming that we will simplify in the future, which is optional. So this recipe:

initialize()
{
    setSeed(23);
    initializeSLiMOptions(keepPedigrees=T);
    initializeTreeSeq(simplificationRatio=INF, timeUnit="generations");
    initializeMutationRate(1e-2);
    initializeMutationType("m1", 0.5, "f", -0.1);
    initializeGenomicElementType("g1", m1, 1.0);
    initializeGenomicElement(g1, 0, 99);
    initializeRecombinationRate(1e-2);
}

1 early() { 
    sim.addSubpop("p1", 10);
}

10 late() {
    sim.treeSeqOutput("out.trees", simplify=F);
}

produces a tree sequence for which not all mutations have information, as seen as follows:

import tskit
ts = tskit.load("out.trees")

md = { x['mutation_id'] : x for x in ts.metadata['SLiM_mutation_list'] }
ds = [ int(j) for x in ts.mutations_derived_state for j in x.split(",") ]
for k in ds:
    assert k in md, f"missing {k}"

Another way to get to this error would be to (a) write out the tree sequence without simplification; (b) use pyslim to mark more individuals as samples; (c) try to read it back into SLiM, who would now have the "unknown mutation" error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions