Hi Sebastian,

the phangorn  package contains a function to construct design matrices
from a tree (class phylo from ape).

library(phangorn)
X = designTree(tree, method = "unrooted")
dm = as.matrix(dm)[tree$tip, tree$tip]
y = dm[lower.tri(dm)]
lm(y~X-1) # a normal Least Squares fit

There are several packages in R to solve quadratic programming
problems (non-negative LS in your case), e.g. function solve.QP in the
package quadprog should do the trick. So it should be straight forward
to solve your problem, once you figured out the parameters of
solve.QP.


Regards
Klaus

On 2/17/11, Sébastien Lavergne <sebastien.laver...@ujf-grenoble.fr> wrote:
> Dear all,
>
> I would like to optimise branch length of a known tree topology based on
> a distance matrix (non genetic data), and prohibiting negative branch
> lengths.
> Is there a way to do this in R ?
> Any help or hints external to R are also appreciated (I just know there
> is way through this in PAUP,, by constraining 'hsearch' function with a
> tree topology).
>
> Thanks in advance
> Seb
>
>
> --
>
> -------------------------------------------------------------------------
>  Sébastien Lavergne
>  Laboratoire d'Ecologie Alpine, UMR-CNRS 5553
>  Université Joseph Fourier
>  BP 53, 38041 Grenoble Cedex 9, France
>  tel +33 (0)4 76 63 54 50
>  http://www-leca.ujf-grenoble.fr/membres/lavergne.htm
>
> _______________________________________________
> R-sig-phylo mailing list
> R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>


-- 
Klaus Schliep
Université Paris 6 (Pierre et Marie Curie)
9, Quai Saint-Bernard, 75005 Paris

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

Reply via email to