BHVDistance() returns the geodesic distance between phylogenetic trees
with edge lengths in the Billera-Holmes-Vogtmann (BHV) treespace
(Billera et al. 2001)
, computed with the
polynomial-time GTP algorithm of Owen and Provan (2011)
.
Arguments
- tree1, tree2
A
phylotree, amultiPhyloobject, or a list ofphylotrees, each carryingedge.length. All trees across both arguments must share the same leaf labels.tree2may be omitted whentree1is a collection, in which case all pairwise distances withintree1are returned.
Value
BHVDistance() returns distances between the input trees:
If both inputs are single trees, the return value is a single non-negative number.
When comparing a tree to a collection of trees, the return value is a named numeric vector with one entry per tree in the collection.
If
tree2is omitted, or is identical totree1, the return value is astats::distobject of all pairwise distances.If
tree1andtree2are different collections, the return value comprises a numeric matrix with rows corresponding totree1and columns totree2.
References
Billera LJ, Holmes SP, Vogtmann K (2001).
“Geometry of the space of phylogenetic trees.”
Advances in Applied Mathematics, 27(4), 733–767.
doi:10.1006/aama.2001.0759
.
Owen M, Provan JS (2011).
“A fast algorithm for computing geodesic distances in tree space.”
IEEE/ACM Transactions on Computational Biology and Bioinformatics, 8(1), 2–13.
doi:10.1109/TCBB.2010.3
.
See also
Other BHV summaries:
BHVMean()
Examples
set.seed(2)
trees <- lapply(1:4, function(i)
TreeTools::RandomTree(8, root = TRUE, lengths = runif)
)
t1 <- trees[[1]]
t2 <- trees[[2]]
BHVDistance(t1, t2) # scalar
#> [1] 2.742226
BHVDistance(t1, trees) # named vector
#> [1] 0.000000 2.742226 3.088498 3.158640
BHVDistance(trees) # dist (pairwise)
#> 1 2 3
#> 2 2.742226
#> 3 3.088498 3.094400
#> 4 3.158640 3.187792 3.344174
BHVDistance(trees[1:2], trees[3:4]) # matrix
#> [,1] [,2]
#> [1,] 3.088498 3.158640
#> [2,] 3.094400 3.187792