You can get the least squares branch lengths. I believe that if the distance matrix is a patristic distance matrix from your tree, then the least squares branch lengths are guaranteed to be the same as your original branches (and you should have a sum of squares error, Q, of zero - to numerical precision).

To test this, you can just use my optim.phylo.ls() function, and set the input tree to your target tree. You will need to have "phangorn" and "ape" to run this:

> source("http://anolis.oeb.harvard.edu/~liam/R-phylogenetics/optim.phylo.ls/v0.3/optim.phylo.ls.R";) # load the source
> LStree<-optim.phylo.ls(D,stree=tree)

Note that "LStree" will be unrooted even if "tree" is rooted.

To test this, try the following:

> tree<-rtree(5,rooted=F) # random unrooted tree
> tree$edge.length # show edge lengths
[1] 0.005683385 0.516492136 0.761613776 0.714302898 0.071461088 0.217680734 0.393926894
> D<-cophenetic(tree) # compute distance matrix
> tree$edge.length<-NULL # delete branch lengths
> test<-optim.phylo.ls(D,tree) # compute LS tree with true tree as input
best Q score of 4.19082355898663e-30 found after 0 nearest neighbor interchange(s).
> test$edge.length
           [,1]
6,7 0.005683385
7,1 0.516492136
7,8 0.761613776
8,2 0.714302898
8,3 0.071461088
6,4 0.217680734
6,5 0.393926894

You can easily see that they are the same branch lengths as in our original tree.

I hope this is helpful.

Sincerely, Liam

--
Liam J. Revell
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://phytools.blogspot.com

On 5/12/2011 5:18 PM, mgavil2 wrote:
All,
I have a tree topology (tree_name.tre), and a distance matrix, based
on that tree topology. However I cant not seem to find the nexus file
from which the matrix was generated.  Is there a way to use that
distance matrix to incorporate branch lengths into my topology?
I have looked into all the threads of questions posted in the list,
but still can not find an answer. my final objective is just to
generate a tree with branch lengths proportional to the distances on
the matrix (reviewers requirement for a publication).

Any suggestions would be greatly appreciated!

Thanks.

Maria Mercedes


_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to