View source: R/find_farthest_tip_pair.R
find_farthest_tip_pair | R Documentation |
Given a phylogenetic tree, find the two most phylogenetically distant tips (to each other) in the tree.
find_farthest_tip_pair(tree, as_edge_counts = FALSE)
tree |
A rooted tree of class "phylo". While the tree must be rooted for technical reasons, the outcome does not actually depend on the rooting. |
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. |
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 named list with the following elements:
tip1 |
An integer between 1 and Ntips, specifying the first of the two most distant tips. |
tip2 |
An integer between 1 and Ntips, specifying the second of the two most distant tips. |
distance |
Numeric, specifying the phylogenetic (patristic) distance between the |
Stilianos Louca
find_nearest_tips
, find_farthest_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
# find farthest pair of tips
results = find_farthest_tip_pair(tree)
# print results
cat(sprintf("Tip %d and %d have distance %g\n",
results$tip1,results$tip2,results$distance))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.