Skip to content

Commit

Permalink
Allow the use of list(pop = <sample names>) in tskit functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bodkan committed Oct 10, 2022
1 parent 4c0581e commit ac5e484
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/tree-sequences.R
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,9 @@ print.slendr_ts <- function(x, ...) { summary(x, ...) }

# Function for extracting numerical node IDs for various statistics
get_node_ids <- function(ts, x) {
# slendr allows named lists to be used for easier group labelling in result tables
if (is.list(x)) x <- x[[1]]

if (is.null(x)) {
ids <- ts_nodes(ts) %>% .[.$sampled, ]$node_id
} else if (is.character(x)) {
Expand Down Expand Up @@ -2655,5 +2658,8 @@ define_windows <- function(ts, breakpoints) {
}

concat <- function(x) {
paste(x, collapse = "+")
if (is.list(x) && !is.null(names(x)))
return(names(x))
else
return(paste(x, collapse = "+"))
}

0 comments on commit ac5e484

Please sign in to comment.