Calculate the path distance between trees.

PathDist(tree1, tree2 = NULL)

## 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 Day (1985).

## Value

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

## Details

This function is a wrapper for the function path.dist() in the phangorn package. It pre-processes trees to ensure that their internal representation does not cause the path.dist() function to crash R.

The path distance is calculated by tabulating the cladistic difference (= topological distance) between each pair of tips in each tree. A precursor to the path distance (Farris, 1969) took the mean squared difference between the elements of each tree's tabulation (Farris, 1973); the method used here is that proposed by Steel & Penny (1993), which takes the square root of this sum. Other precursor measures are described in Williams and Clifford (1971) and Phipps (1971).

Use of the path distance is discouraged as it emphasizes shallow relationships at the expense of deeper (and arguably more fundamental) relationships (Farris, 1973).

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

## Examples

library('TreeTools')

PathDist(BalancedTree(7), PectinateTree(7))
#>  4.690416

PathDist(BalancedTree(7), as.phylo(0:2, 7))
#>  7.348469 6.782330 7.348469
PathDist(as.phylo(0:2, 7), PectinateTree(7))
#>  7.745967 8.246211 8.124038

PathDist(list(bal = BalancedTree(7), pec = PectinateTree(7)),
as.phylo(0:2, 7))
#> NULL

CompareAll(as.phylo(30:33, 8), PathDist)
#>          1        2        3        4
#> 1          3.872983 3.872983 5.567764
#> 2 3.872983          3.464102 6.928203
#> 3 3.872983 3.464102          6.928203
#> 4 5.567764 6.928203 6.928203