CompareAll {TreeDist} | R Documentation |
Distances between each pair of trees
Description
Calculate the distance between each tree in a list, and each other tree in the same list.
Usage
CompareAll(x, Func, FUN.VALUE = Func(x[[1]], x[[1]], ...), ...)
Arguments
x |
List of trees, in the format expected by |
Func |
distance function returning distance between two trees,
e.g. |
FUN.VALUE |
Format of output of |
... |
Additional parameters to pass to |
Details
CompareAll()
is not limited to tree comparisons:
Func
can be any symmetric function.
Value
CompareAll()
returns a distance matrix of class dist
detailing
the distance between each pair of trees.
Identical trees are assumed to have zero distance.
Author(s)
Martin R. Smith (martin.smith@durham.ac.uk)
Examples
# Generate a list of trees to compare
library("TreeTools", quietly = TRUE)
trees <- list(bal1 = BalancedTree(1:8),
pec1 = PectinateTree(1:8),
pec2 = PectinateTree(c(4:1, 5:8)))
# Compare each tree with each other tree
CompareAll(trees, NNIDist)
# Providing FUN.VALUE yields a modest speed gain:
dist <- CompareAll(trees, NNIDist, FUN.VALUE = integer(7))
# View distances as a matrix
as.matrix(dist$lower)
[Package TreeDist version 2.8.0 Index]