all.equal.treeshape {apTreeshape} | R Documentation |
This function makes a global comparison of two phylogenetic trees.
## S3 method for class 'treeshape': all.equal(target, current, names=FALSE, height=FALSE, ...)
target |
An object of class "treeshape" . |
current |
An object of class "treeshape" . |
names |
An object of class "logical" , checking if the names of the tips should be tested. If FALSE (default), the names of the tips are not compared. |
height |
An object of class "logical" , checking if the heights of the nodes should be tested. If FALSE (default), the height of internal nodes are not compared. |
... |
further arguments passed to or from other methods. |
This function is meant to be an adaptation of the generic function all.equal
for the comparison of phylogenetic trees. A phylogenetic tree can have many different representations. Permutations between the left and the right daughter clade of a node do not change the corresponding phylogeny, and all.equal.treeshape
returns TRUE
on two permutated trees.
Returns the logical TRUE
if the tree objects are similar up to a permutation of their tips. Otherwise, it returns FALSE
. Heights and labels can be taken into account.
Michael Blum <michael.blum@imag.fr>
Nicolas Bortolussi <nicolas.bortolussi@imag.fr>
Eric Durand <eric.durand@imag.fr>
Olivier Francois <olivier.francois@imag.fr>
all.equal
for the generic R function.
## Trees with permutations data(carnivora.treeshape) tree=carnivora.treeshape tree$merge[8,]=c(tree$merge[8,2],tree$merge[8,1]) all.equal(tree, carnivora.treeshape) ## Trees with different heights merge=matrix(NA, 3, 2) merge[,1]=c(-3,-1,2); merge[,2]=c(-4,-2,1);tree1=treeshape(merge) merge[,1]=c(-1,-3,1); merge[,2]=c(-2,-4,2);tree2=treeshape(merge) plot(tree1, tree2) all.equal(tree1, tree2) all.equal(tree1, tree2, height=TRUE) ## Trees with different names tree3=treeshape(tree1$merge, c("a", "b", "c", "d")) tree4=treeshape(tree1$merge, c("1", "2", "3", "4")) plot(tree3, tree4) all.equal(tree3, tree4) all.equal(tree3, tree4, names=TRUE)