Skip to content

Calculating number of extant lineages over time #2873

Answered by nspope
JaneeshBansal asked this question in Q&A
Discussion options

You must be logged in to vote

I saw in msprime that the IICR could be calculated using the demographic model specified, I was wondering if the same idea could be applied to a simulation?

Hmm, are you wanting to calculate an empirical pairwise coalescence rate from a simulated tree sequence, within specified time intervals? If so, one way to do so is:

import msprime
import numpy as np

ts = msprime.sim_ancestry(100, recombination_rate=1e-3, sequence_length=1e6, random_seed=2)
time_breaks = np.linspace(0.0, 4.0, 11)
coaltime = ts.coalescence_time_distribution(weight_func='pair_coalescence_events', span_normalise=True)
empirical_rate = coaltime.coalescence_rate_in_intervals(time_breaks).squeeze()

print(np.round(empiri…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@GertjanBisschop
Comment options

@JaneeshBansal
Comment options

@nspope
Comment options

Answer selected by JaneeshBansal
@JaneeshBansal
Comment options

@nspope
Comment options

@JaneeshBansal
Comment options

@GertjanBisschop
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants