Skip to content

Commit

Permalink
KCDiameter.multiPhylo() (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
ms609 authored Feb 29, 2024
1 parent 1644628 commit 5cbff38
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: TreeDist
Type: Package
Title: Calculate and Map Distances Between Phylogenetic Trees
Version: 2.7.0.9000
Version: 2.7.0.9001
Authors@R: c(person("Martin R.", "Smith",
email = "[email protected]",
role = c("aut", "cre", "cph", "prg"),
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# TreeDist 2.7.0.9000 (development)
# TreeDist 2.7.0.9001 (development)

- Fix dead links in documentation

- Fix `KCDiameter.multiPhylo()` for multiple trees.


# TreeDist 2.7.0 (2023-10-25)

- Fix calculation error in `StrainCol()`.
Expand Down
2 changes: 1 addition & 1 deletion R/parallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @examples
#' if (interactive()) { # Only run in terminal
#' library("TreeTools", quietly = TRUE)
#' nCores <- ceiling(detectCores() / 2)
#' nCores <- ceiling(parallel::detectCores() / 2)
#' StartParallel(nCores) # Takes a few seconds to set up processes
#' GetParallel()
#' ClusteringInfoDistance(as.phylo(0:6, 100))
Expand Down
10 changes: 6 additions & 4 deletions R/tree_distance_kendall-colijn.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ SplitVector <- function(tree) {
#' metric.
#'
#' @examples
#' KCDiameter(trees)
#' KCDiameter(4)
#' KCDiameter(trees)
#' @importFrom TreeTools PectinateTree
#' @rdname KendallColijn
#' @export
Expand All @@ -237,10 +237,12 @@ KCDiameter.numeric <- function(tree) {
Euclid(nTip - mat[lower.tri(mat)] + 1L, t(mat)[lower.tri(mat)])
}

#' @export
KCDiameter.multiPhylo <- KCDiameter.phylo

#' @export
KCDiameter.list <- function(tree) {
lapply(tree, KCDiameter)
}

#' @export
KCDiameter.multiPhylo <- function(tree) {
vapply(tree, KCDiameter, double(1))
}
2 changes: 1 addition & 1 deletion man/KendallColijn.Rd

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

2 changes: 1 addition & 1 deletion man/StartParallel.Rd

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

6 changes: 6 additions & 0 deletions tests/testthat/test-tree_distance_kc.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ test_that("KCDiameter() calculated", {
}
Test(4)
Test(40)
tree1 <- ape::read.tree(text = "(a, (b, (c, (d, (e, (f, (g, h)))))));")
tree2 <- ape::read.tree(text = "(a, ((b, c), (d, (e, (f, (g, h))))));")
tree3 <- ape::read.tree(text = "(a, (b, (c, (d, (e, (f, g))))));")
trees <- c(tree1, tree2, tree3)
expect_equal(KCDiameter(trees),
c(KCDiameter(tree1), KCDiameter(tree2), KCDiameter(tree3)))
})

0 comments on commit 5cbff38

Please sign in to comment.