Dear Lev, I simple way to do what you request would be to follow this example with your data:
> library(ape) # here I'm creating a random tree with branch lengths > treeBL <- rtree(10) > treeBL$edge.length [1] 0.59962263 0.76458987 0.48171189 0.26387301 0.76967429 0.42754456 [7] 0.30173612 0.10535179 0.01769042 0.49671428 0.61575421 0.91297819 [13] 0.52992782 0.68690369 0.35537999 0.56974770 0.97019530 0.49849792 # this would be the tree with the same topology but without branch lengths > treeNN <- treeBL > treeNN$edge.length <- NULL > treeNN Phylogenetic tree with 10 tips and 9 internal nodes. Tip labels: t1, t9, t4, t3, t7, t10, ... Rooted; no branch lengths. # create node labels > treeNN$Nnode [1] 9 > treeNN$node.label <- paste("n",1:treeNN$Nnode,sep='') > treeNN$node.label [1] "n1" "n2" "n3" "n4" "n5" "n6" "n7" "n8" "n9" > treeNN Phylogenetic tree with 10 tips and 9 internal nodes. Tip labels: t1, t9, t4, t3, t7, t10, ... Node labels: n1, n2, n3, n4, n5, n6, ... Rooted; no branch lengths. # check if the internal structure of both trees is identical > identical(treeNN$edge,treeBL$edge) [1] TRUE > if (identical(treeNN$edge,treeBL$edge)){ + newtree <- treeBL + newtree$node.label <- treeNN$node.label } > newtree Phylogenetic tree with 10 tips and 9 internal nodes. Tip labels: t1, t9, t4, t3, t7, t10, ... Node labels: n1, n2, n3, n4, n5, n6, ... Rooted; includes branch lengths. Hope this helps. Cheers, Santiago -- Santiago Sánchez-Ramírez Environmental Genomics Group Max Planck Institute for Evolutionary Biology August-Thienemann-Str. 2 24306 Plön Germany Website: https://sites.google.com/site/santiagosnchezrmirez/ > > Message: 1 > Date: Wed, 13 Jan 2016 23:39:21 +0000 > From: "Yampolsky, Lev" <yampo...@mail.etsu.edu> > To: Emmanuel Paradis <emmanuel.para...@ird.fr>, "Liam J. Revell" > <liam.rev...@umb.edu>, Dan Rabosky <drabo...@umich.edu> > Cc: "r-sig-phylo@r-project.org" <r-sig-phylo@r-project.org> > Subject: Re: [R-sig-phylo] getBtimes vs. branching.times > Message-ID: <d2bc4988.7376e%yampo...@mail.etsu.edu> > Content-Type: text/plain; charset="utf-8" > > 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 > > > > > [[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/