当我有一棵树和一些节点信息存储在表中时,我想删除提示,并相应地修改表。因此,需要一个在列节点中具有正确新编号的新表。
library(ape)
library(ggtree)
#make tree
set.seed(2016-12-31)
newrtree<-rtree(12)
newrtreepo<-di2multi(newrtree, tol = 0.5)
# make table with data to plot in tree
a<-1:newrtreepo$Nnode # node label
b<-seq(0,1, length.out=newrtreepo$Nnode)
c<-1-b
dat <- data.frame(a=a, b=b,c=c)
splen<-length(newrtreepo$tip.label)
dat$node <- splen+1:newrtreepo$Nnode
dat
# a b c node
# 1 1 0.0000000 1.0000000 13
# 2 2 0.1428571 0.8571429 14
# 3 3 0.2857143 0.7142857 15
# 4 4 0.4285714 0.5714286 16
# 5 5 0.5714286 0.4285714 17
# 6 6 0.7142857 0.2857143 18
# 7 7 0.8571429 0.1428571 19
# 8 8 1.0000000 0.0000000 20
tree5<-ggtree(newrtreepo)+geom_tiplab()+
geom_text2(aes(subset=!isTip, label=node), hjust=-1, check_overlap = T)+
geom_text2(aes(subset=!isTip,x=branch, label=label, size=2), vjust=-.5, hjust=0.5)
piesa <- nodepie(dat, cols=2:3)
inset(tree5, piesa)
droptree2<-drop.tip(newrtreepo,c("t12","t3","t5"))