Learn R Programming

apTreeshape (version 1.2.1)

tipsubtree: Extract a subtree that contains pre-specified tip names or labels

Description

tipsubtree returns an object of class "treeshape" that contains pre-specified tip names or labels. The name of the tips are conserved. It extracts the smallest tree that contains the common ancestors of the given tips.

Usage

tipsubtree(tree, tips, numeric=FALSE)

Arguments

tree
An object of class "treeshape".
tips
A vector that contains the names of the tips one want to keep. Warning, the names are case-sensitive.
numeric
An object of class "logical". If FALSE, the vector tips contains the names of the tips. If TRUE, it contains the labels of the tips.

Value

  • An object of class "treeshape"

See Also

cutreeshape

Examples

Run this code
## The universal tree of life provided in the data sets.
data(universal.treeshape)
  
## One might want to extract the tree containing the Animals, the Plants,
##      the Aquifex and the Microsporidia
tree1<-tipsubtree(universal.treeshape,tips=c("Animals", "Aquifex", 
      "Microsporidia", "Plants"))
plot(universal.treeshape, tree1)

## Labels that do not appear in the tree are ignored
tree2<-tipsubtree(universal.treeshape,tips=c("Human", "Animals", "Aquifex", 
      "Microsporidia", "Plants"))
plot(universal.treeshape, tree2)
  
tree3<-tipsubtree(universal.treeshape,tips=c(1,3,7), numeric=TRUE)
plot(universal.treeshape, tree3)

Run the code above in your browser using DataLab