Hi, folks -
I had a quick look here (and just saw Chris's reply), and I'm also getting diversities that agree with what's been inputted? There's rather too many scripts for me to dig into the details, though. (For future reference, my recommendation is to reduce your script
to something that is totally minimal, runs fast, and reproduces the problem - probably, you will identify the problem along the way, and if not, it'll be much easier for someone else to find it. For instance, when I ran the code I changed pop_size to 100.)
So: with a simplified version of diploid.slim with a much smaller population size so it runs in a reasonable time:
```
initialize() {
initializeTreeSeq();
defineConstant("simID", getSeed());
defineConstant("pop_size", 100);
defineConstant("d", 0.003);
defineConstant("genome_size", 500000);
defineConstant("N_generations", 10 * pop_size);
defineConstant("mu", d / 4 / pop_size);
defineGlobal("r", mu);
initializeMutationRate(mu);
initializeMutationType("m1", 0.5, "f", 0.0);
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, genome_size);
initializeRecombinationRate(r); // crossover rate
m1.mutationStackGroup = 1;
m1.mutationStackPolicy = 'l';
}
1 early() {
sim.addSubpop("p1", pop_size);
community.rescheduleScriptBlock(s1, start=N_generations, end=N_generations);
}
s1 10000 late() {
sim.treeSeqOutput("test" + simID + ".trees");
}
```
and the following python script:
```
import tskit
import glob
tt = [tskit.load(x) for x in glob.glob("*.trees")]
print(sum([t.diversity() for t in tt]) / len(tt))
```
I get diversity values that are increasingly close to 0.003 the more replicates I run. So, if you are getting a discrepancy, here's some things I'd check:
-
that you've run enough replicates / have enough recombination
-
that you're not hitting saturation (i.e., lots of sites with multiple mutations)
-
that there's not an issue with downstream calculation
--peter