Skip to content

Commit

Permalink
Add keep_unary and keep_unary_in_individuals
Browse files Browse the repository at this point in the history
  • Loading branch information
bodkan committed May 2, 2023
1 parent 4119869 commit 1b2112b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
13 changes: 11 additions & 2 deletions R/tree-sequences.R
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ ts_recapitate <- function(ts, recombination_rate, Ne = NULL, demography = NULL,
#' after the simplification.
#' @param keep_input_roots Should the history ancestral to the MRCA of all
#' samples be retained in the tree sequence? Default is \code{FALSE}.
#' @param keep_unary Should unary nodes be preserved through simplification?
#' Default is \code{FALSE}.
#' @param keep_unary_in_individuals Should unary nodes be preserved through
#' simplification if they are associated with an individual recorded in
#' the table of individuals? Default is \code{FALSE}. Cannot be set to
#' \code{TRUE} if \code{keep_unary} is also true.
#'
#' @return Tree-sequence object of the class \code{slendr_ts}, which serves as
#' an interface point for the Python module tskit using slendr functions with
Expand Down Expand Up @@ -321,7 +327,8 @@ ts_recapitate <- function(ts, recombination_rate, Ne = NULL, demography = NULL,
#'
#' ts_small
#' @export
ts_simplify <- function(ts, simplify_to = NULL, keep_input_roots = FALSE) {
ts_simplify <- function(ts, simplify_to = NULL, keep_input_roots = FALSE,
keep_unary = FALSE, keep_unary_in_individuals = FALSE) {
check_ts_class(ts)

model <- attr(ts, "model")
Expand Down Expand Up @@ -365,7 +372,9 @@ ts_simplify <- function(ts, simplify_to = NULL, keep_input_roots = FALSE) {

ts_new <- ts$simplify(as.integer(samples),
filter_populations = FALSE,
keep_input_roots = keep_input_roots)
keep_input_roots = keep_input_roots,
keep_unary = keep_unary,
keep_unary_in_individuals = keep_unary_in_individuals)

# copy attributes over to the new tree-sequence object or generate updates
# ones where necessary
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/slim.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion docs/reference/ts_simplify.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion man/ts_simplify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1b2112b

Please sign in to comment.