Skip to content

add example of "add more mutations to SLiM sim" #373

@petrelharp

Description

@petrelharp

As @bhaller reports, doing

initialize() {
	initializeTreeSeq();
	initializeMutationRate(1e-12);
	initializeMutationType("m1", 0.5, "f", 0.0);
	initializeMutationType("m2", 0.5, "f", 0.01);
	initializeGenomicElementType("g1", m2, 1.0);
	initializeGenomicElement(g1, 0, 1e8-1);
	initializeRecombinationRate(1e-8);
}
1 early() {
	sim.addSubpop("p1", 500);
}
5000 late() {
	sim.treeSeqOutput("overlay.trees");
}

then

import msprime, tskit

ts = tskit.load("overlay.trees").simplify()
mutated = msprime.sim_mutations(ts, rate=1e-7, random_seed=1, keep=True)
mutated.dump("final_overlaid.trees")

results in


Traceback (most recent call last):
 File "/Users/bhaller/Desktop/ts_overlay.py", line 4, in <module>
  mutated = msprime.sim_mutations(ts, rate=1e-7, random_seed=1, keep=True)
 File "/Users/bhaller/Library/Python/3.9/lib/python/site-packages/msprime/mutations.py", line 1692, in sim_mutations
  _msprime.sim_mutations(
msprime._msprime.LibraryError: Existing allele(s) incompatible with mutation model alphabet.

which is confusing. The solution is to add

ts = pyslim.convert_alleles(pyslim.generate_nucleotides(ts))

but this is not well-explained anywhere. We should add an example to the docs of this.

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