StoreyLab / qvalue

R package to estimate q-values and false discovery rate quantities.
112 stars 36 forks source link

p-values not in valid range [0, 1] #7

Closed katwre closed 7 years ago

katwre commented 7 years ago

Hi, I get an error p-values not in valid range [0, 1] after calling the qvalue function. This error occurs using p-values from the fisher.test function and I am not able to fix it. Some p-values are only above 1 by an amount that was less than machine precision. Could you help with that?

Here is an example that reproduces the error:

> x=c(2 ,  1 ,641, 234)
> qvalue(c(fisher.test(matrix(as.numeric( x) ,ncol=2,byrow=F),conf.int = F)$p.value ,runif(1000))Error in qvalue(c(fisher.test(matrix(as.numeric(x), ncol = 2, byrow = F),  : 
  p-values not in valid range [0, 1].

Kasia

ajbass commented 7 years ago

Hi,

This is not a qvalue issue:

x <- c(2 ,  1 ,641, 234)
ft <- fisher.test(matrix(as.numeric( x) ,ncol=2,byrow=F),conf.int = F)$p.value
ft[1]>1 # problem
sprintf("%.20f",ft)
floor(ft[1])>1 # floor fixes problem

What you can try is to loop over the vector ft and if the numerical value is >1 then set it to 1. It would be dangerous to implement this in the package because the warning message is to make people aware of nonsensical p-values (>1). In this case, it seems to be a numerical issue with fisher.test.

Cheers