# 1) with internal node labels
tree <- "(((t1:5,t2:5)i3:2,(t3:4,t4:4)i4:3)i2:2,(t5:4,t6:4)i5:6)i1;"
phy <- ape::read.tree(text=tree)
ape::plot.phylo(phy, type="p", use.edge.length=TRUE,
show.node.label=TRUE)
# 2) tip labels of interest
choose.tip.labels <- c('t1','t2','t3')
# 2a) extract subtree via an induced clade
subphy <- dcSubtreeTips(phy, choose.tip.labels, subtree.type="clade")
ape::plot.phylo(subphy, type="p", use.edge.length=TRUE,
show.node.label=TRUE)
# 2b) extract subtree containing only tips
subphy <- dcSubtreeTips(phy, choose.tip.labels,
subtree.type="tips_only")
ape::plot.phylo(subphy, type="p", use.edge.length=TRUE,
show.node.label=TRUE)
Run the code above in your browser using DataLab