Getting extant mutation ages on treesequences

8 views
Skip to first unread message

Daniel Pelletier

unread,
Nov 19, 2025, 11:19:07 PM (4 days ago) Nov 19
to slim-discuss
Hi, I'm simulating treesequences with slim, then adding mutations with msprime (example code below). For a sample of chromosomes, I'd like to get the ages of extant mutations, but I'm not sure how to separate the extant mutations (most recent mutation at a site for a chromosome) from ancestral mutations that have been replaced. The mutations table includes all of these with no distinction.

Ex.:
#simulating a simple tree sequence with msprime, 1-locus chromosome, ending in 5 diploid individuals
ats=msprime.sim_ancestry(5, sequence_length=1)
#binary (0 or 1) mutations, with state-dependence so no silent mutations
mts=msprime.sim_mutations(ats, rate=0.5, model=msprime.BinaryMutationModel(state_independent=False))

This gives me a treesequence with 8 mutations. At present time (generation 0, or 'present'), some of those mutations have gone extinct (fully replaced by other mutations), and some exist on one or a few chromosomes. If I want to calculate the average age of mutations:
np.mean(mts.tables.mutations.time)
The ages of all mutations that have happened on the tree are included, rather than just those that are the most recent mutation for at least 1 sample chromosome.

I'd really appreciate advice on how to get the ages (or just mean age) of extant mutations! Hopefully I'm not just missing an obvious function.
Thanks,
Daniel

Ben Haller

unread,
Nov 20, 2025, 9:25:30 AM (3 days ago) Nov 20
to Daniel Pelletier, slim-discuss
Hi Daniel!  Someone on this list might know the answer (I don't), but it seems like a question for the tskit/msprime folks; as your example code shows, the question arises even for a purely msprime simulation, and it looks like you're not even using msprime.SLiMMutationModel.  So I'd recommend that you ask over there.  Good luck!

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University
--
SLiM forward genetic simulation: http://messerlab.org/slim/
Before posting, please read http://benhaller.com/slim/bugs_and_questions.html
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/slim-discuss/aa507ce0-bfc9-4de7-8768-a7e9214ac65bn%40googlegroups.com.

Daniel Pelletier

unread,
Nov 20, 2025, 3:09:30 PM (3 days ago) Nov 20
to slim-discuss
Ah yes you're right, I hadn't thought of that- I posted the question to the tskit github discussion page! Thanks!
Reply all
Reply to author
Forward
0 new messages