I have a list of p-values and I would like to calculate the adjust p-values for multiple comparisons for the FDR. In R, I can use:
pval <- read.csv(\"my_f
Well, to get your code working, I would guess something like this would work:
import rpy2.robjects as R
pvalue_list = [2.26717873145e-10, 1.36209234286e-11 , 0.684342083821...] # my pvalues
p_adjust = R['p.adjust'](R.FloatVector(pvalue_list),method='BH')
for v in p_adjust:
print v
If p.adjust is simple enough, you could write it in Python so you avoid the need to call into R. And if you want to use it a lot, you can make a simple Python wrapper:
def adjust_pvalues(pvalues, method='BH'):
return R['p.adjust'](R.FloatVector(pvalues), method=method)