Approximate the Subtree Prune and Regraft (SPR) distance.
SPRDist(tree1, tree2 = NULL, symmetric = TRUE)
Trees of class phylo
, with leaves labelled identically,
or lists of such trees to undergo pairwise comparison. Where implemented,
tree2 = NULL
will compute distances between each pair of trees in the list
tree1
using a fast algorithm based on Day (1985).
Logical specifying whether to produce a better heuristic
by calculating the minimum of SPRDist(t1, t2)
and SPRDist(t2, t1)
,
which are not guaranteed to be equal due to the heuristic nature of the
approximation (see
phangorn#97). Set to
FALSE
for the faster approximation, as implemented in "phangorn".
SPRDist()
returns a vector or distance matrix of distances
between trees.
SPRDist()
is a wrapper for the function
SPR.dist()
in the phangorn package.
It pre-processes trees to ensure that their internal representation does
not cause the SPR.dist()
function to crash R, and allows an improved
(but slower) symmetric heuristic.
A memory leak is present in phangorn v2.5.5. To avoid a drain on system
resources, install the latest version of phangorn with
devtools::install_github("KlausVigo/phangorn")
.
Other tree distances:
JaccardRobinsonFoulds()
,
KendallColijn()
,
MASTSize()
,
MatchingSplitDistance()
,
NNIDist()
,
NyeSimilarity()
,
PathDist()
,
Robinson-Foulds
,
TreeDistance()
library("TreeTools", quietly = TRUE)
SPRDist(BalancedTree(7), PectinateTree(7))
#> spr
#> 1
SPRDist(BalancedTree(7), as.phylo(0:2, 7))
#> [1] 2 2 2
SPRDist(as.phylo(0:2, 7), PectinateTree(7))
#> [1] 1 2 2
SPRDist(list(bal = BalancedTree(7), pec = PectinateTree(7)),
as.phylo(0:2, 7))
#> [,1] [,2] [,3]
#> bal 2 2 2
#> pec 1 2 2
CompareAll(as.phylo(30:33, 8), SPRDist)
#> 1 2 3 4
#> 1 1 1 1
#> 2 1 1 1
#> 3 1 1 1
#> 4 1 1 1