diff --git a/.gitignore b/.gitignore index d588312..282651f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,6 @@ RcppTskit/src/tskit/*.o RcppTskit/vignettes/*.R RcppTskit/vignettes/*.html RcppTskit/vignettes/*_files/ +RcppTskit.Rcheck/ +RcppTskit_*.tar.gz test.trees diff --git a/AGENTS.md b/AGENTS.md index 5b71df5..b5a49b9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,7 +6,7 @@ These notes apply to this repository root and the `RcppTskit/` package. ## The way of working -* We strive for planned work so we know what we want to change. +* We strive for planned work so we have a plan of what we want to change. * We strive for minimal changes, unless needed otherwise. * We provide clear examples for new functionality so useRs can be quickly onboarded. @@ -211,3 +211,16 @@ but note that others might be working with the files in this repository at the s so don't tweak or revert changes done by others. Keep track of which files you are changing and focus on those changes only. If there are conflicting edits, try to merge or ask for advice on how to merge. +In case of conflicts, save your changes and use git worktree +to work independently. + +## Proofreading + +If asked to proofread, act as an expert proofreader and editor +with a deep understanding of clear, engaging, and well-structured writing. +Work paragraph by paragraph, +always starting by making a TODO list +that includes individual items for each heading. +Fix spelling, grammar, and other minor problems without asking. Label any unclear, confusing, or ambiguous sentences with +a TODO comment. +Only report what you have changed. diff --git a/RcppTskit/NEWS.md b/RcppTskit/NEWS.md index b0b25fe..7bff30c 100644 --- a/RcppTskit/NEWS.md +++ b/RcppTskit/NEWS.md @@ -4,7 +4,7 @@ All notable changes to RcppTskit are documented in this file. The file format is based on [Keep a Changelog](https://keepachangelog.com), and releases adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.2.0] - 2026-02-13 +## [0.2.0] - 2026-02-22 ### Added (new features) @@ -35,10 +35,16 @@ and releases adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html ### Maintenance +- Used `\dontrun{}` with `get_tskit_py()` calls in examples to + further reduce `R CMD check time` on CRAN. + +- Reduced bundled example tree-sequence sizes in `inst/examples/test.trees` + and `inst/examples/test2.trees` to speed up examples and checks. + - Delete temporary files in examples and tests after use. - Renamed unexported functions from `RcppTskit:::ts_load_ptr()` to - `RcppTskit:::ts_ptr_load()`. + `RcppTskit:::ts_ptr_load()` style. ## [0.1.0] - 2026-01-26 diff --git a/RcppTskit/R/Class-TableCollection.R b/RcppTskit/R/Class-TableCollection.R index 216c44b..fae2335 100644 --- a/RcppTskit/R/Class-TableCollection.R +++ b/RcppTskit/R/Class-TableCollection.R @@ -105,21 +105,23 @@ TableCollection <- R6Class( #' @seealso \code{\link{tc_py_to_r}}, \code{\link{tc_load}}, and #' \code{\link[=TableCollection]{TableCollection$dump}}. #' @examples - #' ts_file <- system.file("examples/test.trees", package = "RcppTskit") - #' tc_r <- tc_load(ts_file) - #' is(tc_r) - #' tc_r$print() + #' \dontrun{ + #' ts_file <- system.file("examples/test.trees", package = "RcppTskit") + #' tc_r <- tc_load(ts_file) + #' is(tc_r) + #' tc_r$print() #' - #' # Transfer the table collection to reticulate Python and use tskit Python API - #' tskit <- get_tskit_py() - #' if (check_tskit_py(tskit)) { - #' tc_py <- tc_r$r_to_py() - #' is(tc_py) - #' tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) - #' tmp - #' tc_py$individuals$num_rows # 2 - #' tc_py$nodes$num_rows # 10 - #' tc_py$nodes$time # 0.0 ... 7.4702817 + #' # Transfer the table collection to reticulate Python and use tskit Python API + #' tskit <- get_tskit_py() + #' if (check_tskit_py(tskit)) { + #' tc_py <- tc_r$r_to_py() + #' is(tc_py) + #' tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) + #' tmp + #' tc_py$individuals$num_rows # 2 + #' tc_py$nodes$num_rows # 8 + #' tc_py$nodes$time # 0.0 ... 5.0093910 + #' } #' } r_to_py = function(tskit_module = get_tskit_py(), cleanup = TRUE) { tc_ptr_r_to_py( diff --git a/RcppTskit/R/Class-TreeSequence.R b/RcppTskit/R/Class-TreeSequence.R index 066530e..349d6c1 100644 --- a/RcppTskit/R/Class-TreeSequence.R +++ b/RcppTskit/R/Class-TreeSequence.R @@ -126,22 +126,24 @@ TreeSequence <- R6Class( #' @seealso \code{\link{ts_py_to_r}}, \code{\link{ts_load}}, and #' \code{\link[=TreeSequence]{TreeSequence$dump}}. #' @examples - #' ts_file <- system.file("examples/test.trees", package = "RcppTskit") - #' ts_r <- ts_load(ts_file) - #' is(ts_r) - #' ts_r$num_individuals() # 80 + #' \dontrun{ + #' ts_file <- system.file("examples/test.trees", package = "RcppTskit") + #' ts_r <- ts_load(ts_file) + #' is(ts_r) + #' ts_r$num_individuals() # 8 #' - #' # Transfer the tree sequence to reticulate Python and use tskit Python API - #' tskit <- get_tskit_py() - #' if (check_tskit_py(tskit)) { - #' ts_py <- ts_r$r_to_py() - #' is(ts_py) - #' ts_py$num_individuals # 80 - #' ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) - #' ts_py$num_individuals # 80 - #' ts2_py$num_individuals # 2 - #' ts2_py$num_nodes # 10 - #' ts2_py$tables$nodes$time # 0.0 ... 7.4702817 + #' # Transfer the tree sequence to reticulate Python and use tskit Python API + #' tskit <- get_tskit_py() + #' if (check_tskit_py(tskit)) { + #' ts_py <- ts_r$r_to_py() + #' is(ts_py) + #' ts_py$num_individuals # 8 + #' ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) + #' ts_py$num_individuals # 8 + #' ts2_py$num_individuals # 2 + #' ts2_py$num_nodes # 8 + #' ts2_py$tables$nodes$time # 0.0 ... 5.0093910 + #' } #' } r_to_py = function(tskit_module = get_tskit_py(), cleanup = TRUE) { ts_ptr_r_to_py( diff --git a/RcppTskit/R/RcppTskit.R b/RcppTskit/R/RcppTskit.R index ed73019..0694aed 100644 --- a/RcppTskit/R/RcppTskit.R +++ b/RcppTskit/R/RcppTskit.R @@ -24,10 +24,12 @@ #' \code{TRUE} if \code{object} is a reticulate Python module or \code{FALSE} #' otherwise. #' @examples -#' tskit <- get_tskit_py() -#' is(tskit) -#' if (check_tskit_py(tskit)) { -#' tskit$ALLELES_01 +#' \dontrun{ +#' tskit <- get_tskit_py() +#' is(tskit) +#' if (check_tskit_py(tskit)) { +#' tskit$ALLELES_01 +#' } #' } #' @export get_tskit_py <- function(object_name = "tskit", force = FALSE) { @@ -110,6 +112,7 @@ validate_logical_arg <- function(value, name) { # @title Converting load arguments to \code{tskit} bitwise options # @param skip_tables logical # @param skip_reference_sequence logical +# @details Used in TableCollection and TreeSequence classes. # @return Bitwise options. # @examples # load_args_to_options() @@ -362,20 +365,22 @@ tc_ptr_print <- function(tc) { # and \code{\link{ts_ptr_py_to_r}}, \code{\link{ts_ptr_load}}, and # \code{ts_ptr_dump} (Rcpp) for underlying pointer functions. # @examples -# ts_file <- system.file("examples/test.trees", package = "RcppTskit") -# ts_r <- ts_load(ts_file) -# ts_r_ptr <- ts_r$pointer -# is(ts_r_ptr) -# RcppTskit:::ts_ptr_num_samples(ts_r_ptr) # 160 -# # Transfer the tree sequence to reticulate Python and use tskit Python API -# ts_py <- RcppTskit:::ts_ptr_r_to_py(ts_r_ptr) -# is(ts_py) -# ts_py$num_individuals # 80 -# ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) -# ts_py$num_individuals # 80 -# ts2_py$num_individuals # 2 -# ts2_py$num_nodes # 10 -# ts2_py$tables$nodes$time # 0.0 ... 7.4702817 +# \dontrun{ +# ts_file <- system.file("examples/test.trees", package = "RcppTskit") +# ts_r <- ts_load(ts_file) +# ts_r_ptr <- ts_r$pointer +# is(ts_r_ptr) +# RcppTskit:::ts_ptr_num_samples(ts_r_ptr) # 16 +# # Transfer the tree sequence to reticulate Python and use tskit Python API +# ts_py <- RcppTskit:::ts_ptr_r_to_py(ts_r_ptr) +# is(ts_py) +# ts_py$num_individuals # 8 +# ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) +# ts_py$num_individuals # 8 +# ts2_py$num_individuals # 2 +# ts2_py$num_nodes # 8 +# ts2_py$tables$nodes$time # 0.0 ... 5.0093910 +# } ts_ptr_r_to_py <- function(ts, tskit_module = get_tskit_py(), cleanup = TRUE) { if (!is(ts, "externalptr")) { stop("ts must be an object of externalptr class!") @@ -407,20 +412,22 @@ ts_ptr_r_to_py <- function(ts, tskit_module = get_tskit_py(), cleanup = TRUE) { # and \code{\link{tc_ptr_py_to_r}}, \code{\link{tc_ptr_load}}, and # \code{tc_ptr_dump} (Rcpp) for underlying pointer functions. # @examples -# ts_file <- system.file("examples/test.trees", package = "RcppTskit") -# tc_r <- tc_load(ts_file) -# tc_r_ptr <- tc_r$pointer -# is(tc_r_ptr) -# RcppTskit:::tc_ptr_summary(tc_r_ptr) -# # Transfer the table collection to reticulate Python and use tskit Python API -# tc_py <- RcppTskit:::tc_ptr_r_to_py(tc_r_ptr) -# is(tc_py) -# tc_py$individuals$num_rows # 80 -# tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) -# tmp -# tc_py$individuals$num_rows # 2 -# tc_py$nodes$num_rows # 10 -# tc_py$nodes$time # 0.0 ... 7.4702817 +# \dontrun{ +# ts_file <- system.file("examples/test.trees", package = "RcppTskit") +# tc_r <- tc_load(ts_file) +# tc_r_ptr <- tc_r$pointer +# is(tc_r_ptr) +# RcppTskit:::tc_ptr_summary(tc_r_ptr) +# # Transfer the table collection to reticulate Python and use tskit Python API +# tc_py <- RcppTskit:::tc_ptr_r_to_py(tc_r_ptr) +# is(tc_py) +# tc_py$individuals$num_rows # 8 +# tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) +# tmp +# tc_py$individuals$num_rows # 2 +# tc_py$nodes$num_rows # 8 +# tc_py$nodes$time # 0.0 ... 5.0093910 +# } tc_ptr_r_to_py <- function(tc, tskit_module = get_tskit_py(), cleanup = TRUE) { if (!is(tc, "externalptr")) { stop("tc must be an object of externalptr class!") @@ -447,24 +454,26 @@ tc_ptr_r_to_py <- function(tc, tskit_module = get_tskit_py(), cleanup = TRUE) { # and \code{\link{ts_ptr_r_to_py}}, \code{\link{ts_ptr_load}}, and # \code{ts_ptr_dump} (Rcpp) for underlying pointer functions. # @examples -# ts_file <- system.file("examples/test.trees", package = "RcppTskit") +# \dontrun{ +# 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() -# if (check_tskit_py(tskit)) { -# ts_py <- tskit$load(ts_file) -# is(ts_py) -# ts_py$num_individuals # 80 -# ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) -# ts_py$num_individuals # 80 -# ts2_py$num_individuals # 2 -# ts2_py$num_nodes # 10 -# ts2_py$tables$nodes$time # 0.0 ... 7.4702817 +# # Use the tskit Python API to work with a tree sequence (via reticulate) +# tskit <- get_tskit_py() +# if (check_tskit_py(tskit)) { +# ts_py <- tskit$load(ts_file) +# is(ts_py) +# ts_py$num_individuals # 8 +# ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) +# ts_py$num_individuals # 8 +# ts2_py$num_individuals # 2 +# ts2_py$num_nodes # 8 +# ts2_py$tables$nodes$time # 0.0 ... 5.0093910 # -# # Transfer the tree sequence to R and use RcppTskit -# ts2_ptr_r <- RcppTskit:::ts_ptr_py_to_r(ts2_py) -# is(ts2_ptr_r) -# RcppTskit:::ts_ptr_num_individuals(ts2_ptr_r) # 2 +# # Transfer the tree sequence to R and use RcppTskit +# ts2_ptr_r <- RcppTskit:::ts_ptr_py_to_r(ts2_py) +# is(ts2_ptr_r) +# RcppTskit:::ts_ptr_num_individuals(ts2_ptr_r) # 2 +# } # } ts_ptr_py_to_r <- function(ts, cleanup = TRUE) { if (!reticulate::is_py_object(ts)) { @@ -492,24 +501,26 @@ ts_ptr_py_to_r <- function(ts, cleanup = TRUE) { # and \code{\link{tc_ptr_r_to_py}}, \code{\link{tc_ptr_load}}, and # \code{tc_ptr_dump} (Rcpp) for underlying pointer functions. # @examples -# ts_file <- system.file("examples/test.trees", package = "RcppTskit") +# \dontrun{ +# ts_file <- system.file("examples/test.trees", package = "RcppTskit") # -# # Use the tskit Python API to work with a table collection (via reticulate) -# tskit <- get_tskit_py() -# if (check_tskit_py(tskit)) { -# tc_py <- tskit$TableCollection$load(ts_file) -# is(tc_py) -# tc_py$individuals$num_rows # 80 -# tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) -# tmp -# tc_py$individuals$num_rows # 2 -# tc_py$nodes$num_rows # 10 -# tc_py$nodes$time # 0.0 ... 7.4702817 +# # Use the tskit Python API to work with a table collection (via reticulate) +# tskit <- get_tskit_py() +# if (check_tskit_py(tskit)) { +# tc_py <- tskit$TableCollection$load(ts_file) +# is(tc_py) +# tc_py$individuals$num_rows # 8 +# tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) +# tmp +# tc_py$individuals$num_rows # 2 +# tc_py$nodes$num_rows # 8 +# tc_py$nodes$time # 0.0 ... 5.0093910 # -# # Transfer the table collection to R and use RcppTskit -# tc2_ptr_r <- RcppTskit:::tc_ptr_py_to_r(tc_py) -# is(tc2_ptr_r) -# RcppTskit:::tc_ptr_summary(tc2_ptr_r) +# # Transfer the table collection to R and use RcppTskit +# tc2_ptr_r <- RcppTskit:::tc_ptr_py_to_r(tc_py) +# is(tc2_ptr_r) +# RcppTskit:::tc_ptr_summary(tc2_ptr_r) +# } # } tc_ptr_py_to_r <- function(tc, cleanup = TRUE) { if (!reticulate::is_py_object(tc)) { @@ -533,24 +544,26 @@ tc_ptr_py_to_r <- function(tc, cleanup = TRUE) { #' @seealso \code{\link[=TreeSequence]{TreeSequence$r_to_py}} #' \code{\link{ts_load}}, and \code{\link[=TreeSequence]{TreeSequence$dump}}. #' @examples -#' ts_file <- system.file("examples/test.trees", package = "RcppTskit") +#' \dontrun{ +#' 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() -#' if (check_tskit_py(tskit)) { -#' ts_py <- tskit$load(ts_file) -#' is(ts_py) -#' ts_py$num_individuals # 80 -#' ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) -#' ts_py$num_individuals # 80 -#' ts2_py$num_individuals # 2 -#' ts2_py$num_nodes # 10 -#' ts2_py$tables$nodes$time # 0.0 ... 7.4702817 +#' # Use the tskit Python API to work with a tree sequence (via reticulate) +#' tskit <- get_tskit_py() +#' if (check_tskit_py(tskit)) { +#' ts_py <- tskit$load(ts_file) +#' is(ts_py) +#' ts_py$num_individuals # 8 +#' ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) +#' ts_py$num_individuals # 8 +#' ts2_py$num_individuals # 2 +#' ts2_py$num_nodes # 8 +#' ts2_py$tables$nodes$time # 0.0 ... 5.0093910 #' -#' # Transfer the tree sequence to R and use RcppTskit -#' ts2_r <- ts_py_to_r(ts2_py) -#' is(ts2_r) -#' ts2_r$num_individuals() # 2 +#' # Transfer the tree sequence to R and use RcppTskit +#' ts2_r <- ts_py_to_r(ts2_py) +#' is(ts2_r) +#' ts2_r$num_individuals() # 2 +#' } #' } #' @export ts_py_to_r <- function(ts, cleanup = TRUE) { @@ -568,24 +581,26 @@ ts_py_to_r <- function(ts, cleanup = TRUE) { #' @seealso \code{\link[=TableCollection]{TableCollection$r_to_py}} #' \code{\link{tc_load}}, and \code{\link[=TableCollection]{TableCollection$dump}}. #' @examples -#' ts_file <- system.file("examples/test.trees", package = "RcppTskit") +#' \dontrun{ +#' ts_file <- system.file("examples/test.trees", package = "RcppTskit") #' -#' # Use the tskit Python API to work with a table collection (via reticulate) -#' tskit <- get_tskit_py() -#' if (check_tskit_py(tskit)) { -#' tc_py <- tskit$TableCollection$load(ts_file) -#' is(tc_py) -#' tc_py$individuals$num_rows # 80 -#' tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) -#' tmp -#' tc_py$individuals$num_rows # 2 -#' tc_py$nodes$num_rows # 10 -#' tc_py$nodes$time # 0.0 ... 7.4702817 +#' # Use the tskit Python API to work with a table collection (via reticulate) +#' tskit <- get_tskit_py() +#' if (check_tskit_py(tskit)) { +#' tc_py <- tskit$TableCollection$load(ts_file) +#' is(tc_py) +#' tc_py$individuals$num_rows # 8 +#' tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) +#' tmp +#' tc_py$individuals$num_rows # 2 +#' tc_py$nodes$num_rows # 8 +#' tc_py$nodes$time # 0.0 ... 5.0093910 #' -#' # Transfer the table collection to R and use RcppTskit -#' tc_r <- tc_py_to_r(tc_py) -#' is(tc_r) -#' tc_r$print() +#' # Transfer the table collection to R and use RcppTskit +#' tc_r <- tc_py_to_r(tc_py) +#' is(tc_r) +#' tc_r$print() +#' } #' } #' @export tc_py_to_r <- function(tc, cleanup = TRUE) { diff --git a/RcppTskit/cran-comments.md b/RcppTskit/cran-comments.md index a3b8ddf..3d53456 100644 --- a/RcppTskit/cran-comments.md +++ b/RcppTskit/cran-comments.md @@ -6,6 +6,10 @@ * Re-submitting to CRAN. +* Submitted to CRAN on 2026-02-12 and got feedback to reduce examples time. + Have addressed this by reducing size of `.trees` and `\dontrun{}` for + any function that calls `get_tskit_py()`. + * Submitted to CRAN on 2026-02-09 and got feedback to quote Python, C, and Rust and to be mindful about case sensitivity. diff --git a/RcppTskit/inst/examples/create_test.trees.R b/RcppTskit/inst/examples/create_test.trees.R index 213da2d..b23c808 100644 --- a/RcppTskit/inst/examples/create_test.trees.R +++ b/RcppTskit/inst/examples/create_test.trees.R @@ -24,29 +24,29 @@ tskit <- import("tskit") # Generate a tree sequence for testing ts <- msprime$sim_ancestry( - samples = 80, - sequence_length = 1e4, - recombination_rate = 1e-4, + samples = 8, + sequence_length = 1e2, + recombination_rate = 1e-2, random_seed = 42 ) -ts <- msprime$sim_mutations(ts, rate = 1e-2, random_seed = 42) +ts <- msprime$sim_mutations(ts, rate = 2e-2, random_seed = 42) ts cat(py_str(ts)) builtins$print(ts) ts$num_provenances # 2 ts$num_populations # 1 ts$num_migrations # 0 -ts$num_individuals # 80 -ts$num_samples # 160 -ts$num_nodes # 344 -ts$num_edges # 414 -ts$num_trees # 26 -ts$num_sites # 2376 -ts$num_mutations # 2700 -ts$sequence_length # 10000.0 +ts$num_individuals # 8 +ts$num_samples # 16 +ts$num_nodes # 39 +ts$num_edges # 59 +ts$num_trees # 9 +ts$num_sites # 25 +ts$num_mutations # 30 +ts$sequence_length # 100.0 ts$time_units # generations ts$min_time # 0.0 -ts$max_time # 7.470281689748594 +ts$max_time # 6.961993337190808 ts$metadata # b'' builtins$type(ts$metadata) # @@ -96,7 +96,7 @@ ts$dump("inst/examples/test.trees") ts <- tskit$load("inst/examples/test2.trees") ts -ts$num_individuals # 81 +ts$num_individuals # 9 ts$metadata # $mean_coverage diff --git a/RcppTskit/inst/examples/create_test.trees.py b/RcppTskit/inst/examples/create_test.trees.py index 4c00823..0879455 100644 --- a/RcppTskit/inst/examples/create_test.trees.py +++ b/RcppTskit/inst/examples/create_test.trees.py @@ -6,25 +6,25 @@ # Generate a tree sequence for testing ts = msprime.sim_ancestry( - samples=80, sequence_length=1e4, recombination_rate=1e-4, random_seed=42 + samples=8, sequence_length=1e2, recombination_rate=1e-2, random_seed=42 ) -ts = msprime.sim_mutations(ts, rate=1e-2, random_seed=42) +ts = msprime.sim_mutations(ts, rate=2e-2, random_seed=42) ts print(ts) ts.num_provenances # 2 ts.num_populations # 1 ts.num_migrations # 0 -ts.num_individuals # 80 -ts.num_samples # 160 -ts.num_nodes # 344 -ts.num_edges # 414 -ts.num_trees # 26 -ts.num_sites # 2376 -ts.num_mutations # 2700 -ts.sequence_length # 10000.0 +ts.num_individuals # 8 +ts.num_samples # 16 +ts.num_nodes # 39 +ts.num_edges # 59 +ts.num_trees # 9 +ts.num_sites # 25 +ts.num_mutations # 30 +ts.sequence_length # 100.0 ts.time_units # 'generations' ts.min_time # 0.0 -ts.max_time # 7.470281689748594 +ts.max_time # 6.961993337190808 ts.metadata # b'' type(ts.metadata) # bytes @@ -66,39 +66,41 @@ # ts = tskit.load("RcppTskit/inst/examples/test.trees") ts2_tables = ts.dump_tables() len(ts2_tables.metadata) -ts2_tables.metadata = tskit.pack_bytes('{"seed": 42, "note": "ts2"}') +# ts2_tables.metadata = tskit.pack_bytes('{"seed": 42, "note": "ts2"}') +# TypeError: string argument without an encoding # Create a second tree sequence with metadata in some tables basic_schema = tskit.MetadataSchema({"codec": "json"}) +basic_schema # {"codec":"json"} - tables = ts.dump_tables() - tables.metadata_schema = basic_schema +tables.metadata_schema # {"codec":"json"} tables.metadata = {"mean_coverage": 200.5} +tables.metadata # {'mean_coverage': 200.5} tables.individuals.metadata_schema = tskit.MetadataSchema(None) tables.individuals.metadata -len(tables.individuals) # 80 +len(tables.individuals) # 8 tables.individuals[0] # IndividualTableRow(flags=0, location=array([], dtype=float64), parents=array([], dtype=int32), metadata=b'') tables.individuals[0].metadata # b'' -tables.individuals[79] +tables.individuals[7] # ... -tables.individuals[79].metadata +tables.individuals[7].metadata # b'' tables.individuals.add_row(metadata=b"SOME CUSTOM BYTES #!@") -tables.individuals[80] +tables.individuals[8] # IndividualTableRow(flags=0, location=array([], dtype=float64), parents=array([], dtype=int32), metadata=b'SOME CUSTOM BYTES #!@') -tables.individuals[80].metadata +tables.individuals[8].metadata # b'SOME CUSTOM BYTES #!@' ts = tables.tree_sequence() ts -ts.num_individuals # 81 +ts.num_individuals # 9 ts.metadata # {'mean_coverage': 200.5} type(ts.metadata) # dict diff --git a/RcppTskit/inst/examples/test.trees b/RcppTskit/inst/examples/test.trees index 984206f..0d027c3 100644 Binary files a/RcppTskit/inst/examples/test.trees and b/RcppTskit/inst/examples/test.trees differ diff --git a/RcppTskit/inst/examples/test2.trees b/RcppTskit/inst/examples/test2.trees index a2c0099..930f3b8 100644 Binary files a/RcppTskit/inst/examples/test2.trees and b/RcppTskit/inst/examples/test2.trees differ diff --git a/RcppTskit/man/TableCollection.Rd b/RcppTskit/man/TableCollection.Rd index 067c0f9..11c6a39 100644 --- a/RcppTskit/man/TableCollection.Rd +++ b/RcppTskit/man/TableCollection.Rd @@ -44,21 +44,23 @@ is(ts) ## Method `TableCollection$r_to_py` ## ------------------------------------------------ -ts_file <- system.file("examples/test.trees", package = "RcppTskit") -tc_r <- tc_load(ts_file) -is(tc_r) -tc_r$print() - -# Transfer the table collection to reticulate Python and use tskit Python API -tskit <- get_tskit_py() -if (check_tskit_py(tskit)) { - tc_py <- tc_r$r_to_py() - is(tc_py) - tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) - tmp - tc_py$individuals$num_rows # 2 - tc_py$nodes$num_rows # 10 - tc_py$nodes$time # 0.0 ... 7.4702817 +\dontrun{ + ts_file <- system.file("examples/test.trees", package = "RcppTskit") + tc_r <- tc_load(ts_file) + is(tc_r) + tc_r$print() + + # Transfer the table collection to reticulate Python and use tskit Python API + tskit <- get_tskit_py() + if (check_tskit_py(tskit)) { + tc_py <- tc_r$r_to_py() + is(tc_py) + tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) + tmp + tc_py$individuals$num_rows # 2 + tc_py$nodes$num_rows # 8 + tc_py$nodes$time # 0.0 ... 5.0093910 + } } ## ------------------------------------------------ @@ -255,21 +257,23 @@ Table collection in reticulate Python. } \subsection{Examples}{ \if{html}{\out{
}} -\preformatted{ts_file <- system.file("examples/test.trees", package = "RcppTskit") -tc_r <- tc_load(ts_file) -is(tc_r) -tc_r$print() - -# Transfer the table collection to reticulate Python and use tskit Python API -tskit <- get_tskit_py() -if (check_tskit_py(tskit)) { - tc_py <- tc_r$r_to_py() - is(tc_py) - tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) - tmp - tc_py$individuals$num_rows # 2 - tc_py$nodes$num_rows # 10 - tc_py$nodes$time # 0.0 ... 7.4702817 +\preformatted{\dontrun{ + ts_file <- system.file("examples/test.trees", package = "RcppTskit") + tc_r <- tc_load(ts_file) + is(tc_r) + tc_r$print() + + # Transfer the table collection to reticulate Python and use tskit Python API + tskit <- get_tskit_py() + if (check_tskit_py(tskit)) { + tc_py <- tc_r$r_to_py() + is(tc_py) + tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) + tmp + tc_py$individuals$num_rows # 2 + tc_py$nodes$num_rows # 8 + tc_py$nodes$time # 0.0 ... 5.0093910 + } } } \if{html}{\out{
}} diff --git a/RcppTskit/man/TreeSequence.Rd b/RcppTskit/man/TreeSequence.Rd index b89fba3..04d8f86 100644 --- a/RcppTskit/man/TreeSequence.Rd +++ b/RcppTskit/man/TreeSequence.Rd @@ -57,22 +57,24 @@ ts ## Method `TreeSequence$r_to_py` ## ------------------------------------------------ -ts_file <- system.file("examples/test.trees", package = "RcppTskit") -ts_r <- ts_load(ts_file) -is(ts_r) -ts_r$num_individuals() # 80 - -# Transfer the tree sequence to reticulate Python and use tskit Python API -tskit <- get_tskit_py() -if (check_tskit_py(tskit)) { - ts_py <- ts_r$r_to_py() - is(ts_py) - ts_py$num_individuals # 80 - ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) - ts_py$num_individuals # 80 - ts2_py$num_individuals # 2 - ts2_py$num_nodes # 10 - ts2_py$tables$nodes$time # 0.0 ... 7.4702817 +\dontrun{ + ts_file <- system.file("examples/test.trees", package = "RcppTskit") + ts_r <- ts_load(ts_file) + is(ts_r) + ts_r$num_individuals() # 8 + + # Transfer the tree sequence to reticulate Python and use tskit Python API + tskit <- get_tskit_py() + if (check_tskit_py(tskit)) { + ts_py <- ts_r$r_to_py() + is(ts_py) + ts_py$num_individuals # 8 + ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) + ts_py$num_individuals # 8 + ts2_py$num_individuals # 2 + ts2_py$num_nodes # 8 + ts2_py$tables$nodes$time # 0.0 ... 5.0093910 + } } ## ------------------------------------------------ @@ -423,22 +425,24 @@ Tree sequence in reticulate Python. } \subsection{Examples}{ \if{html}{\out{
}} -\preformatted{ts_file <- system.file("examples/test.trees", package = "RcppTskit") -ts_r <- ts_load(ts_file) -is(ts_r) -ts_r$num_individuals() # 80 - -# Transfer the tree sequence to reticulate Python and use tskit Python API -tskit <- get_tskit_py() -if (check_tskit_py(tskit)) { - ts_py <- ts_r$r_to_py() - is(ts_py) - ts_py$num_individuals # 80 - ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) - ts_py$num_individuals # 80 - ts2_py$num_individuals # 2 - ts2_py$num_nodes # 10 - ts2_py$tables$nodes$time # 0.0 ... 7.4702817 +\preformatted{\dontrun{ + ts_file <- system.file("examples/test.trees", package = "RcppTskit") + ts_r <- ts_load(ts_file) + is(ts_r) + ts_r$num_individuals() # 8 + + # Transfer the tree sequence to reticulate Python and use tskit Python API + tskit <- get_tskit_py() + if (check_tskit_py(tskit)) { + ts_py <- ts_r$r_to_py() + is(ts_py) + ts_py$num_individuals # 8 + ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) + ts_py$num_individuals # 8 + ts2_py$num_individuals # 2 + ts2_py$num_nodes # 8 + ts2_py$tables$nodes$time # 0.0 ... 5.0093910 + } } } \if{html}{\out{
}} diff --git a/RcppTskit/man/get_tskit_py.Rd b/RcppTskit/man/get_tskit_py.Rd index 855eef2..7987748 100644 --- a/RcppTskit/man/get_tskit_py.Rd +++ b/RcppTskit/man/get_tskit_py.Rd @@ -48,9 +48,11 @@ This function is meant for users running \code{tskit <- get_tskit_py()} }} \examples{ -tskit <- get_tskit_py() -is(tskit) -if (check_tskit_py(tskit)) { - tskit$ALLELES_01 +\dontrun{ + tskit <- get_tskit_py() + is(tskit) + if (check_tskit_py(tskit)) { + tskit$ALLELES_01 + } } } diff --git a/RcppTskit/man/tc_py_to_r.Rd b/RcppTskit/man/tc_py_to_r.Rd index 8c473ee..b481ad3 100644 --- a/RcppTskit/man/tc_py_to_r.Rd +++ b/RcppTskit/man/tc_py_to_r.Rd @@ -19,24 +19,26 @@ This function saves a table collection from reticulate Python to disk and reads it into R for use with \code{RcppTskit}. } \examples{ -ts_file <- system.file("examples/test.trees", package = "RcppTskit") +\dontrun{ + ts_file <- system.file("examples/test.trees", package = "RcppTskit") -# Use the tskit Python API to work with a table collection (via reticulate) -tskit <- get_tskit_py() -if (check_tskit_py(tskit)) { - tc_py <- tskit$TableCollection$load(ts_file) - is(tc_py) - tc_py$individuals$num_rows # 80 - tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) - tmp - tc_py$individuals$num_rows # 2 - tc_py$nodes$num_rows # 10 - tc_py$nodes$time # 0.0 ... 7.4702817 + # Use the tskit Python API to work with a table collection (via reticulate) + tskit <- get_tskit_py() + if (check_tskit_py(tskit)) { + tc_py <- tskit$TableCollection$load(ts_file) + is(tc_py) + tc_py$individuals$num_rows # 8 + tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) + tmp + tc_py$individuals$num_rows # 2 + tc_py$nodes$num_rows # 8 + tc_py$nodes$time # 0.0 ... 5.0093910 - # Transfer the table collection to R and use RcppTskit - tc_r <- tc_py_to_r(tc_py) - is(tc_r) - tc_r$print() + # Transfer the table collection to R and use RcppTskit + tc_r <- tc_py_to_r(tc_py) + is(tc_r) + tc_r$print() + } } } \seealso{ diff --git a/RcppTskit/man/ts_py_to_r.Rd b/RcppTskit/man/ts_py_to_r.Rd index 7dfe69f..2ab7788 100644 --- a/RcppTskit/man/ts_py_to_r.Rd +++ b/RcppTskit/man/ts_py_to_r.Rd @@ -19,24 +19,26 @@ This function saves a tree sequence from reticulate Python to disk and reads it into R for use with \code{RcppTskit}. } \examples{ -ts_file <- system.file("examples/test.trees", package = "RcppTskit") +\dontrun{ + 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() -if (check_tskit_py(tskit)) { - ts_py <- tskit$load(ts_file) - is(ts_py) - ts_py$num_individuals # 80 - ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) - ts_py$num_individuals # 80 - ts2_py$num_individuals # 2 - ts2_py$num_nodes # 10 - ts2_py$tables$nodes$time # 0.0 ... 7.4702817 + # Use the tskit Python API to work with a tree sequence (via reticulate) + tskit <- get_tskit_py() + if (check_tskit_py(tskit)) { + ts_py <- tskit$load(ts_file) + is(ts_py) + ts_py$num_individuals # 8 + ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) + ts_py$num_individuals # 8 + ts2_py$num_individuals # 2 + ts2_py$num_nodes # 8 + ts2_py$tables$nodes$time # 0.0 ... 5.0093910 - # Transfer the tree sequence to R and use RcppTskit - ts2_r <- ts_py_to_r(ts2_py) - is(ts2_r) - ts2_r$num_individuals() # 2 + # Transfer the tree sequence to R and use RcppTskit + ts2_r <- ts_py_to_r(ts2_py) + is(ts2_r) + ts2_r$num_individuals() # 2 + } } } \seealso{ diff --git a/RcppTskit/tests/testthat/test_TableCollection.R b/RcppTskit/tests/testthat/test_TableCollection.R index b077cea..eebabd3 100644 --- a/RcppTskit/tests/testthat/test_TableCollection.R +++ b/RcppTskit/tests/testthat/test_TableCollection.R @@ -78,7 +78,7 @@ test_that("TableCollection and TreeSequence round-trip works", { "time_units", "has_metadata" ), - value = c(10000, "generations", FALSE) + value = c(100, "generations", FALSE) ), tables = data.frame( table = c( @@ -91,7 +91,7 @@ test_that("TableCollection and TreeSequence round-trip works", { "sites", "mutations" ), - number = c(2, 1, 0, 80, 344, 414, 2376, 2700), + number = c(2, 1, 0, 8, 39, 59, 25, 30), has_metadata = c( NA, # provenances have no metadata TRUE, @@ -142,7 +142,7 @@ test_that("TableCollection and TreeSequence round-trip works", { "time_units", "has_metadata" ), - value = c(10000, "generations", FALSE) + value = c(100, "generations", FALSE) ), tables = data.frame( table = c( @@ -155,7 +155,7 @@ test_that("TableCollection and TreeSequence round-trip works", { "sites", "mutations" ), - number = c(2, 1, 0, 80, 344, 414, 2376, 2700), + number = c(2, 1, 0, 8, 39, 59, 25, 30), has_metadata = c( NA, # provenances have no metadata TRUE, diff --git a/RcppTskit/tests/testthat/test_load_summary_and_dump.R b/RcppTskit/tests/testthat/test_load_summary_and_dump.R index 5b1281f..320a3be 100644 --- a/RcppTskit/tests/testthat/test_load_summary_and_dump.R +++ b/RcppTskit/tests/testthat/test_load_summary_and_dump.R @@ -135,17 +135,17 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "num_provenances" = 2L, "num_populations" = 1L, "num_migrations" = 0L, - "num_individuals" = 80L, - "num_samples" = 160L, - "num_nodes" = 344L, - "num_edges" = 414L, - "num_trees" = 26L, - "num_sites" = 2376L, - "num_mutations" = 2700L, - "sequence_length" = 10000.0, + "num_individuals" = 8L, + "num_samples" = 16L, + "num_nodes" = 39L, + "num_edges" = 59L, + "num_trees" = 9L, + "num_sites" = 25L, + "num_mutations" = 30L, + "sequence_length" = 100.0, "time_units" = "generations", "min_time" = 0, - "max_time" = 7.470281689748594 + "max_time" = 6.9619933371908083 ) ) @@ -174,57 +174,57 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { expect_error(ts_ptr_num_individuals(ts)) n_ptr <- ts_ptr_num_individuals(ts_ptr) expect_true(is.integer(n_ptr)) - expect_equal(n_ptr, 80L) - expect_equal(ts$num_individuals(), 80L) + expect_equal(n_ptr, 8L) + expect_equal(ts$num_individuals(), 8L) expect_error(ts_ptr_num_samples()) expect_error(ts_ptr_num_samples(ts)) n_ptr <- ts_ptr_num_samples(ts_ptr) expect_true(is.integer(n_ptr)) - expect_equal(n_ptr, 160L) - expect_equal(ts$num_samples(), 160L) + expect_equal(n_ptr, 16L) + expect_equal(ts$num_samples(), 16L) expect_error(ts_ptr_num_nodes()) expect_error(ts_ptr_num_nodes(ts)) n_ptr <- ts_ptr_num_nodes(ts_ptr) expect_true(is.integer(n_ptr)) - expect_equal(n_ptr, 344L) - expect_equal(ts$num_nodes(), 344L) + expect_equal(n_ptr, 39L) + expect_equal(ts$num_nodes(), 39L) expect_error(ts_ptr_num_edges()) expect_error(ts_ptr_num_edges(ts)) n_ptr <- ts_ptr_num_edges(ts_ptr) expect_true(is.integer(n_ptr)) - expect_equal(n_ptr, 414L) - expect_equal(ts$num_edges(), 414L) + expect_equal(n_ptr, 59L) + expect_equal(ts$num_edges(), 59L) expect_error(ts_ptr_num_trees()) expect_error(ts_ptr_num_trees(ts)) n_ptr <- ts_ptr_num_trees(ts_ptr) expect_true(is.integer(n_ptr)) - expect_equal(n_ptr, 26L) - expect_equal(ts$num_trees(), 26L) + expect_equal(n_ptr, 9L) + expect_equal(ts$num_trees(), 9L) expect_error(ts_ptr_num_sites()) expect_error(ts_ptr_num_sites(ts)) n_ptr <- ts_ptr_num_sites(ts_ptr) expect_true(is.integer(n_ptr)) - expect_equal(n_ptr, 2376L) - expect_equal(ts$num_sites(), 2376L) + expect_equal(n_ptr, 25L) + expect_equal(ts$num_sites(), 25L) expect_error(ts_ptr_num_mutations()) expect_error(ts_ptr_num_mutations(ts)) n_ptr <- ts_ptr_num_mutations(ts_ptr) expect_true(is.integer(n_ptr)) - expect_equal(n_ptr, 2700L) - expect_equal(ts$num_mutations(), 2700L) + expect_equal(n_ptr, 30L) + expect_equal(ts$num_mutations(), 30L) expect_error(ts_ptr_sequence_length()) expect_error(ts_ptr_sequence_length(ts)) n_ptr <- ts_ptr_sequence_length(ts_ptr) expect_true(is.numeric(n_ptr)) - expect_equal(n_ptr, 10000) - expect_equal(ts$sequence_length(), 10000) + expect_equal(n_ptr, 100) + expect_equal(ts$sequence_length(), 100) expect_error(ts_ptr_time_units()) expect_error(ts_ptr_time_units(ts)) @@ -244,8 +244,8 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { expect_error(ts_ptr_max_time(ts)) d_ptr <- ts_ptr_max_time(ts_ptr) expect_true(is.numeric(d_ptr)) - expect_equal(d_ptr, 7.470281689748594) - expect_equal(ts$max_time(), 7.470281689748594) + expect_equal(d_ptr, 6.9619933371908083) + expect_equal(ts$max_time(), 6.9619933371908083) # ---- tc_ptr_summary() ---- @@ -290,7 +290,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "max_time", "has_metadata" ), - value = c(160, 10000, 26, "generations", 0.0, 7.470281689748594, FALSE) + value = c(16, 100, 9, "generations", 0.0, 6.9619933371908083, FALSE) ), tables = data.frame( table = c( @@ -303,7 +303,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "sites", "mutations" ), - number = c(2, 1, 0, 80, 344, 414, 2376, 2700), + number = c(2, 1, 0, 8, 39, 59, 25, 30), has_metadata = c( NA, # provenances have no metadata TRUE, @@ -338,7 +338,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "time_units", "has_metadata" ), - value = c(10000, "generations", FALSE) + value = c(100, "generations", FALSE) ), tables = data.frame( table = c( @@ -351,7 +351,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "sites", "mutations" ), - number = c(2, 1, 0, 80, 344, 414, 2376, 2700), + number = c(2, 1, 0, 8, 39, 59, 25, 30), has_metadata = c( NA, # provenances have no metadata TRUE, @@ -401,17 +401,17 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "num_provenances" = 2L, "num_populations" = 1L, "num_migrations" = 0L, - "num_individuals" = 80L, - "num_samples" = 160L, - "num_nodes" = 344L, - "num_edges" = 414L, - "num_trees" = 26L, - "num_sites" = 2376L, - "num_mutations" = 2700L, - "sequence_length" = 10000.0, + "num_individuals" = 8L, + "num_samples" = 16L, + "num_nodes" = 39L, + "num_edges" = 59L, + "num_trees" = 9L, + "num_sites" = 25L, + "num_mutations" = 30L, + "sequence_length" = 100.0, "time_units" = "generations", "min_time" = 0.0, - "max_time" = 7.470281689748594 + "max_time" = 6.9619933371908083 ) ) @@ -487,17 +487,17 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "num_provenances" = 2L, "num_populations" = 1L, "num_migrations" = 0L, - "num_individuals" = 80L, - "num_samples" = 160L, - "num_nodes" = 344L, - "num_edges" = 414L, - "num_trees" = 26L, - "num_sites" = 2376L, - "num_mutations" = 2700L, - "sequence_length" = 10000.0, + "num_individuals" = 8L, + "num_samples" = 16L, + "num_nodes" = 39L, + "num_edges" = 59L, + "num_trees" = 9L, + "num_sites" = 25L, + "num_mutations" = 30L, + "sequence_length" = 100.0, "time_units" = "generations", "min_time" = 0.0, - "max_time" = 7.470281689748594 + "max_time" = 6.9619933371908083 ) ) @@ -529,12 +529,12 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "num_provenances" = 2L, "num_populations" = 1L, "num_migrations" = 0L, - "num_individuals" = 80L, - "num_nodes" = 344L, - "num_edges" = 414L, - "num_sites" = 2376L, - "num_mutations" = 2700L, - "sequence_length" = 10000.0, + "num_individuals" = 8L, + "num_nodes" = 39L, + "num_edges" = 59L, + "num_sites" = 25L, + "num_mutations" = 30L, + "sequence_length" = 100.0, "time_units" = "generations" ) ) @@ -572,17 +572,17 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "num_provenances" = 2L, "num_populations" = 1L, "num_migrations" = 0L, - "num_individuals" = 81L, - "num_samples" = 160L, - "num_nodes" = 344L, - "num_edges" = 414L, - "num_trees" = 26L, - "num_sites" = 2376L, - "num_mutations" = 2700L, - "sequence_length" = 10000.0, + "num_individuals" = 9L, + "num_samples" = 16L, + "num_nodes" = 39L, + "num_edges" = 59L, + "num_trees" = 9L, + "num_sites" = 25L, + "num_mutations" = 30L, + "sequence_length" = 100.0, "time_units" = "generations", "min_time" = 0, - "max_time" = 7.470281689748594 + "max_time" = 6.9619933371908083 ) ) @@ -620,7 +620,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "max_time", "has_metadata" ), - value = c(160, 10000, 26, "generations", 0.0, 7.470281689748594, TRUE) + value = c(16, 100, 9, "generations", 0.0, 6.9619933371908083, TRUE) ), tables = data.frame( table = c( @@ -633,7 +633,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "sites", "mutations" ), - number = c(2, 1, 0, 81, 344, 414, 2376, 2700), + number = c(2, 1, 0, 9, 39, 59, 25, 30), has_metadata = c( NA, # provenances have no metadata TRUE, @@ -698,7 +698,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "time_units", "has_metadata" ), - value = c(10000, "generations", TRUE) + value = c(100, "generations", TRUE) ), tables = data.frame( table = c( @@ -711,7 +711,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { "sites", "mutations" ), - number = c(2, 1, 0, 81, 344, 414, 2376, 2700), + number = c(2, 1, 0, 9, 39, 59, 25, 30), has_metadata = c( NA, # provenances have no metadata TRUE, diff --git a/RcppTskit/vignettes/RcppTskit_intro.qmd b/RcppTskit/vignettes/RcppTskit_intro.qmd index 8656036..2fd159b 100644 --- a/RcppTskit/vignettes/RcppTskit_intro.qmd +++ b/RcppTskit/vignettes/RcppTskit_intro.qmd @@ -252,11 +252,11 @@ tskit <- get_tskit_py() if (check_tskit_py(tskit)) { ts_py <- ts$r_to_py() # ... continue in reticulate Python ... - ts_py$num_individuals # 80 + ts_py$num_individuals # 8 ts2_py = ts_py$simplify(samples = c(0L, 1L, 2L, 3L)) ts2_py$num_individuals # 2 - ts2_py$num_nodes # 10 - ts2_py$tables$nodes$time # 0.0 ... 7.4702817 + ts2_py$num_nodes # 8 + ts2_py$tables$nodes$time # 0.0 ... 5.0093910 # ... and to bring it back to R, use ... ts2 <- ts_py_to_r(ts2_py) ts2$num_individuals() # 2 @@ -269,7 +269,7 @@ ts$dump(file = ts_file) # ... continue in standard Python ... # import tskit # ts = tskit.load("insert_ts_file_path_here") -# ts.num_individuals # 80 +# ts.num_individuals # 8 # ts2 = ts.simplify(samples = [0, 1, 2, 3]) # ts2.num_individuals # 2 # ts2.dump("insert_ts_file_path_here") @@ -286,8 +286,8 @@ if (check_tskit_py(tskit)) { tmp <- tc_py$simplify(samples = c(0L, 1L, 2L, 3L)) tmp tc_py$individuals$num_rows # 2 - tc_py$nodes$num_rows # 10 - tc_py$nodes$time # 0.0 ... 7.4702817 + tc_py$nodes$num_rows # 8 + tc_py$nodes$time # 0.0 ... 5.0093910 # ... and to bring it back to R, use ... tc2 <- tc_py_to_r(tc_py) tc2$print()