PCMBase (version 1.2.14)

PCMTreeSplitAtNode: Slit a tree at a given internal node into a clade rooted at this node and the remaining tree after dropping this clade

Description

Slit a tree at a given internal node into a clade rooted at this node and the remaining tree after dropping this clade

Usage

PCMTreeSplitAtNode(
  tree,
  node,
  tableAncestors = PCMTreeTableAncestors(tree),
  X = NULL
)

Value

A list containing two named phylo objects:

clade

The subtree (clade) starting at node.

Xclade

The portion of X attributable to the tips in clade; NULL if X is NULL.

rest

The tree resulting after dropping all tips in the clade.

Xrest

The portion of X attributable to the tips in rest; NULL if X is NULL.

Arguments

tree

a PCMTree object.

node

an integer or character indicating a root, internal or tip node

tableAncestors

an integer matrix returned by a previous call to PCMTreeTableAncestors(tree) or NULL.

X

an optional k x N matrix with trait value vectors for each tip in tree.

Details

In the current implementation, the edge.jump and edge.part members of the tree will be discarded and not present in the clade.

Examples

Run this code
set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion")
tree <- PCMTree(ape::rtree(25))

if(requireNamespace("ggtree"))
PCMTreePlot(tree) + ggtree::geom_nodelab(angle = 45) +
  ggtree::geom_tiplab(angle = 45)

spl <- PCMTreeSplitAtNode(tree, 28)

if(requireNamespace("ggtree"))
PCMTreePlot(PCMTree(spl$clade)) + ggtree::geom_nodelab(angle = 45) +
  ggtree::geom_tiplab(angle = 45)

if(requireNamespace("ggtree"))
PCMTreePlot(PCMTree(spl$rest)) + ggtree::geom_nodelab(angle = 45) +
  ggtree::geom_tiplab(angle = 45)

Run the code above in your browser using DataLab