Skip to content

Commit

Permalink
Progress bar for .MaxInfo()
Browse files Browse the repository at this point in the history
  • Loading branch information
ms609 committed Jul 25, 2024
1 parent 1d970c0 commit dabaaba
Show file tree
Hide file tree
Showing 4 changed files with 16 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.1.9003
Version: 2.7.1.9004
Authors@R: c(person("Martin R.", "Smith",
email = "[email protected]",
role = c("aut", "cre", "cph", "prg"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ importFrom(ape,plot.phylo)
importFrom(cli,cli_alert_danger)
importFrom(cli,cli_alert_info)
importFrom(cli,cli_alert_success)
importFrom(cli,cli_progress_along)
importFrom(cli,cli_progress_bar)
importFrom(cli,cli_progress_update)
importFrom(colorspace,qualitative_hcl)
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# TreeDist 2.7.1.9003 (2024-06-28)
# TreeDist 2.7.1.9004 (2024-07-25)

- `Islands()` allows the identification of islands of trees.

- Internal implementation of path and SPR distances, removing dependency
on phangorn (and thus R 4.4).

- Add progress bar within `.MaxValue()`


# TreeDist 2.7.1 (2024-06-13)
Expand Down
18 changes: 11 additions & 7 deletions R/tree_distance.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ GeneralizedRF <- function(splits1, splits2, nTip, PairScorer,
ret
}


#' @importFrom cli cli_progress_along
.MaxValue <- function(tree1, tree2, Value) {
lab1 <- TipLabels(tree1)
sameTips <- .AllTipsSame(lab1, TipLabels(tree2))
Expand All @@ -95,13 +97,15 @@ GeneralizedRF <- function(splits1, splits2, nTip, PairScorer,
pairs <- combn(seq_along(tree1), 2)
nPairs <- dim(pairs)[[2]]

apply(pairs, 2, function(ij) {
i <- ij[[1]]
j <- ij[[2]]
common <- intersect(lab1[[i]], lab1[[j]])
Value(KeepTip(tree1[[i]], common)) +
Value(KeepTip(tree1[[j]], common))
})
vapply(cli_progress_along(seq_len(nPairs), "Calc max value"),
function(pair) {
i <- pairs[1, pair]
j <- pairs[2, pair]
common <- intersect(lab1[[i]], lab1[[j]])
Value(KeepTip(tree1[[i]], common)) +
Value(KeepTip(tree1[[j]], common))
}, double(1))

}
} else {
value1 <- Value(tree1)
Expand Down

0 comments on commit dabaaba

Please sign in to comment.