Q-value for FDR correction in R stats package I used FDR correction (i.e., Benjamin-Hochberg tests) from the R 'Stats' package, but I'm confused of the q value used in the package. The notations in the 'p.adjust' function does not include the default setting for q values, which makes me feel a little less confident. For example, here is my original p-value list:
 p_raw <- c(8.133371e-04, 2.471103e-01, 3.343610e-03, 2.505031e-03, 2.887362e-06, 5.736712e-19, 8.955674e-03, 1.199260e-02, 7.698829e-04, 3.301545e-02, 1.126950e-03, 9.405598e-03)

Here is my R code for adjusting p-values:
p_adjust <- round(p.adjust(p_raw,method="BH"),3)

Here is the output for p_adjust:
0.002 0.247 0.006 0.005 0.000 0.000 0.013 0.014 0.002 0.036 0.003 0.013

I tried to calculate q values using the formula p_adjusted = (i/m)*q where i is the rank and m is the number of tests but did not get consistent q values for each p_adjust output. I wonder if anyone knows how the R 'Stats' package calculates this and what q value is the package using?
 A: P-values never use set significance levels as part of their computation.
In fact, the lack of reliance on any binary cutoff is part of the attraction of p-values.
In the case of p_adjust <- p.adjust(p, method="BH"), the elements with p_adjust < q for any value of $q$ are exactly the same elements that the original Benjamini-Hochberg (1995) method would choose as significant in order to control the FDR below $q$.
So the adjusted p-values and the original BH method are exactly equivalent.
Note that it is not sufficient to simply compute p_raw * m/i to get adjusted p-values, because those values are not generally monotonic in the original p-values.
It is necessary to apply an extra step to enforce monotonicity.
For a bit more background, see
https://support.bioconductor.org/p/49864/
and
What's the formula for the Benjamini-Hochberg adjusted p-value?
A: Thanks for COOLSerdash's prompt, I looked up the source code for p.adjust in stats package. Here is the part that's informative:
BH = {
    i <- lp:1L
    o <- order(p, decreasing = TRUE)
    ro <- order(o)
    pmin(1, cummin(n/i * p[o]))[ro]

Basically, stats uses a formula of m/i * raw_p to calculate the adjusted p instead of the traditional i/m * q. Therefore, there is no default q value in the R stats package FDR correction.
According to the R documentation of this p.adjust function, the original Benjamin-Hochberg (1995) paper was cited to support their method. The original paper used the p_raw <= i/m * q correction exactly as the procedure mentioned in this page. Therefore, just multiply the equation by m/i we get p_raw * m/i <= q. I assume the package uses p_raw * m/i to calculate adjusted p value and then it's upon us to decide what q value to use as criteria. I think it's commonly 0.05 or 0.1.
