Skip to contents

For more information about optional keyword arguments see tskit documentation:


ts_tree(ts, i, mode = c("index", "position"), ...)



Tree sequence object of the class slendr_ts


Position of the tree in the tree sequence. If mode = "index", an i-th tree will be returned (in one-based indexing), if mode = "position", a tree covering an i-th base of the simulated genome will be returned.


How should the i argument be interpreted? Either "index" as an i-th tree in the sequence of genealogies, or "position" along the simulated genome.


Additional keyword arguments accepted by and tskit.TreeSequence.at_index methods


Python-reticulate-based object of the class tskit.trees.Tree


check_dependencies(python = TRUE) # make sure dependencies are present

#> 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.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, simplify = TRUE)

# extract the first tree in the tree sequence
tree <- ts_tree(ts, i = 1)

# extract the tree at a position 100000bp in the tree sequence
tree <- ts_tree(ts, i = 100000, mode = "position")