
Extract (spatio-)temporal ancestral history for given nodes/individuals
Source:R/tree-sequences.R
ts_ancestors.RdExtract (spatio-)temporal ancestral history for given nodes/individuals
Arguments
- ts
Tree sequence object of the class
slendr_ts- x
Either an individual name or an integer node ID
- verbose
Report on the progress of ancestry path generation?
- complete
Does every individual in the tree sequence need to have complete metadata recorded? If
TRUE, only individuals/nodes with complete metadata will be included in the reconstruction of ancestral relationships. For instance, nodes added during the coalescent recapitation phase will not be included because they don't have spatial information associated with them.
Value
A table of ancestral nodes of a given tree-sequence node all the way up to the root of the tree sequence
Examples
init_env()
#> Python virtual environment for slendr has been activated.
# load an example model with an already simulated tree sequence
slendr_ts <- system.file("extdata/models/introgression_slim.trees", package = "slendr")
model <- read_model(path = system.file("extdata/models/introgression", package = "slendr"))
# load the tree-sequence object from disk
ts <- ts_read(slendr_ts, model)
# find the complete ancestry information for a given individual
ts_ancestors(ts, "EUR_1", verbose = TRUE)
#> Collecting ancestors of EUR_1 [1/1]...
#>
#> Generating data about spatial relationships of nodes...
#> # A tibble: 164 × 12
#> name pop node_id level child_id parent_id child_time parent_time child_pop
#> <chr> <fct> <int> <fct> <int> <int> <dbl> <dbl> <fct>
#> 1 EUR_1 EUR 16 1 16 44 0 21590 EUR
#> 2 EUR_1 EUR 16 1 16 45 0 21740 EUR
#> 3 EUR_1 EUR 16 1 16 47 0 22850 EUR
#> 4 EUR_1 EUR 16 1 16 54 0 38630 EUR
#> 5 EUR_1 EUR 16 1 16 61 0 49040 EUR
#> 6 EUR_1 EUR 16 1 16 63 0 55820 EUR
#> 7 EUR_1 EUR 16 1 16 64 0 58010 EUR
#> 8 EUR_1 EUR 16 1 16 65 0 63530 EUR
#> 9 EUR_1 EUR 16 1 16 67 0 65120 EUR
#> 10 EUR_1 EUR 16 1 16 68 0 65780 EUR
#> # ℹ 154 more rows
#> # ℹ 3 more variables: parent_pop <fct>, left_pos <dbl>, right_pos <dbl>