This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Benjamin Hochberg adjust P-values

I have some raw p-values and I would like to do Benjamini Hochberg and Bonferoni correction? Does anyone know how to do it - step by step? I have my p-values as txt files. And how can I check it, whether it is right or not.

Thanks Martin

r

Sorry

pBenjaminiHochberg = min(0,00002 * 5 / 1) = 0,0001 pBenjaminiHochberg = min(0,00034 * 5 / 2) = 0,00085 pBenjaminiHochberg = min(0,0024 * 5 / 3) = 0,004 pBenjaminiHochberg = min(0,0235 * 5 / 4) = 0,029375 pBenjaminiHochberg = min(0,12424 * 5 / 5) = 0,12424

It looks correct. I did the test in R and I have the same results :

p.adjust(c( 0.00002, 0.00034,0.0024, 0.0235, 0.12424),method="fdr")
[1] 0.000100 0.000850 0.004000 0.029375 0.124240

@ lampardmartin3 : Please use ADD COMMENT/ADD REPLY when responding to existing posts to keep threads logically organized. SUBMIT ANSWER should be used for NEW answers to original question.

4 answers

I would like to add a cautionary note about the above answer here, regarding the nonmonotonocity of q-values (corrected p-values) that would result from the formula.

The source code for the p.adjust function in R is here:

BH = {
    i <- lp:1L
    o <- order(p, decreasing = TRUE)
    ro <- order(o)
    pmin(1, cummin(n/i * p[o]))[ro]}
  

Which fixes this issue in the last line.

You can use a function in R,p.adjust.

thank you

I not trained in using R (at least not now)

pBenjaminiHochberg = min( p * n / r , 1)

where p is the original p-value, n is the number of computed p-values in total and r is the rank of the original p-value when p-values are sorted in ascending order.

It should be possible to do the manipulations manually in Excel, but if you can use R, there is the p.adj function that is more straightforward.

Dear Carlo,

Thank you very much.

Is this right: p-values in ascending order: 1) 0,00002 2) 0,00034 3)0,0024 4)0,0235 5) 0,12424

pBenjaminiHochberg = min(0,00002 * 5 / 1) = 0,0001 pBenjaminiHochberg = min(0,00034 * 5 / 2) = 0,00085 pBenjaminiHochberg = min(0,0024 * 5 / 3) = 0,004 pBenjaminiHochberg = min(0,0235 * 5 / 4) = 0,029375 pBenjaminiHochberg = min(0,12424 * 5 / 4) = 0,12424

Best,

Martin

Log in to answer this question.