Skip to contents

Resolves the names, attaches their full higher classification, and assembles a taxonomy tree (kingdom -> phylum -> class -> order -> family -> genus -> species) from the shared lineages. Returns the tree as a Newick string and the underlying classification table; when the ape package is installed, an ape phylo object is included too.

Usage

class2tree(x, backbone = NULL, verbose = TRUE)

# S3 method for class 'taxify_tree'
print(x, ...)

Arguments

x

Character vector of names, or a taxify() result.

backbone

Backend passed to taxify() when x is raw names. NULL (default) uses every installed backbone. Ignored when x is a result.

verbose

Logical. Default TRUE.

...

Ignored, present for S3 print method consistency.

Value

An object of class taxify_tree: a list with

newick

The Newick string (internal nodes labelled by rank value, tips by species name).

classification

The classification data.frame the tree was built from.

tip_labels

The species at the tips.

phylo

An ape phylo object, or NULL if ape is not installed / the string could not be parsed.

Examples

# Runs offline against the bundled example database.
old <- options(taxify.data_dir = taxify_example_data())

tr <- class2tree(c("Quercus robur", "Quercus petraea", "Quercus pyrenaica"))
tr$newick

options(old)