Genealogical Relatedness in pyslim #325
-
Hi everyone, I am currently building a simulation where I would like to track the ancestry all the way back to the first generation. SLiM provides the relatedness feature that allows to get 2 generations back for each individual. However, I am interested in 10 generations back. That's why I am creating a tree sequence. However, I am stuck on the part in pyslim, where I can calculate the genealogical relatedness. I just want to use the pedigree to calculate what the relatedness() feature does in SLiM but all the way back to the first generation. Does anyone have advice on how to do this in pyslim? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Hello, @fouerghi! I do have advice. Let's see: It depends which relatedness you are interested in. If it is the "realized" relatedness (ie. the amount of genetic material inherited in common), you can use ts.genetic_relatedness. However, I imagine you're looking for the classical expected-relatedness-between-diploids quantity (as computed by SLiM). In this case, I don't have code written to do it already, but I do have: I've just noticed that I don't have these listed in the docs (and will fix that shortly - so they should be at https://tskit.dev/pyslim/docs/latest/python_api.html soon) - but they give you the information you need to compute relatedness. The way I'd do this is to (a) use How's that? |
Beta Was this translation helpful? Give feedback.
-
@petrelharp, do these methods depend upon remembering every individual in the simulation? How does remembering interact with calculating relatedness? |
Beta Was this translation helpful? Give feedback.
-
There are some powerful pedigree relatedness methods in sgkit The relatedness tutorial should be some help in getting started with pedigrees in sgkit. This discussion should help with the conversion from tskit: tskit-dev/tskit#2711 (reply in thread) (We really should document this somewhere; I'm currently working on the sgkit paper which will hopefully raise the profile and create some interest) |
Beta Was this translation helpful? Give feedback.
Hello, @fouerghi! I do have advice. Let's see: It depends which relatedness you are interested in. If it is the "realized" relatedness (ie. the amount of genetic material inherited in common), you can use ts.genetic_relatedness.
However, I imagine you're looking for the classical expected-relatedness-between-diploids quantity (as computed by SLiM). In this case, I don't have code written to do it already, but I do have:
I've just noticed that I don't have these listed in the docs (and will fix that shortly - so they should be at https://tskit.dev/pyslim/docs/latest/python_api.html soon) - but they give you the information you need to comput…