Test the Edge Matrix of a 'phylo' Phylogeny Object for Inconsistencies

Share:

Description

testEdgeMat is a small simple function which tests the $edge matrix of 'phylo' objects for inconsistencies that can cause downstream analytical problems. The associated function, cleanNewPhylo puts an input phylo object, presumably freshly created or reconstituted by some function, through a series of post-processing, This includes having singles collapsed, nodes reordered and being written out as a Newick string and read back in, to ensure functionality with ape functions and ape-derived functions.

Usage

1
2
3

Arguments

tree

A phylogeny object of type phylo

Details

Useful when doing complex manipulations and reconstitutions of 'phylo' objects (or their de novo construction), and thus is used by a number of paleotree functions.

Value

For testEdgeMat, if all the checks in the function pass correctly, the logical TRUE is returned.

For cleanNewPhylo, an object of class 'phylo' is returned.

Author(s)

David W. Bapst, with a large number of tests incorporated from Emmanuel Paradis's checkValidPhylo function, provided at his github repo here, which was released GPL v>2:

https://github.com/emmanuelparadis/checkValidPhylo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
set.seed(444)
tree<-rtree(10)
# should return TRUE
testEdgeMat(tree)

# should also work on star trees
testEdgeMat(stree(10))

# should also work on trees with two taxa
testEdgeMat(rtree(2))

# should also work on trees with one taxon
testEdgeMat(stree(1))

#running cleanNewPhylo on this tree should have little effect
		#beyond ladderizing it...
tree1<-cleanNewPhylo(tree)

#compare outputs
layout(1:2)
plot(tree)
plot(tree1)
layout(1)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.