Hi Ben, Hi Peter,
Thanks for the great software you have provided us with!
One thing is giving me headaches though.
I've been trying to run a SLiM simulation with a recombination map and recapitate the result using pyslim. However, for some reason the recapitation process finishes without error, but with a certain fraction of trees still having more than one root. The interval of those trees is always extremely small (mean=0.0004) vs 1080 for all other trees (for a particular run of the minimal example I have included). I assume I'm misspecifying something here that trips up pyslim. So I have included both recombination maps that I have used.
`
initialize() {
initializeMutationType("m1",0.5,"f",0.0);
initializeGenomicElementType("g1", m1, 1);
initializeGenomicElement(g1, 100,100);
initializeMutationRate(0.0);
//read in hapmap
lines = readFile('hapmap_slim_half.txt');
ends = sapply(strsplit(lines[0],','),'asInteger(applyValue);');
rates =sapply(strsplit(lines[1],','),'asFloat(applyValue);');
initializeRecombinationRate(rates,ends);
initializeTreeSeq(simplificationRatio=NULL, simplificationInterval=1000);
}
// create a population of 500 individuals
1 {
defineConstant('simID',getSeed());
defineConstant('m',0.001);
defineConstant("Ne_1", 1000);
defineConstant("Ne_0", 1000);
sim.addSubpop('p1',Ne_1);
}
1000 late() {
sim.addSubpopSplit("p0",Ne_0,p1);
p1.setMigrationRates(p0,m);
}
1000:8000 late(){
if (sim.generation%1000==0){print('sim at time step '+sim.generation);}
}
8000 late() {
sim.treeSeqOutput('min_example.trees');
sim.simulationFinished();
}
`
Recapitation
`
#!/usr/bin/env python3
import msprime, pyslim
import numpy as np
import os, glob
import numpy.random
def main():
directory = os.getcwd()
treefile='min_example.trees'
with open('hapmap_msprime_half.txt','r') as file:
positions = [int(element) for element in file.readline().rstrip().split(',')]
rates = [float(element) for element in file.readline().rstrip().split(',')]
hapmap = msprime.RecombinationMap(positions,rates)
mutation_rate = 1.9e-7
Ne_ancestral = 1000
ts = pyslim.load(os.path.join(directory, treefile))
recap = ts.recapitate(recombination_map=hapmap, Ne=Ne_ancestral)
recap.dump(directory+'/recap_'+treefile)
if __name__ == '__main__':
main()
`
Thanks,
gertjan