YuLab-SMU / treeio

:seedling: Base Classes and Functions for Phylogenetic Tree Input and Output
https://yulab-smu.top/treedata-book/
94 stars 24 forks source link

Keep.tip #100

Closed xiangpin closed 1 year ago

xiangpin commented 1 year ago

Description

add keep.tip function for treedata

Related Issue

Example

> library(treeio)
> nhxfile <- system.file("extdata/NHX", "ADH.nhx", package="treeio")
> nhx <- read.nhx(nhxfile)
> toDrop <- c("ADH2", "ADH1")
> toKeep <- setdiff(nhx@phylo$tip.label, toDrop)
> tr1 <- drop.tip(nhx, toDrop)
> tr2 <- keep.tip(nhx, toKeep)
> identical(tr1, tr2)
[1] TRUE