View source: R/get_all_distances_to_tip.R
get_all_distances_to_tip | R Documentation |
Given a tree and a focal tip, calculate the phylogenetic ("patristic") distances between the focal tip and all other tips & nodes in the tree.
get_all_distances_to_tip(tree, focal_tip)
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. |
The "patristic distance" between two tips and/or nodes is the shortest cumulative branch length that must be traversed along the tree in order to reach one tip/node from the other. If tree$edge.length
is missing, then each edge is assumed to be of length 1.
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 the result.
A numeric vector of length Ntips+Nnodes, specifying the distances of all tips (entries 1,..,Ntips) and all nodes (entries Ntips+1,..,Ntips+Nnodes) to the focal tip.
Stilianos Louca
get_all_pairwise_distances
,
get_pairwise_distances
# generate a random tree
Ntips = 100
tree = generate_random_tree(list(birth_rate_intercept=1),
max_tips = Ntips,
tip_basename="tip.")$tree
# calculate all distances to a focal tip
distances = get_all_distances_to_tip(tree, "tip.39")
print(distances)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.