Skip to contents

Extract spatio-temporal edge annotation table from a given tree or tree sequence

Usage

ts_edges(x)

Arguments

x

Tree object generated by ts_phylo or a slendr tree sequence object produced by ts_load, ts_recapitate, ts_simplify, or ts_mutate

Value

Data frame of the sf type containing the times of nodes and start-end coordinates of edges across space

Examples

check_dependencies(python = TRUE, quit = TRUE) # dependencies must be present

init_env()
#> The interface to all required Python modules 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_load(slendr_ts, model)

# extract an annotated table with (spatio-)temporal edge information
ts_edges(ts)
#> # A tibble: 298 × 6
#>    child_node_id parent_node_id child_time parent_time child_pop parent_pop
#>            <int>          <int>      <dbl>       <dbl> <fct>     <fct>     
#>  1             0             74      70000       70040 NEA       NEA       
#>  2             1             74      70000       70040 NEA       NEA       
#>  3             2             55      40000       40220 NEA       NEA       
#>  4             3             55      40000       40220 NEA       NEA       
#>  5             4             34          0         740 AFR       AFR       
#>  6             5             28          0          80 AFR       AFR       
#>  7             6             26          0          20 AFR       AFR       
#>  8             7             27          0          80 AFR       AFR       
#>  9             8             27          0          80 AFR       AFR       
#> 10             9             36          0        1160 AFR       AFR       
#> # ℹ 288 more rows