bl_distance_ns: bl_distance_ns

View source: R/bl_distance_ns.r

bl_distance_nsR Documentation

bl_distance_ns

Description

Calculates branch-length distance between tipa and tipb in a phylogenetic tree using nested-set optomization. Requires a pre-calculated nested-set.

Usage

bl_distance_ns(tipa, tipb, tree, ns)

Arguments

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).

Value

Distance between tipa and tipb.

Author(s)

John L. Darcy

Examples

#  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
  


darcyj/specificity documentation built on Aug. 1, 2023, 8 a.m.