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?

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?
