R Under development (unstable) (2026-01-30 r89357 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "RcppTskit" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > options(pager = "console") > base::assign(".ExTimings", "RcppTskit-Ex.timings", pos = 'CheckExEnv') > base::cat("name\tuser\tsystem\telapsed\n", file=base::get(".ExTimings", pos = 'CheckExEnv')) > base::assign(".format_ptime", + function(x) { + if(!is.na(x[4L])) x[1L] <- x[1L] + x[4L] + if(!is.na(x[5L])) x[2L] <- x[2L] + x[5L] + options(OutDec = '.') + format(x[1L:3L], digits = 7L) + }, + pos = 'CheckExEnv') > > ### * > library('RcppTskit') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("RcppTskit-package") > ### * RcppTskit-package > > flush(stderr()); flush(stdout()) > > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: RcppTskit-package > ### Title: RcppTskit: R Access to the Tskit C API > ### Aliases: RcppTskit RcppTskit-package > ### Keywords: internal > > ### ** Examples > > vignette(package="RcppTskit") Vignettes in package 'RcppTskit': RcppTskit_intro RcppTskit: Working with tree sequences in R (source, html) > > > > base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") > base::cat("RcppTskit-package", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") > cleanEx() > nameEx("TreeSequence") > ### * TreeSequence > > flush(stderr()); flush(stdout()) > > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: TreeSequence > ### Title: Succinct tree sequence R6 class (TreeSequence) > ### Aliases: TreeSequence > > ### ** Examples > > > ## ------------------------------------------------ > ## Method `TreeSequence$new` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- TreeSequence$new(file = ts_file) > is(ts) [1] "TreeSequence" > ts Object of class 'TreeSequence' $ts property value 1 num_samples 160 2 sequence_length 10000 3 num_trees 26 4 time_units generations 5 min_time 0 6 max_time 7.47028168974859 7 has_metadata FALSE $tables table number has_metadata 1 provenances 2 NA 2 populations 1 TRUE 3 migrations 0 FALSE 4 individuals 80 FALSE 5 nodes 344 FALSE 6 edges 414 FALSE 7 sites 2376 FALSE 8 mutations 2700 FALSE > ts$num_nodes() [1] 344 > # Also > ts <- ts_load(ts_file) > is(ts) [1] "TreeSequence" > > ## ------------------------------------------------ > ## Method `TreeSequence$dump` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > dump_file <- tempfile() > ts$dump(dump_file) > ts$write(dump_file) # alias > > ## ------------------------------------------------ > ## Method `TreeSequence$print` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$print() Object of class 'TreeSequence' $ts property value 1 num_samples 160 2 sequence_length 10000 3 num_trees 26 4 time_units generations 5 min_time 0 6 max_time 7.47028168974859 7 has_metadata FALSE $tables table number has_metadata 1 provenances 2 NA 2 populations 1 TRUE 3 migrations 0 FALSE 4 individuals 80 FALSE 5 nodes 344 FALSE 6 edges 414 FALSE 7 sites 2376 FALSE 8 mutations 2700 FALSE > ts Object of class 'TreeSequence' $ts property value 1 num_samples 160 2 sequence_length 10000 3 num_trees 26 4 time_units generations 5 min_time 0 6 max_time 7.47028168974859 7 has_metadata FALSE $tables table number has_metadata 1 provenances 2 NA 2 populations 1 TRUE 3 migrations 0 FALSE 4 individuals 80 FALSE 5 nodes 344 FALSE 6 edges 414 FALSE 7 sites 2376 FALSE 8 mutations 2700 FALSE > > ## ------------------------------------------------ > ## Method `TreeSequence$r_to_py` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts_r <- ts_load(ts_file) > is(ts_r) [1] "TreeSequence" > ts_r$num_samples() # 160 [1] 160 > > # Transfer the tree sequence to reticulate Python and use tskit Python API > tskit <- get_tskit_py() Python module tskit is not available. Attempting to install it ... > if (check_tskit_py(tskit)) { + ts_py <- ts_r$r_to_py() + is(ts_py) + ts_py$num_samples # 160 + ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) + ts2_py$num_samples # 4 + } object must be a reticulate Python module object! > > ## ------------------------------------------------ > ## Method `TreeSequence$num_provenances` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_provenances() [1] 2 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_populations` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_populations() [1] 1 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_migrations` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_migrations() [1] 0 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_individuals` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_individuals() [1] 80 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_samples` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_samples() [1] 160 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_nodes` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_nodes() [1] 344 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_edges` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_edges() [1] 414 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_trees` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_trees() [1] 26 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_sites` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_sites() [1] 2376 > > ## ------------------------------------------------ > ## Method `TreeSequence$num_mutations` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$num_mutations() [1] 2700 > > ## ------------------------------------------------ > ## Method `TreeSequence$sequence_length` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$sequence_length() [1] 10000 > > ## ------------------------------------------------ > ## Method `TreeSequence$time_units` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$time_units() [1] "generations" > > ## ------------------------------------------------ > ## Method `TreeSequence$min_time` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$min_time() [1] 0 > > ## ------------------------------------------------ > ## Method `TreeSequence$max_time` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$max_time() [1] 7.470282 > > ## ------------------------------------------------ > ## Method `TreeSequence$metadata_length` > ## ------------------------------------------------ > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > ts$metadata_length() $ts [1] 0 $populations [1] 33 $migrations [1] 0 $individuals [1] 0 $nodes [1] 0 $edges [1] 0 $sites [1] 0 $mutations [1] 0 > > > > base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") > base::cat("TreeSequence", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") > cleanEx() > nameEx("get_tskit_py") > ### * get_tskit_py > > flush(stderr()); flush(stdout()) > > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: get_tskit_py > ### Title: Get the reticulate 'tskit' Python module > ### Aliases: get_tskit_py check_tskit_py > > ### ** Examples > > tskit <- get_tskit_py() Python module tskit is not available. Attempting to install it ... > is(tskit) [1] "python.builtin.ModuleNotFoundError" > if (check_tskit_py(tskit)) { + tskit$ALLELES_01 + } object must be a reticulate Python module object! > > > > base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") > base::cat("get_tskit_py", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") > cleanEx() > nameEx("kastore_version") > ### * kastore_version > > flush(stderr()); flush(stdout()) > > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: kastore_version > ### Title: Report the version of the installed kastore C API > ### Aliases: kastore_version > > ### ** Examples > > kastore_version() major minor patch 2 1 1 > > > > base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") > base::cat("kastore_version", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") > cleanEx() > nameEx("ts_load") > ### * ts_load > > flush(stderr()); flush(stdout()) > > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: ts_load > ### Title: Load a tree sequence from a file > ### Aliases: ts_load ts_read > > ### ** Examples > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > ts <- ts_load(ts_file) > is(ts) [1] "TreeSequence" > ts Object of class 'TreeSequence' $ts property value 1 num_samples 160 2 sequence_length 10000 3 num_trees 26 4 time_units generations 5 min_time 0 6 max_time 7.47028168974859 7 has_metadata FALSE $tables table number has_metadata 1 provenances 2 NA 2 populations 1 TRUE 3 migrations 0 FALSE 4 individuals 80 FALSE 5 nodes 344 FALSE 6 edges 414 FALSE 7 sites 2376 FALSE 8 mutations 2700 FALSE > ts$num_nodes() [1] 344 > # Also > ts <- TreeSequence$new(file = ts_file) > is(ts) [1] "TreeSequence" > > > > base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") > base::cat("ts_load", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") > cleanEx() > nameEx("ts_py_to_r") > ### * ts_py_to_r > > flush(stderr()); flush(stdout()) > > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: ts_py_to_r > ### Title: Transfer a tree sequence from reticulate Python to R > ### Aliases: ts_py_to_r > > ### ** Examples > > ts_file <- system.file("examples/test.trees", package = "RcppTskit") > > # Use the tskit Python API to work with a tree sequence (via reticulate) > tskit <- get_tskit_py() Python module tskit is not available. Attempting to install it ... > if (check_tskit_py(tskit)) { + ts_py <- tskit$load(ts_file) + is(ts_py) + ts_py$num_samples # 160 + ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) + ts2_py$num_samples # 4 + + # Transfer the tree sequence to R and use RcppTskit + ts2_r <- ts_py_to_r(ts2_py) + is(ts2_r) + ts2_r$num_samples() # 4 + } object must be a reticulate Python module object! > > > > base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") > base::cat("ts_py_to_r", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") > cleanEx() > nameEx("tskit_version") > ### * tskit_version > > flush(stderr()); flush(stdout()) > > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: tskit_version > ### Title: Report the version of the installed tskit C API > ### Aliases: tskit_version > > ### ** Examples > > tskit_version() major minor patch 1 3 0 > > > > base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") > base::cat("tskit_version", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") > ### *