tree_from_taxonomy: Gets a taxonomic tree from a vector of taxa

View source: R/tree_from_taxonomy.R

tree_from_taxonomyR Documentation

Gets a taxonomic tree from a vector of taxa


This uses the taxize package's wrapper of the Global Names Resolver to get taxonomic paths for the vector of taxa you pass in. Sources is a vector of source labels in order (though it works best if everything uses the same taxonomy, so we recommend doing just one source). You can see options by doing taxize::gnr_datasources(). Our default is Catalogue of Life. The output is a phylo object (typically with many singleton nodes if collapse_singles is FALSE: nodes with only one descendant (like "Homo" having "Homo sapiens" as its only descendant) but these singletons typically have node.labels


  sources = "Catalogue of Life",
  collapse_singles = TRUE



Vector of taxon names


Vector of names of preferred sources; see taxize::gnr_datasources(). Currently supports 100 taxonomic resources, see details.


If true, collapses singleton nodes


A list containing a phylo object with resolved names and a vector with unresolved names


taxa <- c(
  "Homo sapiens", "Ursus arctos", "Pan paniscus", "Tyrannosaurus rex",
  "Ginkgo biloba", "Vulcan", "Klingon"
results <- tree_from_taxonomy(taxa)
print(results$unresolved) # The taxa that do not match
ape::plot.phylo(results$phy) # may generate warnings due to problems with singletons
ape::plot.phylo($phy), show.node.label = TRUE)
# got rid of singles, but this also removes a lot of the node.labels
 # end donttest

OpenTreeChronograms documentation built on June 22, 2022, 9:08 a.m.