Skip to contents

Run the "extend haplotypes" algorithm to extend the span of sequence covered by ancestral nodes, as implemented by the tskit method TreeSequence.extend_haplotypes.

Usage

ts_extend(ts, iterations = 10)

Arguments

ts

Tree sequence object

iterations

Maximum number of iterations over the tree sequence (default is 10)

Value

Tree-sequence object of the class slendr_ts

Details

For more details about this functionality, please read the following resources:

  1. Paper by Fritze et al. 2025 (doi:10.1093/genetics/iyaf198 )

  2. Official tskit documentation at https://tskit.dev/tskit/docs/stable/python-api.html#tskit.TreeSequence.extend_haplotypes

Note that this function has been currently tested exclusively on tree sequences simulated by slendr's msprime() simulation engine.

Examples

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_msprime.trees", package = "slendr")
model <- read_model(path = system.file("extdata/models/introgression", package = "slendr"))

ts <- ts_read(slendr_ts, model)
ts_ext <- ts_extend(ts, iterations = 10)

ts_ext
#> ╔═══════════════════════════╗
#> ║TreeSequence               ║
#> ╠═══════════════╤═══════════╣
#> ║Trees          │        180║
#> ╟───────────────┼───────────╢
#> ║Sequence Length│  1,000,000║
#> ╟───────────────┼───────────╢
#> ║Time Units     │generations║
#> ╟───────────────┼───────────╢
#> ║Sample Nodes   │         26║
#> ╟───────────────┼───────────╢
#> ║Total Size     │   37.7 KiB║
#> ╚═══════════════╧═══════════╝
#> ╔═══════════╤════╤═════════╤════════════╗
#> ║Table      │Rows│Size     │Has Metadata║
#> ╠═══════════╪════╪═════════╪════════════╣
#> ║Edges      │ 621│ 19.4 KiB│          No║
#> ╟───────────┼────┼─────────┼────────────╢
#> ║Individuals│  13│388 Bytes│          No║
#> ╟───────────┼────┼─────────┼────────────╢
#> ║Migrations │   0│  8 Bytes│          No║
#> ╟───────────┼────┼─────────┼────────────╢
#> ║Mutations  │   0│ 16 Bytes│          No║
#> ╟───────────┼────┼─────────┼────────────╢
#> ║Nodes      │ 339│  9.3 KiB│          No║
#> ╟───────────┼────┼─────────┼────────────╢
#> ║Populations│   4│338 Bytes│         Yes║
#> ╟───────────┼────┼─────────┼────────────╢
#> ║Provenances│   1│  2.8 KiB│          No║
#> ╟───────────┼────┼─────────┼────────────╢
#> ║Sites      │   0│ 16 Bytes│          No║
#> ╚═══════════╧════╧═════════╧════════════╝
#>