[R-sig-phylo] issue with cophenetic.phylo()

2012-12-10 Thread Kelly Burkett
Thanks Klaus,

The problem was that I expected logically that two nodes would have the same 
distance. For example with ((A,B),C), I expect d(A,C)==d(B,C).

I'm sure for most people's purposes it isn't a problem that they aren't exactly 
equal, but if you apply functions involving the ranks of the values, then 
strange results can occur. This is how I came across this issue. If I use the 
rounded distance matrix it is fine, my functions work perfectly, but it did not 
occur to me to do this from the outset because I expected a matrix having 
particular properties.

Cheers,
Kelly



From: Klaus Schliep [klaus.schl...@gmail.com]
Sent: December 7, 2012 5:16 PM
To: Kelly Burkett
Cc: r-sig-phylo@r-project.org
Subject: Re: [R-sig-phylo] issue with cophenetic.phylo()

Hi Kelly,

where is the problem? This happens if you work with floating point numbers.
There is a nice link on the developer.r-project on the topic
www.validlab.com/goldberg/paper.pdf

The value is on my machine actually the same as
.Machine$double.eps
[1] 2.220446e-16
which is the smallest positive floating-point number ‘x’ such that ‘1 + x != 1’.

Regards,
Klaus


On 12/7/12, Kelly Burkett kelly.burk...@mail.mcgill.ca wrote:
 Hi Everyone,

 I have been using the cophenetic.phylo() function and I have been
 having some issues with pairs of tips having distances that are
 different than what I would expect.

 The following code illustrates the issue (I have set the seed in
 order to reproduce these results). I generate a tree with
 10 tips. There should be 9 unique non-zero distances in the matrix
 returned by cophenetic.phylo(). Instead there are 10 because
 1.22313194 is duplicated:

 set.seed(1723)
 tree=rcoal(10)
 x=cophenetic.phylo(tree)
 y=sort(unique(as.vector(x)))

 y:
 [1] 0. 0.04371057 0.16334724 0.22292128 0.31957449 0.33656861
 [7] 0.35227827 0.84410552 1.22313194 1.22313194 2.14497976

 As an example, t9 should have the same distance to t8 and t2.
 x[t9,]:
t1t3t6t9t7t2t8
 t5
 0.3522783 0.3365686 0.3365686 0.000 1.2231319 1.2231319 1.2231319
 2.1449798
   t10t4
 2.1449798 2.1449798

 But they are different:
 x[t9,t8]==x[t9,t2]
 [1] FALSE

 They are off by a very small amount:
 x[t9,t8]-x[t9,t2]
 [1] -2.220446e-16

 I am posting this in case it is of interest to others. As a quick fix,
 I am now rounding x.

 Thanks,
 Kelly

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



--
Klaus Schliep
Phylogenomics Lab at the University of Vigo, 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] issue with cophenetic.phylo()

2012-12-07 Thread Kelly Burkett
Hi Everyone,

I have been using the cophenetic.phylo() function and I have been
having some issues with pairs of tips having distances that are
different than what I would expect.

The following code illustrates the issue (I have set the seed in
order to reproduce these results). I generate a tree with
10 tips. There should be 9 unique non-zero distances in the matrix
returned by cophenetic.phylo(). Instead there are 10 because
1.22313194 is duplicated:

 set.seed(1723)
 tree=rcoal(10)
 x=cophenetic.phylo(tree)
 y=sort(unique(as.vector(x)))

y:
[1] 0. 0.04371057 0.16334724 0.22292128 0.31957449 0.33656861
[7] 0.35227827 0.84410552 1.22313194 1.22313194 2.14497976

As an example, t9 should have the same distance to t8 and t2.
x[t9,]:
   t1t3t6t9t7t2t8t5
0.3522783 0.3365686 0.3365686 0.000 1.2231319 1.2231319 1.2231319 2.1449798
  t10t4
2.1449798 2.1449798

But they are different:
 x[t9,t8]==x[t9,t2]
[1] FALSE

They are off by a very small amount:
 x[t9,t8]-x[t9,t2]
[1] -2.220446e-16

I am posting this in case it is of interest to others. As a quick fix,
I am now rounding x.

Thanks,
Kelly

[[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] issue with cophenetic.phylo()

2012-12-07 Thread Klaus Schliep
Hi Kelly,

where is the problem? This happens if you work with floating point numbers.
There is a nice link on the developer.r-project on the topic
www.validlab.com/goldberg/paper.pdf

The value is on my machine actually the same as
.Machine$double.eps
[1] 2.220446e-16
which is the smallest positive floating-point number ‘x’ such that ‘1 + x != 1’.

Regards,
Klaus


On 12/7/12, Kelly Burkett kelly.burk...@mail.mcgill.ca wrote:
 Hi Everyone,

 I have been using the cophenetic.phylo() function and I have been
 having some issues with pairs of tips having distances that are
 different than what I would expect.

 The following code illustrates the issue (I have set the seed in
 order to reproduce these results). I generate a tree with
 10 tips. There should be 9 unique non-zero distances in the matrix
 returned by cophenetic.phylo(). Instead there are 10 because
 1.22313194 is duplicated:

 set.seed(1723)
 tree=rcoal(10)
 x=cophenetic.phylo(tree)
 y=sort(unique(as.vector(x)))

 y:
 [1] 0. 0.04371057 0.16334724 0.22292128 0.31957449 0.33656861
 [7] 0.35227827 0.84410552 1.22313194 1.22313194 2.14497976

 As an example, t9 should have the same distance to t8 and t2.
 x[t9,]:
t1t3t6t9t7t2t8
 t5
 0.3522783 0.3365686 0.3365686 0.000 1.2231319 1.2231319 1.2231319
 2.1449798
   t10t4
 2.1449798 2.1449798

 But they are different:
 x[t9,t8]==x[t9,t2]
 [1] FALSE

 They are off by a very small amount:
 x[t9,t8]-x[t9,t2]
 [1] -2.220446e-16

 I am posting this in case it is of interest to others. As a quick fix,
 I am now rounding x.

 Thanks,
 Kelly

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



-- 
Klaus Schliep
Phylogenomics Lab at the University of Vigo, 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/