Export simulation pedigree

83 views
Skip to first unread message

Hannes Becher

unread,
Jan 17, 2025, 7:20:30 AM1/17/25
to slim-discuss
It is great we can make a SLiM simulation follow an existing pedigree. But sometimes, we may want to be able to export the pedigree that emerges during a SLiM run.

Is there are way to export the pedigree of all individuals of one species in a simulation?

My understanding is that with keepPedigrees=T, only the IDs of the parents of currently existing individuals are retained, but not the 'whole' pedigree, correct?

I can see two ways to get the whole pedigree:
1. Keep all individuals (I know that can be done for tree sequence tracking) and then export their and their parents' pedigree IDs. Likely unsuitable for large populations/many generations.
2. At each tick/generation, write down the existing individual's IDs and parental IDs.

Does this make sense? Is there an easier built-in way?

Many, many thanks,
Hannes

Ben Haller

unread,
Jan 17, 2025, 7:52:02 AM1/17/25
to Hannes Becher, slim-discuss
Hi Hannes!

First of all, yes, you could as you say use tree-sequence recording and remember every individual in every generation.  That would provide you not only with a complete pedigree, but also all of the information about inheritance along the chromosome; but it would grow very large, for large/long simulations, to the point where you would likely run out of memory.  Perhaps you could allow simplification to trim away extinct branches of the tree (if you don't need those), but set retainCoalescentOnly=F so that ancestors of the extant individuals are kept even if they are not a coalescent node in the ancestry tree; and perhaps you could remember individuals with treeSeqRememberIndividuals() with permanent=F, allowing them to be simplified away in cases where they are no longer relevant to the final generation, but keeping them otherwise?  I'm not sure whether that would then give you a complete pedigree for the final generation or not; honestly I find these flags (which are tskit flags, not SLiM flags, really) a bit confusing in their exact effects.  :->  The pyslim documentation at https://tskit.dev/pyslim/docs/latest/tutorial.html has discussion and diagrams regarding this, which you could try to figure out, and perhaps Peter can weigh in to whether some combination of the available options would produce a recorded pedigree (plus inheritance information), in effect, or if there is some difference.

Second, yes, as you say, you could "write down" each individual's ID and parents to produce a recorded pedigree.  There is an example recipe to do this in section 15.10 that does not even use SLiM's "pedigree tracking" feature, instead tagging each individual; but you could certainly use the IDs from pedigree tracking instead.  It's just a couple of extra lines of code.

Third, no, there is no built-in facility for this; but doing it yourself, as in section 15.10, is really not difficult at all.  I guess there's no built-in facility for doing it because (a) it's easy to script, (b) everybody would probably want it to do different things, keep different information, save in different formats, etc.; it seems like a feature with so much variation in the desired functionality that it might be better to let people just implement what they want, and (c) nobody has asked for it.  :->  If you wanted to write up a precise, detailed feature request in a GitHub issue, it might well happen eventually, but since I know little about how people use pedigrees in the real world, what file format would be desired, etc., your writeup should really specify all the relevant details or I won't know how to proceed with it.  :->  I'm certainly open to the idea of adding such a feature, if you think it is a well-defined problem with a clear solution that would actually make people happy.

And fourth, there is a package called py_ped_sim that does a bunch of stuff related to pedigrees in SLiM that you might want to look at.  Section 1.10 of the SLiM manual has more information on it.  I don't think (?) it provides a way to record a pedigree in SLiM automatically, but I think it perhaps *does* provide a way for you to use some other software package to simulate a pedigree and record it, and then simulate along that recorded pedigree in SLiM, which might or might not solve your problem, depending on what exactly you're trying to do.

I hope this helps; happy modeling!

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Hannes Becher wrote on 1/17/25 6:20 AM:
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
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/e8176cc3-1f1f-4908-a618-b47104e26d10n%40googlegroups.com.

Hannes Becher

unread,
Jan 17, 2025, 8:03:35 AM1/17/25
to Ben Haller, slim-discuss
Hi Ben,

Thank for your rapid reply! Sound like recipe 15.10 is exactly what I need ATM. This recipe actually was highlighted to me when I used the "Find Recipe" function of SLiMgui. But I dismissed it when reading the title "Forcing a specific pedigree".

I'll hold off with the feature request for now. :)

Thanks again and all the best,
Hannes
Reply all
Reply to author
Forward
0 new messages