View source: R/find_farthest_tips.R
find_farthest_tips | R Documentation |
Given a rooted phylogenetic tree and a subset of potential target tips, for each tip and node in the tree find the farthest target tip. The set of target tips can also be taken as the whole set of tips in the tree.
find_farthest_tips( tree,
only_descending_tips = FALSE,
target_tips = NULL,
as_edge_counts = FALSE,
check_input = TRUE)
tree |
A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge. |
only_descending_tips |
A logical indicating whether the farthest tip to a node or tip should be chosen from its descending tips only. If FALSE, then the whole set of possible target tips is considered. |
target_tips |
Optional integer vector or character vector listing the subset of target tips to restrict the search to. If an integer vector, this should list tip indices (values in 1,..,Ntips). If a character vector, it should list tip names (in this case |
as_edge_counts |
Logical, specifying whether to count phylogenetic distance in terms of edge counts instead of cumulative edge lengths. This is the same as setting all edge lengths to 1. |
check_input |
Logical, whether to perform basic validations of the input data. If you know for certain that your input is valid, you can set this to |
If only_descending_tips
is TRUE
, then only descending target tips are considered when searching for the farthest target tip of a node/tip. In that case, if a node/tip has no descending target tip, its farthest target tip is set to NA. If tree$edge.length
is missing or NULL, then each edge is assumed to have length 1. The tree may include multi-furcations as well as mono-furcations (i.e. nodes with only one child).
The asymptotic time complexity of this function is O(Nedges), where Nedges is the number of edges in the tree.
A list with the following elements:
farthest_tip_per_tip |
An integer vector of size Ntips, listing the farthest target tip for each tip in the tree. Hence, |
farthest_tip_per_node |
An integer vector of size Nnodes, listing the index of the farthest target tip for each node in the tree. Hence, |
farthest_distance_per_tip |
Integer vector of size Ntips. Phylogenetic ("patristic") distance of each tip in the tree to its farthest target tip. If |
farthest_distance_per_node |
Integer vector of size Nnodes. Phylogenetic ("patristic") distance of each node in the tree to its farthest target tip. If |
Stilianos Louca
M. G. I. Langille, J. Zaneveld, J. G. Caporaso et al (2013). Predictive functional profiling of microbial communities using 16S rRNA marker gene sequences. Nature Biotechnology. 31:814-821.
find_nearest_tips
# generate a random tree
Ntips = 1000
parameters = list(birth_rate_intercept=1,death_rate_intercept=0.9)
tree = generate_random_tree(parameters,Ntips,coalescent=FALSE)$tree
# pick a random set of "target" tips
target_tips = sample.int(n=Ntips, size=5, replace=FALSE)
# find farthest target tip to each tip & node in the tree
results = find_farthest_tips(tree, target_tips=target_tips)
# plot histogram of distances to target tips (across all tips of the tree)
distances = results$farthest_distance_per_tip
hist(distances, breaks=10, xlab="farthest distance", ylab="number of tips", prob=FALSE);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.