View source: R/bl_distance_ns.r
bl_distance_ns | R Documentation |
Calculates branch-length distance between tipa and tipb in a phylogenetic tree using nested-set optomization. Requires a pre-calculated nested-set.
bl_distance_ns(tipa, tipb, tree, ns)
tipa |
string. Name of a tip in tree. |
tipb |
string. Name of another tip in tree. |
tree |
phylo object. Tree containing all unique species in x as tips. May contain tips that are not in x. |
ns |
matrix. Nested-set matrix for tree; use make_nested_set(tree). |
Distance between tipa and tipb.
John L. Darcy
# library(specificity)
# library(ape)
# example_tree <- ape::read.tree(text=" ((((a:1,b:1):1,c:2):1,d:3):1,(e:1,f:1):3);")
# plot(example_tree); axis(side=1)
# example_ns <- make_nested_set(example_tree)
# bl_distance_ns("a", "c", example_tree, example_ns) # should be 4
# bl_distance_ns("a", "f", example_tree, example_ns) # should be 8
# bl_distance_ns("d", "c", example_tree, example_ns) # should be 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.