StoreyLab / qvalue

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

Error in smooth.spline(lambda, pi0, df = smooth.df) #9

Closed ramiromagno closed 6 years ago

ramiromagno commented 6 years ago

I get this error:

Error in smooth.spline(lambda, pi0, df = smooth.df) : 
  missing or infinite values in inputs are not allowed

while running the qvalue function:

qvalue(sample(seq(0, 0.94, 0.01)))

but not with:

qvalue(sample(seq(0, 0.95, 0.01)))

This relates to pi0 estimation (in the fn pi0est) and how lambda is defined. If there is not a pvalue beyond the last value (default: 0.95) in the vector lambda, qvalue will give the error abovementioned.

Should not line 106 from pi0est.R:

pi0 <- cumsum(tabulate(findInterval(p, vec=lambda))[ind]) / (length(p) * (1-lambda[ind]))

read instead:

pi0 <- cumsum(tabulate(findInterval(p, vec = lambda), nbins = length(lambda))[ind])/(length(p) * (1 - lambda[ind]))

?

ajbass commented 6 years ago

See the discussion here: https://github.com/StoreyLab/qvalue/commit/f534759bdc462d672744a29230017c9a346021fa#commitcomment-26274105 ... We are discussing internally the best way to handle this. The package is not designed to handle truncated p-value distributions but can easily be extended. We hope to have a solution soon!

Cheers, Andrew

ramiromagno commented 6 years ago

Thanks for the quick reply!

I didn't realise you were already aware of this issue. Nice!

In the meantime you could maybe add a check for truncated p-value distributions... because having that error from smooth.spline surfacing is a bit unexpected... particularly when using other packages that have qvalue as dependency.

swvanderlaan commented 6 years ago

Is there any update on this issue? Also: how can I check the truncated p-value distributions, I mean practically/code-wise in a script and without drawing a picture?

Zepeng-Mu commented 5 years ago

What I am doing to circumvent this is to use qvalue(p, lambda = seq(0, max(p), 0.05)). But I am not sure whether it is OK to do so.

ajbass commented 5 years ago

If I recall, it seemed like nearly every test was statistically significant. In this case I would be conservative and simply force pi0 = 1: qvalue(p, pi0 = 1) ... This is also known as the BH procedure from the function p.adjust.