Calculating adjusted p-values in Python

It is available in statsmodels.

http://statsmodels.sourceforge.net/devel/stats.html#multiple-tests-and-multiple-comparison-procedures

http://statsmodels.sourceforge.net/devel/generated/statsmodels.sandbox.stats.multicomp.multipletests.html

and some explanations, examples and Monte Carlo http://jpktd.blogspot.com/2013/04/multiple-testing-p-value-corrections-in.html


According to the biostathandbook, the BH is easy to compute.

def fdr(p_vals):

    from scipy.stats import rankdata
    ranked_p_values = rankdata(p_vals)
    fdr = p_vals * len(p_vals) / ranked_p_values
    fdr[fdr > 1] = 1

    return fdr