find_mrca {Claddis}R Documentation

Find ancestor

Description

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

Usage

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


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

[Package Claddis version 0.6.3 Index]