This function implements an R-friendly interface to an algorithm for
extracting ancestry tracts provided by the Python module tspop
https://tspop.readthedocs.io/en/latest/ and developed by Georgia Tsambos.
Please make sure to cite the paper which describes the algorithm in
detail: tools:::Rd_expr_doi("10.1093/bioadv/vbad163").
For more technical details, see also the tutorial at:
https://tspop.readthedocs.io/en/latest/basicusage.html.
In general, when using this function on a slendr-generated tree sequence,
please be aware that the output changes slightly to what you would get by
running the pure tspop.get_pop_ancestry()
in Python. First,
ts_tracts()
populates the output data frame with additional metadata
(such as names of individuals or populations). Additionally, for slendr models,
it is specifically designed to only return ancestry tracts originating to a
an ancestral population which contributed its ancestry during a gene-flow
event which started at a specific time (i.e., scheduled in a model via
the gene_flow()
) function. It does not return every single ancestry
tracts present in the tree sequence for every single sample node (and every
single potential ancestry population) as does the tspop.get_pop_ancestry()
Python method.
That said, when run on a tree sequence which does not originate from a slendr
simulation, the behavior of ts_tracts()
is identical to that of the
underlying tspop.get_pop_ancestry()
.
As of the current version of slendr, ts_tracts()
only works for
slendr/msprime sequences but not on slendr/SLiM tree sequences. Support for
slendr-generated SLiM tree sequences is in development. Tracts from tree
sequences originating from non-slendr msprime and SLiM simulations are not
restricted in any way and, as mentioned in the previous paragraph,
ts_tracts()
in this situation effectively reduces to the standard
tspop.get_pop_ancestry()
call.