treemakr: Convert a table of taxonomic relationships into a...

Description Usage Arguments Details Value Examples

View source: R/treemakr.R

Description

Converts a table of taxa into a phylogenetic tree or matrix. The phylogenetic tree produced will be rooted with a topology corresponding to the child-parent relationships encoded in the table and branch lengths determined by the ages of taxa provided in the table. The phylogenetic matrix produced records the distribution of child taxa amongst parent taxa.

Usage

1
treemakr(x, output)

Arguments

x

is a data.frame with a row for each taxon. To produce a phylogenetic tree, every tip and internal node (including the root) must be represented by a row. x includes the following columns.

  • Taxon is a character vector giving the names of taxa (assigned to tips and internal nodes).

  • Parent is a character vector giving the corresponding parent taxon. Each parent name must match exactly to a name in Taxon, except for the root node which must be labelled as "Root".

  • Node_type is a character vector labelling each row as one of "Root", "Tip" or "Internal".

  • Node_age is numeric vector giving the age of the internal node or tip. Tips would normally have an age of 0 unless extinct. This column is not required if generating a phylogenetic matrix only.

output

is a character vector of length 1 indicating whether the output should be a matrix (output="matrix") or a tree (output="tree").

Details

treemakr takes a table of child-parent relationships among taxa and converts to a phylogenetic tree or matrix. The table could be encoded from a published phylogenetic tree, for which no newick or nexus file is available, or from a hierarchical taxonomy. If a tree is desired, node ages are required but these could be arbitrary (e.g. representing taxonomic level).

Value

If output="matrix", a binary matrix is returned with a row for each tip and a column for each internal and terminal (tip) node. If a tip is descendant from that node, the matrix records that relationship as a 1, and 0 otherwise. If output="tree", a phylo object (see ape package) is returned. If the taxa in x are not in cladewise order, the resulting tree will not plot correctly in ape (the plot function requires trees to be organised in cladewise order). This can be easily fixed by writing the tree to a Newick or Nexus file (using the write.tree or write.nexus in the ape package) and then reading the file back into R.

Examples

1
2

davidnipperess/PDcalc documentation built on July 7, 2021, 1:07 p.m.