Learn R Programming

Claddis (version 0.3.4)

FindAncestor: Find ancestor

Description

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

Usage

FindAncestor(descs, tree)

Arguments

descs

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

tree

The tree as a phylo object.

Value

anc.node

The ancestral node number.

Details

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

Examples

Run this code
# NOT RUN {
# Create a simple four-taxon tree:
tree <- read.tree(text = "(A,(B,(C,D)));")

# Plot the tree:
plot(tree)

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

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

# }

Run the code above in your browser using DataLab