View source: R/extract_tip_neighborhood.R
extract_tip_neighborhood | R Documentation |
Given a rooted tree and a focal tip, extract a subtree comprising various representative nodes and tips in the vicinity of the focal tip using a heuristic algorithm. This may be used for example to display closely related taxa from a reference tree.
extract_tip_neighborhood(tree,
focal_tip,
Nbackward,
Nforward,
force_tips = NULL,
include_subtree = TRUE)
tree |
A rooted tree of class "phylo". |
focal_tip |
Either a character, specifying the name of the focal tip, or an integer between 1 and Ntips, specifying the focal tip's index. |
Nbackward |
Integer >=1, specifying how many splits backward (towards the root) to explore. A larger value of |
Nforward |
Non-negative integer, specifying how many splits forward (towards the tips) to explore. A larger value of |
force_tips |
Optional integer or character list, specifying indices or names of tips to force-include in any case. |
include_subtree |
Logical, whether to actually extract the subtree, rather than just returning the inferred neighbor tips. |
The tree may include multi-furcations as well as mono-furcations (i.e. nodes with only one child). The input tree must be rooted at some node for technical reasons (see function root_at_node
), but the choice of the root node does not influence which tips are extracted.
A named list with the following elements:
neighbor_tips |
Integer vector with values in 1,..,Ntips, specifying which tips were found to be neighbors of the focal tip. |
subtree |
A new tree of class "phylo", containing a subset of the tips and nodes in the vicinity of the focal tip. Only returned if |
new2old_tip |
Integer vector of length Ntips_extracted (=number of tips in the extracted subtree) with values in 1,..,Ntips, mapping tip indices of the extracted subtree to tip indices in the original tree. In particular, |
Stilianos Louca
get_subtree_with_tips
# generate a random tree
Ntips = 50
tree = generate_random_tree(list(birth_rate_factor=0.1),
max_tips = Ntips,
tip_basename="tip.")$tree
# extract a subtree in the vicinity of a focal tip
subtree = extract_tip_neighborhood(tree,
focal_tip="tip.39",
Nbackward=5,
Nforward=2)$subtree
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.