Skip to content

Commit

Permalink
custom subsets with clade names
Browse files Browse the repository at this point in the history
  • Loading branch information
TGuillerme committed Nov 5, 2024
1 parent 078f1fc commit d15c229
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dispRity v1.9 (2024-06-06) *distant update*
### MINOR IMPROVEMENTS

* `custom.subsets` can now take a logical vector for the `group` argument.
* `custom.subsets` now recycles node names when using a tree to create clade groups.
* `plot` functions doing scatter plot now centers them without changing the scale of both axes.
* **changed default argument** for `tree.age`: the number of digits output by `tree.age` is now changed from 3 to 4 by default.
* the random starting parameters in `reduce.space` are now drawn from the input data distribution which speeds up the function significantly.
Expand Down
6 changes: 6 additions & 0 deletions R/custom.subsets_fun.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ get.tree.clades <- function(tree, data) {
clade_nodes <- lapply(clades, get.node.labels, tree = tree)
clades <- mapply(c, clades, clade_nodes)
}

## Add clade names
if(!is.null(tree$node.label)) {
names(clades) <- tree$node.label
}

return(clades)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-custom.subsets.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test_that("set.group.list works", {
test <- set.group.list(group6, data, group_class = class(group6))
expect_is(test, "list")
expect_equal(length(test), 4)
expect_equal(unlist(lapply(test, length)), c(9, 3, 5, 3))
expect_equal(unlist(lapply(test, length)), c("f" = 9, "g" = 3, "h" = 5, "i" = 3))
})

## Check.group.list
Expand Down

0 comments on commit d15c229

Please sign in to comment.