Re: [R-sig-phylo] get branch lengths from distances to root

2016-11-30 Thread Cecile Ane
One way would be to label the root to make it a leaf, and apply NJ. Neighbor-joining reconstructs the original branch lengths (and topology) given tree-distances between the leaves. Cécile On Nov 30, 2016, at 10:30 AM, Juan Antonio Balbuena > wrote:

Re: [R-sig-phylo] get branch lengths from distances to root

2016-11-30 Thread Liam J. Revell
Hola Juan. If your heights (distances) above the root are a vector h in the order of the node indices of the tree (in tree$edge) it would be as easy as: tree$edge.length<-rep(NA,nrow(tree$edge)) for(i in 1:nrow(tree$edge)) tree$edge.length[i]<-h[tree$edge[i,2]]-h[tree$edge[i,1]] If