# 1) a newick tree without internal node labels
tree <- "(((t1:5,t2:5):2,(t3:4,t4:4):3):2,(t5:4,t6:4):6);"
phy <- ape::read.tree(text=tree)
phy
Ntip <- ape::Ntip(phy)
Nnode <- ape::Nnode(phy)
ape::plot.phylo(phy, type="p", use.edge.length=TRUE)
ape::nodelabels(node=Ntip+1:Nnode, col="red", bg="white")
# a subtree specified via a built-in internal node ID
subphy <- dcSubtreeClade(phy, choose.node=Ntip+2)
subphy
ape::plot.phylo(subphy, type="p", use.edge.length=TRUE)
# 2) a newick tree 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)
phy
ape::plot.phylo(phy, type="p", use.edge.length=TRUE,
show.node.label=TRUE)
# a subtree specified via an internal node label
subphy <- dcSubtreeClade(phy, choose.node.label='i2')
subphy
ape::plot.phylo(subphy, type="p", use.edge.length=TRUE,
show.node.label=TRUE)
Run the code above in your browser using DataLab