我有成千上万个要修剪的系统发育树:
我在R中编写了以下代码:
tree <- read.tree(file='MyTree.tre')
tips <- tree$tip.label
nodes<-sapply(tips,function(x,y) which(y==x),y=tree$tip.label)
edge.lengths<-setNames(tree$edge.length[sapply(nodes,function(x,y) which(y==x),y=tree$edge[,2])],names(nodes))
e <- data.frame(edge.lengths)
E <- as.data.frame(add_rownames(e, var = 'taxa'))
ByeBye <- E[E$edge.lengths<0.0001,1]
tr.p <- drop.tip(tree, ByeBye)
这是我的输入树:
(SP1:0.00000001,SP2:0.00000001,(SP3:0.00000065,((SP4:0.02355024,(SP5:0.07343248,SP6:0.07280366)22:0.00000033)50:0.02354874,(SP7:0.00000059,(SP8:0.07323173,((SP9:0.04761974,SP10:0.00000072)59:0.04865423,((SP11:0.02604142,SP12:0.19513180)53:0.02235647,(SP13:0.00000033,SP14:0.00000001)25:0.00000001)54:0.02452009)31:0.02362920)8:0.00000078)43:0.04811732)12:0.00000033)93:0.07279201);