View source: R/inherit_taxonomies.R
| inherit_taxonomies | R Documentation |
Given a rooted tree and taxon names associated with some nodes and/or tips, infer the inherited taxonomic paths for all tips and/or nodes by concatenating the ancestral taxon names. Tip/node taxon names can be specified as separate vectors or taken from the tip/node labels stored in the tree itself.
inherit_taxonomies(tree,
tip_taxa = NULL,
node_taxa = NULL,
delimiter = ";",
only_proper = FALSE,
halt = "last",
strict_proper = TRUE,
focal_tips = NULL,
focal_nodes = NULL)
tree |
A rooted tree of class "phylo". |
tip_taxa |
Optional character vector of length Ntips, listing taxon names for the tips. These will be appended to the inherited taxonomies of the tips. If |
node_taxa |
Optional character vector of length Nnodes, listing taxon names for the nodes. If NULL, then node labels are assumed to be taxon names. Some elements in |
delimiter |
Character, the delimiter to use between taxonomic levels (e.g., ";" for SILVA taxonomies) |
only_proper |
Logical, whether to only include proper taxa in the inferred taxonomies. See option |
halt |
Character, specifying when to halt accumulating taxon levels, moving from root to tips. Options are |
strict_proper |
Logical, specifying whether to define taxa as proper in the strict sense, i.e., only if the taxon name is a properly encoded taxon name (i.e., contains no numeric digits, dashes or "candidatus"). If |
focal_tips |
Optional specification of tips to focus on. Either a character vector listing tip names, or an integer vector listing tip indices. If |
focal_nodes |
Optional specification of nodes to focus on. Either a character vector listing node names, or an integer vector listing node indices. If |
This function may be used for example to infer taxonomic paths of new genomes placed on a phylogeny/taxonomy such as the GTDB. Some taxa may be empty (""), i.e., not all tips/nodes are expected to have taxon names; empty taxa are never included in the returned taxonomies, not even as placeholders.
A named list with the following elements:
tip_taxonomies: Character vector of length Ntips (if focal_tips=NULL) or of the same length as focal_tips, listing the inferred "inheritted" taxonomies at the tips.
node_taxonomies: Character vector of length Nnodes (if focal_nodes=NULL) or of the same length as focal_nodes, listing the inferred "inheritted" taxonomies at each node.
tip_levels: Integer vector of the same length as tip_taxonomies, listing the number of concatenated taxonomic levels for each inferred tip taxonomy. Note that each taxon name is counted once, even if it consists of multiple levels; for example, if a node has taxon name "WOR-3; Hydrothermia" then any descending taxonomies will count this taxon as one level.
node_levels: Integer vector of the same length as node_taxonomies, listing the number of concatenated taxonomic levels for each inferred node taxonomy, similarly to tip_taxonomies.
Stilianos Louca
place_tips_taxonomically, consensus_taxonomies
# generate a random tree
tree = generate_random_tree(list(birth_rate_factor=0.1), max_tips=7)$tree
# define a character vector storing hypothetical node taxa
node_taxa = paste("taxon.",seq_len(tree$Nnode),sep="")
# infer inheritted taxonomies for all tips
inheritted = castor::inherit_taxonomies(tree, node_taxa = node_taxa)
print(inheritted$tip_taxonomies)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.