extract_taxonomy

0th

Percentile

Extract taxonomy information from sequence headers

Extracts the taxonomy from metadata (e.g. sequence headers) or parsed sequence data. The location and identity of important information in the input is specified using a regular expression with capture groups and an corresponding key. An object of type taxmap is returned containing the specifed information. Taxa are translated into unique codes if they are not already encoded this way.

Usage
extract_taxonomy(input, ...)
"extract_taxonomy"(input, key = c("class", "taxon_id", "name", "taxon_info", "obs_id", "obs_info"), regex = "(.*)", class_key = c("name", "taxon_id", "taxon_info"), class_regex = "(.*)", class_sep = NULL, class_rev = FALSE, database = c("none", "ncbi", "itis", "eol", "col", "tropicos", "nbn"), allow_na = TRUE, vigilance = c("warning", "error", "message", "none"), return_match = FALSE, return_input = FALSE, redundant_names = FALSE, verbosity = c("low", "none", "high"), ...)
"extract_taxonomy"(input, ...)
"extract_taxonomy"(input, ...)
Arguments
input
A vector from which to extract taxonomy information or an object of class ape{DNAbin}.
...
Not used.
key
(character) The identity of the capturing groups defined using regex. The length of key must be equal to the number of capturing groups specified in regex. Any names added to the terms will be used as column names in the output. Only "taxon_info" and "obs_info" can be used multiple times. Each term must be one of those decribed below:
regex
(character; length == 1) A regular expression with capturing groups indicating the locations of relevant information. The identity of the information must be specified using the key argument.
class_key
(character of length 1) The identity of the capturing groups defined using class_iregex. The length of class_key must be equal to the number of capturing groups specified in class_regex. Any names added to the terms will be used as column names in the output. At least "taxon_id" or "name" must be specified. Only "taxon_info" can be used multiple times. Each term must be one of those decribed below:
class_regex
(character of length 1) A regular expression with capturing groups indicating the locations of data for each taxon in the class term in the key argument. The identity of the information must be specified using the class_key argument. The class_sep option can be used to split the classification into data for each taxon before matching. If class_sep is NULL, each match of class_regex defines a taxon in the classification.
class_sep
(character of length 1) Used with the class term in the key argument. The character(s) used to separate individual taxa within a classification. After the string defined by the class capture group in regex is split by class_sep, its capture groups are extracted by class_regex and defined by class_key. If NULL, every match of class_regex is used instead with first splitting by class_sep.
class_rev
(logical of length 1) Used with the class term in the key argument. If TRUE, the order of taxon data in a classfication is reversed to be specific to broad.
database
(character of length 1) The name of the database that patterns given in parser will apply to. Valid databases include "ncbi", "itis", "eol", "col", "tropicos", "nbn", and "none". "none" will cause no database to be quired; use this if you want to not use the internet. NOTE: Only "ncbi" has been tested so far.
allow_na
(logical of length 1) If TRUE, any missing data will be represented as NAs in the output. This preserves the correspondance between the input and output values. Missing data can be generated if the regex does not match the input or online queries fail.
vigilance
(character of length 1) Controls the reporting of possible problems, such as missing data and failed online queries (see allow_na). The following values are possible:
return_match
(logical of length 1) If TRUE, include the part of the input matched by regex in the output object.
return_input
(logical of length 1) If TRUE, include the input in the output object.
redundant_names
(logical of length 1) If TRUE, remove any occurrence of the a supertaxon's name at the start of the taxon name. This is useful for removing the redundant genus information in species binomials.
verbosity
(character of length 1) Controls the printing of progress updates. The following values are possible:
Value

Returns an object of type taxmap

Aliases
  • extract_taxonomy
  • extract_taxonomy.DNAbin
  • extract_taxonomy.default
  • extract_taxonomy.list
Examples
## Not run: 
# # Extract embedded classifications from UNITE FASTA file offline
# file_path <- system.file("extdata", "unite_general_release.fasta", package = "metacoder")
# sequences <- ape::read.FASTA(file_path)
# unite_ex_data_3 <- extract_taxonomy(sequences,
#                                     regex = "^(.*)\\|(.*)\\|(.*)\\|.*\\|(.*)$",
#                                     key = c(name = "obs_info", seq_id = "obs_info",
#                                             other_id = "obs_info", "class_name"),
#                                     database = "none")
# # Look up taxonomic data online using sequence ID
# unite_ex_data <- extract_taxonomy(sequences,
#                                   regex = "^(.*)\\|(.*)\\|(.*)\\|.*\\|(.*)$",
#                                 key = c(name = "name", seq_id = "obs_id",
#                                        other_id = "obs_info", tax_string = "obs_info"))
# ## End(Not run)

Documentation reproduced from package metacoder, version 0.1.2, License: GPL-2 | GPL-3

Community examples

Looks like there are no examples yet.