From: Joris Meys <jorismeys_at_gmail.com>

Date: Wed, 02 Jun 2010 15:14:27 +0200

Date: Wed, 02 Jun 2010 15:14:27 +0200

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.mir_at_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.mir_at_uib.es
**> URL: http://dmi.uib.es/~arnau <http://dmi.uib.es/%7Earnau>
**> ------------------------------------------------------------
**>
**>
**>
**>
**>
**>
**>
**>
**> ______________________________________________
**> R-help_at_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.Meys_at_Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] ______________________________________________ R-help_at_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.Received on Wed 02 Jun 2010 - 13:19:17 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Wed 02 Jun 2010 - 16:40:26 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*