find_mrca: Find ancestor

Description Usage Arguments Details Value Author(s) Examples

View source: R/find_mrca.R

Description

Finds the last common ancestor (node) of a set of two or more descendant tips.

Usage

1
find_mrca(descendant_names, tree)

Arguments

descendant_names

A vector of mode character representing the tip names for which an ancestor is sought.

tree

The tree as a phylo object.

Details

Intended for use as an internal function for trim_matrix, but potentially of more general use.

Value

ancestor_node

The ancestral node number.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Create a simple four-taxon tree:
tree <- ape::read.tree(text = "(A,(B,(C,D)));")

# Plot the tree:
ape::plot.phylo(tree)

# Add nodelabels and show that the most recent common
# ancestor of B, C, and D is node 6:
ape::nodelabels()

# Use find_mrca to show that the most recent common
# ancestor of B, C, and D is node 6:
find_mrca(
  descendant_names = c("B", "C", "D"),
  tree = tree
)

Claddis documentation built on Oct. 23, 2020, 8:04 p.m.