ro warning=FALSE, message=FALSE, comment=NA, cache=FALSE or
name: get-taxa-downstream layout: post title: Getting taxonomic names downstream date: 2012-10-16 author: Scott Chamberlain tags:
- open access
It can be a pain in the ass to get taxonomic names. For example, I sometimes need to get all the Class names for a set of species. This is a relatively easy problem using the ITIS API (example below).
The much harder problem is getting all the taxonomic names downstream. ITIS doesn't provide an API method for this - well, they do (
getHirerachyDownFromTSN), but it only provides direct children (e.g., the genera within a tribe - but it won't give all the species within each genus).
So in the
taxize package, we wrote a function called
downstream, which allows you to get taxonomic names to any downstream point, e.g.:
- get all Classes within Animalia,
- get all Species within a Family
Install packages. You can get other packages from CRAN, but taxize is only on GitHub for now.
# install_github('ritis', 'ropensci') # uncomment if not already installed # install_github('taxize_', 'ropensci') # uncomment if not already installed library(ritis); library(taxize)
Get upstream taxonomic names.
# Search for a TSN by scientific name df <- searchbyscientificname("Tardigrada") tsn <- df[df$combinedname %in% "Tardigrada","tsn"] # Get just one immediate higher taxonomic name gethierarchyupfromtsn(tsn = tsn) # Get full hierarchy upstream from TSN getfullhierarchyfromtsn(tsn = tsn)
Get taxonomc names downstream.
# Get genera downstream fromthe Class Bangiophyceae downstream(846509, "Genus") # Get families downstream from __Acridoidea__ downstream(650497, "Family") # Get species downstream from __Ursus__ downstream(180541, "Species")