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:


Hi all

This is a simple question:

I have a set of ultrametric trees with information on their topology but 
without branch lengths. On a separate file, I have the distances of each node 
and leaf to the root. Can someone instruct me on how to to compute the branch 
lengths of the tree with these two separate bits of information?

Many thanks in advance

Juan A. Balbuena

--
Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
University of Valencia
http://www.uv.es/~balbuena
P.O. Box 22085
http://www.uv.es/cophylpaco
46071 Valencia, Spain
e-mail: j.a.balbu...@uv.estel. +34 963 543 658   
 fax +34 963 543 733

NOTE! For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.

___
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/


[[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/

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 it the nodes are labeled in a different fashion, then it would be 
slightly more complicated (for instance, involving the identifying MRCAs 
or matching nodes), but similar. How are your node & leaf heights organized?


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 11/30/2016 11:30 AM, Juan Antonio Balbuena wrote:

Hi all

This is a simple question:

I have a set of ultrametric trees with information on their topology but
without branch lengths. On a separate file, I have the distances of each
node and leaf to the root. Can someone instruct me on how to to compute
the branch lengths of the tree with these two separate bits of information?

Many thanks in advance

Juan A. Balbuena


--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
University of Valencia
http://www.uv.es/~balbuena 
P.O. Box 22085
http://www.uv.es/cophylpaco 
46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963
543 658fax +34 963 543 733

*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.




___
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/