Learn R Programming

taxize (version 0.9.4)

classification: Retrieve the taxonomic hierarchy for a given taxon ID.

Description

Retrieve the taxonomic hierarchy for a given taxon ID.

Usage

classification(...)

# S3 method for default classification(x, db = NULL, callopts = list(), return_id = TRUE, rows = NA, ...)

# S3 method for tsn classification(id, return_id = TRUE, ...)

# S3 method for uid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for eolid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for colid classification(id, start = NULL, checklist = NULL, callopts = list(), return_id = TRUE, ...)

# S3 method for tpsid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for gbifid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for nbnid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for tolid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for wormsid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for natservid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for boldid classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for wiki classification(id, callopts = list(), return_id = TRUE, ...)

# S3 method for ids classification(id, ...)

# S3 method for classification cbind(...)

# S3 method for classification rbind(...)

# S3 method for classification_ids cbind(...)

# S3 method for classification_ids rbind(...)

Arguments

...

For classification: other arguments passed to get_tsn, get_uid, get_eolid, get_colid, get_tpsid, get_gbifid, get_wormsid, get_natservid, get_wormsid, get_wiki. For rbind.classification and cbind.classification: one or more objects of class classification

x

Vector of taxa names (character) or IDs (character or numeric) to query.

db

character; database to query. either ncbi, itis, eol, col, tropicos, gbif, nbn, worms, natserv, bold, or wiki. Note that each taxonomic data source has, their own identifiers, so that if you provide the wrong db value for the identifier you could get a result, but it will likely be wrong (not what you were expecting).

callopts

Curl options passed on to GET

return_id

(logical) If TRUE (default), return the taxon id as well as the name and rank of taxa in the lineage returned. Ignored for natserv as they don't return IDs in their taxonomic classification data.

rows

(numeric) Any number from 1 to infinity. If the default NA, all rows are considered. Note that this parameter is ignored if you pass in a taxonomic id instead of a name of class character.

start

The first record to return. If omitted, the results are returned from the first record (start=0). This is useful if the total number of results is larger than the maximum number of results returned by a single Web service query (currently the maximum number of results returned by a single query is 500 for terse queries and 50 for full queries).

checklist

character; The year of the checklist to query, if you want a specific year's checklist instead of the lastest as default (numeric).

Value

A named list of data.frames with the taxonomic classification of every supplied taxa.

Lots of results

It may happen sometimes that you get more results back from your query than will show in the data.frame on screen. Our advice is to refine your query in those cases. On a data source basis we can attempt to help make it easier to refine queries, whether it be with the data provider (unlikely to happen), or in the code in this package (more likely) - let us know if you run into too many results problem and we'll see what we can do.

Authentication

See getkey

Details

If IDs are supplied directly (not from the get_* functions) you must specify the type of ID. There is a timeout of 1/3 seconds between queries to NCBI.

BEWARE: Right now, NBN doesn't return the queried taxon in the classification. But you can attach it yourself quite easily of course. This behavior is different from the other data sources.

See Also

get_tsn, get_uid, get_eolid, get_colid, get_tpsid, get_gbifid get_wormsid, get_natservid, get_boldid, get_wiki

Examples

Run this code
# NOT RUN {
# Plug in taxon IDs
classification(9606, db = 'ncbi')
classification(c(9606, 55062), db = 'ncbi')
classification(129313, db = 'itis')
classification(57361017, db = 'eol')
classification(126436, db = 'worms')
classification("ELEMENT_GLOBAL.2.134717", db = 'natserv')
classification(c(2704179, 2441176), db = 'gbif')
classification(25509881, db = 'tropicos')
classification("NBNSYS0000004786", db = 'nbn')
classification(as.nbnid("NBNSYS0000004786"), db = 'nbn')
classification(3930798, db = 'tol')

## works the same if IDs are in class character
classification(c("2704179", "2441176"), db = 'gbif')
classification("Agapostemon", db = "bold")

# wikispecies
classification("Malus domestica", db = "wiki")
classification("Pinus contorta", db = "wiki")
classification("Pinus contorta", db = "wiki", wiki_site = "commons")
classification("Pinus contorta", db = "wiki", wiki_site = "pedia")
classification("Pinus contorta", db = "wiki", wiki_site = "pedia", wiki = "fr")

classification(get_wiki("Malus domestica", "commons"))
classification(get_wiki("Malus domestica", "species"))
classification(c("Pinus contorta", "Malus domestica"), db = "wiki")

