SPRDist: Approximate the Subtree Prune and Regraft distance

View source: R/tree_distance_spr.R

SPRDistR Documentation

Approximate the Subtree Prune and Regraft distance

Description

SPRDist() approximates the SPR distance between trees.

Usage

SPRDist(tree1, tree2 = NULL, method = "deOliveira", symmetric)

## S3 method for class 'phylo'
SPRDist(tree1, tree2 = NULL, method = "deOliveira", symmetric)

## S3 method for class 'list'
SPRDist(tree1, tree2 = NULL, method = "deOliveira", symmetric)

## S3 method for class 'multiPhylo'
SPRDist(tree1, tree2 = NULL, method = "deOliveira", symmetric)

Arguments

tree1, tree2

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 \insertCiteDay1985;textualTreeDist.

method

Character specifying which method to use to approximate the SPR distance. Currently defaults to ⁠"deOliveira"``. ⁠"Rogue"' implements an experimental method whose details are pending publication; this function is under development, and may be modified or removed without notice. Once formally validated, it is anticipated that this method will become the default.

symmetric

Deprecated (redundant after fix of phangorn#97).

Details

The function currently defaults to the heuristic method of \insertCitedeOliveira2008;textualTreeDist, which purports to provide an upper bound on the SPR distance (though exceptions exist). Other approximations \insertCite@e.g. @Hickey2008, @Goloboff2008SPR, @Whidden2018TreeDist are not yet implemented.

Value

SPRDist() returns a vector or distance matrix of distances between trees.

Author(s)

Martin R. Smith (martin.smith@durham.ac.uk)

References

\insertAllCited

See Also

Exact calculation with TBRDist functions USPRDist() and ReplugDist().

phangorn function SPR.dist() employs the \insertCitedeOliveira2008;textualTreeDist algorithm but can crash when sent trees of certain formats, and tends to have a longer running time.

Other tree distances: HierarchicalMutualInfo(), JaccardRobinsonFoulds(), KendallColijn(), MASTSize(), MatchingSplitDistance(), NNIDist(), NyeSimilarity(), PathDist(), Robinson-Foulds, TreeDistance()

Examples

library("TreeTools", quietly = TRUE)

# Compare single pair of trees
SPRDist(BalancedTree(7), PectinateTree(7))

# Compare all pairs of trees
SPRDist(as.phylo(30:33, 8))

# Compare each tree in one list with each tree in another
SPRDist(BalancedTree(7), as.phylo(0:2, 7))
SPRDist(as.phylo(0:2, 7), PectinateTree(7))

SPRDist(list(bal = BalancedTree(7), pec = PectinateTree(7)),
        as.phylo(0:2, 7))

TreeDist documentation built on Feb. 13, 2026, 5:10 p.m.