El 02/06/10 15:14, Joris Meys escribió:
> Hi,
>
> with a little hack you can use the function cophenetic.phylo from ape. 
> You just set all branch lengths to 1 :
>
> require(ape)
>
> >tree <- rtree(5,rooted=F)
> >n <- length(tree$edge.length)
> >tree$edge.length <- rep(1,n)
> >cophenetic.phylo(tree)
>
>    t3 t1 t2 t4 t5
> t3  0  3  3  3  3
> t1  3  0  2  4  4
> t2  3  2  0  4  4
> t4  3  4  4  0  2
> t5  3  4  4  2  0
>
> Cheers
>
>
> On Wed, Jun 2, 2010 at 2:47 PM, Arnau Mir Torres <arnau....@uib.es 
> <mailto:arnau....@uib.es>> wrote:
>
>     Hello.
>
>     I'd like to compute the associate vector of distances between
>     leaves in a binary non-rooted tree. The definition of a distance
>     between two leaves in a binary non-rooted tree is the number of
>     edges in the path joining the two leaves.
>     I've tried the ape package but I'm unable to find this vector.
>     For example, using rtree(5,rooted=F) I've obtained the following tree:
>
>     $edge
>         [,1] [,2]
>     [1,]    6    7
>     [2,]    7    1
>     [3,]    7    8
>     [4,]    8    2
>     [5,]    8    3
>     [6,]    6    4
>     [7,]    6    5
>
>     $tip.label
>     [1] "t4" "t3" "t2" "t1" "t5"
>
>     $edge.length
>     [1] 0.9126727 0.2765674 0.4996832 0.7904400 0.8508797 0.8174133
>     0.9027958
>
>     $Nnode
>     [1] 3
>
>
>     My question is: how to compute the vector of distances between the
>     5 leaves. This vector is in this case:
>     
> v=(d(t1,t2),d(t1,t3),d(t1,t4),d(t1,t5),d(t2,t3),d(t2,t4),d(t2,t5),d(t3,t4),d(t3,t5),d(t4,t5))=(4,4,3,2,2,3,4,3,4,3).
>
>
>     Thanks in advance,
>
>     Arnau.
>     ------------------------------------------------------------
>     Arnau Mir Torres
>     Edifici A. Turmeda
>     Campus UIB
>     Ctra. Valldemossa, km. 7,5
>     07122 Palma de Mca.
>     tel: (+34) 971172987
>     fax: (+34) 971173003
>     email: arnau....@uib.es <mailto:arnau....@uib.es>
>     URL: http://dmi.uib.es/~arnau <http://dmi.uib.es/%7Earnau>
>     ------------------------------------------------------------
>
>
>
>
>
>
>
>
>     ______________________________________________
>     R-help@r-project.org <mailto:R-help@r-project.org> mailing list
>     https://stat.ethz.ch/mailman/listinfo/r-help
>     PLEASE do read the posting guide
>     http://www.R-project.org/posting-guide.html
>     and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
> -- 
> Joris Meys
> Statistical Consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> Coupure Links 653
> B-9000 Gent
>
> tel : +32 9 264 59 87
> joris.m...@ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
Thank you very much. It has been very useful.

I'd like to go one step further.

Would it be possible to obtain a "distance matrix" but with no 
permutation of the leaves? In the above example, the "distance matrix" 
must be transformed into:

    t1 t2 t3 t4 t5
t1  0  2  3  4  4
t2  2  0  3  4  4
t3  3  3  0  3  3
t4  4  4  3  0  2
t5  4  4  3  2  0

Thanks,

Arnau.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to