View source: R/tree_from_taxa.R
tree_from_taxa | R Documentation |
Given a collection of taxon lists, construct a rooted taxonomic tree. Each taxon list is defined by a parent name and the names of its children (i.e., immediate descendants).
tree_from_taxa(taxa)
taxa |
Named list, whose elements are character vectors, each representing a parent and its children. The element names of |
The following rules apply:
Each taxon must appear at most once as a parent and at most once as a child.
Any taxa found as parents but not as children, will be assumed to descend directly from the root. If only one such taxon was found, it will become the root itself.
Any taxa found as a child but not as a parent, will become tips.
Any parents without children will be considered tips.
Empty parent names (i.e., "") are not allowed.
Taxa can be specified in any arbitrary order, including breadth-first, depth-first etc.
Since the returned tree is a taxonomy, it will contain no edge lengths.
A rooted tree of class "phylo".
Stilianos Louca
consensus_taxonomies
,
place_tips_taxonomically
# define a list of taxa, with taxon "A" being the root
# Taxa G, H, I, J, K, L, M, N and O will be tips
taxa = list(A = c("B","C","D"),
B = c("E","I"),
C = c("J","F"),
D = c("M", "N", "O"),
E = c("G", "H"),
F = c("K", "L"))
tree = castor::tree_from_taxa(taxa)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.