Skip to content

How to very quickly record marginal changes in tree height along a sequence? #2278

Description

@trevorcousins

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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