PhyloDistance-KFDist | R Documentation |
Calculate KF distance between two unrooted phylogenies.
This function is called as part of PhyloDistance
and calculates Kuhner-Felsenstein distance between two unrooted phylogenies. Each dendrogram is first pruned to only internal branches implying a partition in the shared leaf set; trivial partitions (where one leaf set contains 1 or 0 leaves) are ignored. The total score is calculated as the sum of squared differences between lengths of branches implying equivalent partitions. If a particular branch is unique to a given tree, it is treated as having length 0 in the other tree. The final score is normalized by the sum of squared lengths of all internal branches of both trees, resulting in a final distance that ranges from 0 to 1.
Returns a normalized distance, with 0 indicating identical trees and 1 indicating maximal difference.
If the trees have no leaves in common, the function will return 1
.
Note that this function requires the input dendrograms to be labeled alike (ex.
leaf labeled abc
in dend1
represents the same species as
leaf labeled abc
in dend2
).
Labels can easily be modified using dendrapply
.
Aidan Lakshman ahl27@pitt.edu
Robinson, D.F. and Foulds, L.R. Comparison of phylogenetic trees. Mathematical Biosciences, 1987. 53(1–2): 131–147.
Kuhner, M. K. and Felsenstein, J. Simulation comparison of phylogeny algorithms under equal and unequal evolutionary rates. Molecular Biology and Evolution, 1994. 11: 459–468.
# making some toy dendrograms
set.seed(123)
dm1 <- as.dist(matrix(runif(64, 0.5, 5), ncol=8))
dm2 <- as.dist(matrix(runif(64, 0.5, 5), ncol=8))
tree1 <- as.dendrogram(hclust(dm1))
tree2 <- as.dendrogram(hclust(dm2))
# get KF distance
PhyloDistance(tree1, tree2, Method="KF")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.