Skip to contents

Extracts a table of metadata information about individuals recorded in a given simulated tree sequence or in a tree sequence which would be produced by a given model

Usage

ts_recorded(x, schedule = NULL)

Arguments

x

Either a tree sequence object of the class slendr_ts, or a compiled slendr model of the class slendr_model

schedule

If individuals from a model (not yet a tree sequence) are to be obtained, this argument can be used to only extract those individuals who would be simulated from the model

Value

Table of individuals scheduled for recording across space and time

Details

If a model is provided as x, the function will first simulate a trivially small tree sequence using the built-in msprime engine.

Examples

init_env()

# 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)

# extract the table of individuals recorded in the tree sequence
ts_recorded(ts)
#> # A tibble: 13 × 3
#>    name   time pop  
#>    <chr> <int> <chr>
#>  1 NEA_1 70000 NEA  
#>  2 NEA_2 40000 NEA  
#>  3 AFR_1     0 AFR  
#>  4 AFR_2     0 AFR  
#>  5 AFR_3     0 AFR  
#>  6 AFR_4     0 AFR  
#>  7 AFR_5     0 AFR  
#>  8 CH_1      0 CH   
#>  9 EUR_1     0 EUR  
#> 10 EUR_2     0 EUR  
#> 11 EUR_3     0 EUR  
#> 12 EUR_4     0 EUR  
#> 13 EUR_5     0 EUR