If I am interested in recording a single locus' coalescent time distribution, it is easy to do lots of independent tree replicates, e.g:
for i in range(0,replicates):
sim = msprime.sim_ancestry( # simulate ancestry
samples=[msprime.SampleSet(num_samples=10 ploidy=1,population='human,time=0), \
demography=demography,sequence_length=1)
tree = sim.at(0)
However, I am interested in the distribution of tree heights at locus i+1 given locus i. In other words conditional on the current tree height, what is the distribution of the next tree height? Previously I recorded this by doing something like
L=1e+07 # arbitrary
r=1e-06 # arbitrary
sim = msprime.sim_ancestry( # simulate ancestry
samples=[msprime.SampleSet(num_samples=10 ploidy=1,population='human,time=0), \
demography=demography,sequence_length=L,recombination_rate=r)
then iterate through for tree in sim.trees() and record the height for each. It feels like there should be a faster way to do this, as the information must be built into what happens to a lineage after a recombination event. Even in my current method, it's not obvious what is the optimal L/r tradeoff to get the most transitions per unit time.
Any tips much appreciated!
Thanks,
Trevor
If I am interested in recording a single locus' coalescent time distribution, it is easy to do lots of independent tree replicates, e.g:
However, I am interested in the distribution of tree heights at locus i+1 given locus i. In other words conditional on the current tree height, what is the distribution of the next tree height? Previously I recorded this by doing something like
then iterate through
for tree in sim.trees()and record the height for each. It feels like there should be a faster way to do this, as the information must be built into what happens to a lineage after a recombination event. Even in my current method, it's not obvious what is the optimal L/r tradeoff to get the most transitions per unit time.Any tips much appreciated!
Thanks,
Trevor