# Plug in taxon names
## in this case, we use get_*() fxns internally to first get taxon IDs
classification(c("Chironomus riparius", "aaa vva"), db = 'ncbi')
classification(c("Chironomus riparius", "aaa vva"), db = 'ncbi',
  messages=FALSE)
classification(c("Chironomus riparius", "aaa vva"), db = 'itis')
classification(c("Chironomus riparius", "aaa vva"), db = 'itis',
  messages=FALSE)
classification(c("Chironomus riparius", "aaa vva"), db = 'eol')
classification(c("Chironomus riparius", "aaa vva"), db = 'col')
classification("Alopias vulpinus", db = 'nbn')
classification('Gadus morhua', db = 'worms')
classification('Aquila chrysaetos', db = 'natserv')
classification('Gadus morhua', db = 'natserv')
classification('Pomatomus saltatrix', db = 'natserv')
classification('Aquila chrysaetos', db = 'natserv')
classification(c("Chironomus riparius", "aaa vva"), db = 'col',
  messages=FALSE)
classification(c("Chironomus riparius", "asdfasdfsfdfsd"), db = 'gbif')
classification("Chironomus", db = 'tol')
classification("Poa annua", db = 'tropicos')

# Use methods for get_uid, get_tsn, get_eolid, get_colid, get_tpsid
classification(get_uid(c("Chironomus riparius", "Puma concolor")))

classification(get_uid(c("Chironomus riparius", "aaa vva")))
classification(get_tsn(c("Chironomus riparius", "aaa vva")))
classification(get_tsn(c("Chironomus riparius", "aaa vva"),
  messages = FALSE))
classification(get_eolid(c("Chironomus riparius", "aaa vva")))
classification(get_colid(c("Chironomus riparius", "aaa vva")))
classification(get_tpsid(c("Poa annua", "aaa vva")))
classification(get_gbifid(c("Poa annua", "Bison bison")))

# Pass many ids from class "ids"
(out <- get_ids(names="Puma concolor", db = c('ncbi','gbif')))
(cl <- classification(out))

# Bind width-wise from class classification_ids
cbind(cl)

# Bind length-wise
rbind(cl)

# Many names to get_ids
(out <- get_ids(names=c("Puma concolor","Accipiter striatus"),
  db = c('ncbi','itis','col')))
(cl <- classification(out))
rbind(cl)
## cbind with so many names results in some messy data
cbind(cl)
## so you can turn off return_id
cbind( classification(out, return_id=FALSE) )

# rbind and cbind on class classification (from a
# call to get_colid, get_tsn, etc. other than get_ids)
(cl_col <- classification(
  get_colid(c("Puma concolor","Accipiter striatus"))))
rbind(cl_col)
cbind(cl_col)

(cl_uid <- classification(get_uid(c("Puma concolor","Accipiter striatus")),
  return_id=FALSE))
rbind(cl_uid)
cbind(cl_uid)
## cbind works a bit odd when there are lots of ranks without names
(cl_uid <- classification(get_uid(c("Puma concolor","Accipiter striatus")),
  return_id=TRUE))
cbind(cl_uid)

(cl_tsn <- classification(get_tsn(c("Puma concolor","Accipiter striatus"))))
rbind(cl_tsn)
cbind(cl_tsn)

(tsns <- get_tsn(c("Puma concolor","Accipiter striatus")))
(cl_tsns <- classification(tsns))
cbind(cl_tsns)

# NBN data
(res <- classification(c("Alopias vulpinus","Pinus sylvestris"),
  db = 'nbn'))
rbind(res)
cbind(res)

# Return taxonomic IDs
## the return_id parameter is logical, and you can turn it on or off.
## It's TRUE by default
classification(c("Alopias vulpinus","Pinus sylvestris"), db = 'ncbi',
  return_id = TRUE)
classification(c("Alopias vulpinus","Pinus sylvestris"), db = 'ncbi',
  return_id = FALSE)

# Use rows parameter to select certain
classification('Poa annua', db = 'tropicos')
classification('Poa annua', db = 'tropicos', rows=1:4)
classification('Poa annua', db = 'tropicos', rows=1)
classification('Poa annua', db = 'tropicos', rows=6)
# }
# NOT RUN {
# }
# NOT RUN {
# Fails without db param set
# classification(315576)
# }

Run the code above in your browser using DataLab