Learn R Programming

TreeSearch (version 0.3.2)

Subtree: Extract subtree

Description

Safely extracts a clade from a phylogenetic tree.

Usage

Subtree(tree, node)

Arguments

tree

A tree of class phylo, with internal numbering in cladewise order (use Preorder(tree) or (slower) Cladewise(tree))

node

The number of the node at the base of the clade to be extracted.

Value

This function returns a tree of class phylo that represents a clade extracted from the original tree.

Details

Modified from the ape function extract.clade, which sometimes behaves erratically. Unlike extract.clade, this function supports the extraction of 'clades' that constitute a single tip.

Examples

Run this code
# NOT RUN {
{
tree <- Preorder(ape::rtree(20, br=NULL))
plot(tree); ape::nodelabels(); ape::nodelabels(33, 33, bg='yellow'); dev.new()
plot(Subtree(tree, 33))
}

# }

Run the code above in your browser using DataLab