get_all_distances_to_tip {castor} | R Documentation |
Get distances of all tips/nodes to a focal tip.
Description
Given a tree and a focal tip, calculate the phylogenetic ("patristic") distances between the focal tip and all other tips & nodes in the tree.
Usage
get_all_distances_to_tip(tree, focal_tip)
Arguments
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. |
Details
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.
Value
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.
Author(s)
Stilianos Louca
See Also
get_all_pairwise_distances
,
get_pairwise_distances
Examples
# 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)