taxonTable2taxonTree: Create a Taxonomy-Based Phylogeny ('Taxon Tree') from a...

View source: R/taxonTable2TaxonTree.R

taxonTable2taxonTreeR Documentation

Create a Taxonomy-Based Phylogeny ('Taxon Tree') from a Hierarchical Table of Taxonomy Memberships

Description

This function takes a matrix of taxon names, indicating a set of hierarchical taxonomic relationships conveyed as nested placements for a set of tip-taxa (listed in the last column of the matrix) and returns a 'taxonomy-tree' phylogeny object of class phylo.

Usage

taxonTable2taxonTree(taxonTable, cleanTree = TRUE, rootLabel = "root")

Arguments

taxonTable

A matrix of type character and multiple rows and columns, containing the tip taxa in the last column, one per row, with progressively larger taxa listed in prior columns (reading left-to-right). Invariant columns (i.e. taxa that all tip taxa are in) are allowed, but all but the most 'shallow' of such invariant taxa are dropped prior to transformation to a taxon-tree phylogeny object.

cleanTree

When TRUE (the default), the tree is run through a series of post-processing, including 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. If FALSE, none of this post-processing is done and users should beware, as such trees can lead to hard-crashes of R.

rootLabel

If the lowest constant/shared level in the taxonomic hierarchy isn't labeled, what label should be given to this level? The default is "root".

Details

This function can deal with empty entries in cells of taxonTable by assuming these are lower-level taxa which are 'floating' freely somewhere in taxa several levels higher.

Value

A phylogeny of class phylo, where each tip is a taxon listed in the last column of the input taxonTable. Edges are scaled so that the distance from one taxon rank to another rank is one unit, then merged to remove singleton nodes. As not all taxa have parents at the immediate taxon level above, this leads to some odd cases. For example, two genera emanating from a node representing a class but with a very short (length = 1) branch and a long branch (length = 3) means one genus is simply placed in the class, with no family or order listed while the one on the long branch is within an order and family that is otherwise monogeneric.

The names of higher taxa than the tips should be appended as the element $node.label for the internal nodes.

Author(s)

David W. Bapst

See Also

makePBDBtaxonTree, parentChild2taxonTree

Examples


# let's create a small, really cheesy example
pokeTable <- rbind(cbind("Pokezooa","Shelloidea","Squirtadae",
     c("Squirtle","Blastoise","Wartortle")),
     c("Pokezooa","Shelloidea","","Lapras"),
     c("Pokezooa","","","Parasect"),
     cbind("Pokezooa","Hirsutamona","Rodentapokemorpha",
     c("Linoone","Sandshrew","Pikachu")),
     c("Pokezooa","Hirsutamona",NA,"Ursaring"))

pokeTree <- taxonTable2taxonTree(pokeTable)

plot(pokeTree)
nodelabels(pokeTree$node.label)


paleotree documentation built on Aug. 22, 2022, 9:09 a.m.