all.equal.treeshape: Compare two objects of class treeshape

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function makes a global comparison of two phylogenetic trees.

Usage

1
2
## S3 method for class 'treeshape'
all.equal(target, current, names=FALSE, height=FALSE, ...)

Arguments

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.

Details

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.

Value

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.

Author(s)

Michael Blum <michael.blum@imag.fr>
Nicolas Bortolussi <nicolas.bortolussi@imag.fr>
Eric Durand <eric.durand@imag.fr>
Olivier Francois <olivier.francois@imag.fr>

See Also

all.equal for the generic R function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  
## 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)

apTreeshape documentation built on Jan. 8, 2021, 2:07 a.m.