consensus_taxonomies {castor} | R Documentation |
Compute consensus taxonomies across a tree.
Description
Given a rooted phylogenetic tree and taxonomies for all tips, compute corresponding consensus taxonomies for all nodes in the tree based on their descending tips. The consensus taxonomy of a given node is the longest possible taxonomic path (i.e., to the lowest possible level) such that the taxonomies of all descending tips are nested within that taxonomic path. Some tip taxonomies may be incomplete, i.e., truncated at higher taxonomic levels. In that case, consensus taxonomy building will be conservative, i.e., no assumptions will be made about the missing taxonomic levels.
Usage
consensus_taxonomies(tree, tip_taxonomies = NULL, delimiter = ";")
Arguments
tree |
A rooted tree of class "phylo". |
tip_taxonomies |
Optional, character vector of length Ntips, listing taxonomic paths for the tips. If |
delimiter |
Character, the delimiter between taxonomic levels (e.g., ";" for SILVA and Greengenes taxonomies). |
Details
Examples:
If the descending tips of a node have taxonomies "A;B;C" and "A;B;C;D" and "A;B;C;E", then their consensus taxonomy is "A;B;C".
If the descending tips of a node have taxonomies "A;B" and "A;B;C;D" and "A;B;C;E", then their consensus taxonomy is "A;B".
If the descending tips of a node have taxonomies "X;B;C" and "Y;B;C", then their consensus taxonomy is "" (i.e., empty).
Value
A character vector of length Nnodes, listing the inferred consensus taxonomies for all nodes in the tree.
Author(s)
Stilianos Louca
See Also
Examples
# generate a random tree
tree = generate_random_tree(list(birth_rate_factor=0.1), max_tips=7)$tree
# define a character vector storing hypothetical tip taxonomies
tip_taxonomies = c("R;BB;C", "AA;BB;C;DD", "AA;BB;C;E",
"AA;BB", "AA;BB;D", "AA;BB;C;F", "AA;BB;C;X")
# compute consensus taxonomies and store them in the tree as node labels
tree$node.label = castor::consensus_taxonomies(tree,
tip_taxonomies = tip_taxonomies,
delimiter = ";")