Dear all, I ran into a similar problem mentioned in the below post:
http://blog.phytools.org/2011/04/problem-with-bindtree.html I want to prune a clade and attach the internal branch with another tree of same branch length. I am using drop.clade and bind.tree function from ape package. The code works good when I remove clade containing only two descendants (please run the following code to check if this is correct). >set.seed(3) >tree<-rlineage(0.025, 0) >plot(tree) >nodelabels() >edgelabels(signif(tree$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) >a<-drop.clade(tree,c("t5","t4")) >plot(a) >edgelabels(signif(a$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) >pruned.tree<-drop.tip(tree,tree$tip.label[-match(c("t5","t4"),tree$tip.label)]) >edgelabels(signif(pruned.tree$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) >f<-bind.tree(a,pruned.tree,where=which(a$tip.label=='NA'),position=0) >plot(f) >edgelabels(signif(f$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) >is.ultrametric(f) # to check if branch length changes *To remove clade with three descendants (please run the below code)* >set.seed(3) >tree2<-rlineage(0.025, 0) >plot(tree2) >nodelabels() >edgelabels(signif(tree2$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) >a<-drop.clade(tree2,c("t6","t5","t4")) >plot(a) >nodelabels() >edgelabels(signif(a$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8)#note the change in the branch length >pruned.tree<-drop.tip(tree2,tree2$tip.label[-match(c("t6","t5","t4"),tree2$tip.label)]) >edgelabels(signif(pruned.tree$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) >f<-bind.tree(a,pruned.tree,where=which(a$tip.label=='NA'),position=0) >plot(f) >edgelabels(signif(f$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) >is.ultrametric(f) # to check branch length changes; note for descendants >2 this becomes false I also looked into the drop.tip function used in the *drop.clade* function with trim.internal = FALSE The branch length of the internal branch after pruning is changing. (Kindly run the below code to check difference in branch length after dropping the node with descendants >2 using drop.tip with trim.internal=FALSE) >set.seed(3) >tree3<-rlineage(0.025, 0) >m<-drop.tip(tree3,c("t5","t4","t6"), trim.internal = FALSE) >par(mfrow=c(1,2)) >plot(tree3) >nodelabels() >edgelabels(signif(tree2$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) >plot(m) >nodelabels() >edgelabels(signif(m$edge.length,digits=2),frame="none",adj=c(0.5,-0.2),cex=0.8) Is there any other function/way I can do the same manipulations? Or is there a problem with the code? Basically, I want to remove a clade and attach the internal branch with a new tree of same branch length (of the removed tree) but of different topology so the tree should remain ultrametric. Thanks in advance, Gopal Murali [[alternative HTML version deleted]] _______________________________________________ R-sig-phylo mailing list - [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/[email protected]/
