Lev, This is easy, if the newick strings are structured the same so that the resulting edge matrix and tip labels are identical. Here's a worked example:
``` library(ape) # with edge lengths newick1<-"(Homo:30,(Echinus:18,(Cephalodiscus:12,(Rhabdopleura:8,(Dictyonema:1,(Rhabdinopora:1,Dicellograptus:3):1):1):4):4):10);" # with node names newick2<-"(Homo,(Echinus,(Cephalodiscus,(Rhabdopleura,(Dictyonema,(Rhabdinopora,Dicellograptus)Graptoloida)Eugraptolithina)Graptolithina)Pterobranchia)Ambulacraria)Deuterostomia;" # convert newick strings to phylo objects tree1<-read.tree(text=newick1) plot(tree1) tree2<-read.tree(text=newick2) plot(tree2) nodelabels(tree2$node.label) # combine if(identical(tree1$edge,tree2$edge) & identical(tree1$tip.label,tree2$tip.label)){ tree3<-tree1 tree3$node.label<-tree2$node.label } plot(tree3) nodelabels(tree3$node.label) ``` If $edge and $tip.label are not identical, then this is a somewhat more complex issue. Cheers, -Dave On Wed, Jan 13, 2016 at 4:39 PM, Yampolsky, Lev <yampo...@mail.etsu.edu> wrote: > Dear Colleagues, > > Thank you very much for your help, it’s all clear now. (I got way more > than I asked for, for example, my trees include only extant taxa). And > yes, branching.times() and getBtimes() return exact same numbers of > course, I just didn’t understand ow indexing works. > > Next question, a very simple one again. > > I have two newick trees, identical topology. In one I have branch lengths, > in the other I have node names. I would like a tree with both. How do I do > this? > > Thanks in advance! > > -- > Lev Yampolsky > > Professor > Department of Biological Sciences > East Tennessee State University > Box 70703 > Johnson City TN 37614-1710 > Cell 423-676-7489 > Office/lab 423-439-4359 > Fax 423-439-5958 > > > > > On 1/13/16, 4:20 AM, "Emmanuel Paradis" <emmanuel.para...@ird.fr> wrote: > >>To pile a little bit more after David's message, ape has the function >>ltt.plot.coords which does the same thing than phytools::ltt but with >>different options, including 'tol' which specifies the tolerance for >>considering a tree as ultrametric or not. >> >>Best, >> >>Emmanuel >> >>Le 13/01/2016 03:29, Liam J. Revell a écrit : >>> Hi Lev. >>> >>> You could also look at ltt in phytools. The object returned has the time >>> of all the events on the tree - including the end of lineages that go >>> extinct before the present. To access these, you can do: >>> >>> obj<-ltt(tree,plot=FALSE) >>> obj$times >>> obj$ltt >>> >>> & to see how these are associated with events, you can do: >>> >>> plot(obj,show.tree=TRUE) >>> >>> All the best, Liam >>> >>> Liam J. Revell, Associate Professor of Biology >>> University of Massachusetts Boston >>> web: http://faculty.umb.edu/liam.revell/ >>> email: liam.rev...@umb.edu >>> blog: http://blog.phytools.org >>> >>> On 1/12/2016 10:22 PM, Dan Rabosky wrote: >>>> >>>> Dear Lev- >>>> >>>> I don't think branching.times can compute these for non-ultrametric >>>> trees. >>>> >>>> You can do this with package BAMMtools, but you need a "hidden" >>>> internal function. You can access it as >>>> >>>> "BAMMtools:::NU.branching.times" >>>> >>>> It returns branching times relative to the most recently-occurring tip >>>> in the tree. It's a R-based recursion that is a little slower that the >>>> ape function, so it's not recommended as a replacement for >>>> branching.times if you have an ultrametric tree. >>>> >>>> I'm not actively maintaining laser, but getBtimes returns the output >>>> of branching.times after sorting the times and stripping out the node >>>> names (this was useful for something many years ago!). If you plot >>>> sort(getBtimes(x)) and sort(branching.times(x)) they should be >>>>identical. >>>> >>>> ~Dan Rabosky >>>> >>>> >>>> >>>> On Jan 12, 2016, at 7:37 PM, Yampolsky, Lev <yampo...@mail.etsu.edu> >>>> wrote: >>>> >>>>> Dear Colleagues, >>>>> >>>>> Does anyone know what is the difference between ape�s >>>>> branching.times() and laser�s getBtimes()? >>>>> And why they may be giving rather different results, particularly for >>>>> internal branches? (From an ultrametric tree created by >>>>> chronotree <- chronos(tree, lambda = 1, model = "correlated", quiet = >>>>> FALSE, calibration = makeChronosCalib(tree), control = >>>>> chronos.control()) >>>>> >>>>> Thank you very much in advance for your help! >>>>> >>>>> PS. A related but less important question: I am curious how does >>>>> branching.times() calculate branching times from a non-ultrametric >>>>>tree? >>>>> >>>>> -- >>>>> Lev Yampolsky >>>>> >>>>> Professor >>>>> Department of Biological Sciences >>>>> East Tennessee State University >>>>> Box 70703 >>>>> Johnson City TN 37614-1710 >>>>> Cell 423-676-7489 >>>>> Office/lab 423-439-4359 >>>>> Fax 423-439-5958 >>>>> >>>>> _______________________________________________ >>>>> R-sig-phylo mailing list - R-sig-phylo@r-project.org >>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo >>>>> Searchable archive at >>>>> http://www.mail-archive.com/r-sig-phylo@r-project.org/ >>>> >>>> _____________________ >>>> Dan Rabosky >>>> Assistant Professor & Curator of Herpetology >>>> Museum of Zoology & >>>> Department of Ecology and Evolutionary Biology >>>> University of Michigan >>>> Ann Arbor, MI 48109-1079 USA >>>> >>>> drabo...@umich.edu >>>> http://www-personal.umich.edu/~drabosky >>>> http://www.lsa.umich.edu/ummz/ >>>> >>>> >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> >>>> >>>> _______________________________________________ >>>> R-sig-phylo mailing list - R-sig-phylo@r-project.org >>>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo >>>> Searchable archive at >>>> http://www.mail-archive.com/r-sig-phylo@r-project.org/ >>>> >>> >>> _______________________________________________ >>> R-sig-phylo mailing list - R-sig-phylo@r-project.org >>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo >>> Searchable archive at >>>http://www.mail-archive.com/r-sig-phylo@r-project.org/ >> > > _______________________________________________ > R-sig-phylo mailing list - R-sig-phylo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-phylo > Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/ -- David W. Bapst, PhD Adjunct Asst. Professor, Geology and Geol. Eng. South Dakota School of Mines and Technology 501 E. St. Joseph Rapid City, SD 57701 http://webpages.sdsmt.edu/~dbapst/ http://cran.r-project.org/web/packages/paleotree/index.html _______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/