-2

I ran a correlation analysis between two vectors and I need to plot the -log10(pvalue)...when the correlation runs, I have the following results:

data <- read.table("test-data.txt")
a <- data[,1]
b <- data[,2]
test <- cor.test(a, b)
test

    Pearson's product-moment correlation

data:  a and b
t = 8.3704, df = 10352, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.06282908 0.10109436
sample estimates:
       cor 
0.08199194 

but when I extract the p-value as test$p.value it comes out as zero..this means that when I calculate the -log10(pv) i get Inf as results...which I cannot plot.

however, -log(2.2e-16, base=10) is 15.65758 which is what I want

so my question is: how would you maintain the exponential number?

also, this is a sample of a series of 81 correlations I'm running that have to be plotted all together, I have this very same problem for 30 out of 81

rawr
  • 20,481
  • 4
  • 44
  • 78
TriRook
  • 147
  • 1
  • 3
  • 18
  • 3
    Yes, but your p-value is less than 2.2e-16. – mgriebe Aug 18 '14 at 16:38
  • yes it is, but looking here (http://stackoverflow.com/questions/6970705/why-cant-i-get-a-p-value-smaller-than-2-2e-16) you can get something smaller, and if I could get it with cor.test it would be (graphically) better. – TriRook Aug 18 '14 at 18:46

1 Answers1

1

Your p-value is not 2.2e-16, its less than that. That means its computationally zero. You can skip the zeros, or set zero to the arbitrarily small 2.2e-16.

ifelse(pv==0,-log(2.2e-16,base=10),-log(pv,base=10))

Of course, 30 out of 81 times you do not know what the p-value is, just that it is very small.

mgriebe
  • 908
  • 5
  • 8