dcSubtreeClade
is supposed to extract a subtree under a given
clade from a phylo-formatted phylogenetic tree. In addition to the tree
in subject, another input is a built-in integer specifying an internal
node/clade of interest. Alternatively, the internal node of interest
can be given by its label (if there are internal node labels). As a
result, a subtree under a given clade is also represented as an object
of class 'phylo'.
dcSubtreeClade(phy, choose.node = NULL, choose.node.label = NULL, verbose = T)
Ntip+1
to Ntip+Nnode
, where Ntip
and Nnode
are the number of tips and internal nodes. Internal
nodes are indexed in a pre-ordered manner. The subtree under the given
interna node will be extractedan object of class 'phylo'
If a valid 'choose.node' is given, then 'choose.node.label' will be ignored.
# 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) phyPhylogenetic tree with 6 tips and 5 internal nodes. Tip labels: [1] "t1" "t2" "t3" "t4" "t5" "t6" Rooted; includes branch lengths.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)From the input tree (with 6 tips) and under the internal node '8', a subtree (with 4 tips) has been extracted.subphyPhylogenetic tree with 4 tips and 3 internal nodes. Tip labels: [1] "t1" "t2" "t3" "t4" Rooted; includes branch lengths.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) phyPhylogenetic tree with 6 tips and 5 internal nodes. Tip labels: [1] "t1" "t2" "t3" "t4" "t5" "t6" Node labels: [1] "i1" "i2" "i3" "i4" "i5" Rooted; includes branch lengths.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')From the input tree (with 6 tips) and under the internal node '8', a subtree (with 4 tips) has been extracted.subphyPhylogenetic tree with 4 tips and 3 internal nodes. Tip labels: [1] "t1" "t2" "t3" "t4" Node labels: [1] "i2" "i3" "i4" Rooted; includes branch lengths.ape::plot.phylo(subphy, type="p", use.edge.length=TRUE, show.node.label=TRUE)
dcSubtreeClade.r
dcSubtreeClade.Rd
dcSubtreeClade.pdf
dcTreeConnectivity