I have a data.frame with an id field and three different and unrelated p-values. I would like to apply the benjamini-hochberg corection at each column.
I’ve been working with the p.adjust as function p.adjust(data[,2], "BH"), but I’m having trouble since I have to sort each column before applying the correction and I lose the id information after that. My data looks like:
id p1 p2 p3
1 ENSG00000179094 1.000000e+00 1.000000e+00 1.000000e+00
2 ENSG00000164306 1.000000e+00 1.000000e+00 1.000000e+00
3 ENSG00000147180 1.000000e+00 8.778847e-02 1.000000e+00
4 ENSG00000172932 4.370119e-01 1.766703e-04 1.000000e+00
5 ENSG00000137252 1.000000e+00 2.562124e-02 1.000000e+00
6 ENSG00000144644 1.654108e-02 1.000000e+00 1.000000e+00
7 ENSG00000197273 3.316301e-01 5.341301e-01 1.000000e+00
8 ENSG00000169221 1.000000e+00 1.000000e+00 1.000000e+00
9 ENSG00000108309 8.689368e-01 2.350522e-03 1.000000e+00
10 ENSG00000172382 1.000000e+00 9.028471e-01 2.697276e-02
11 ENSG00000099937 1.000000e+00 1.000000e+00 9.988716e-01
12 ENSG00000259431 1.000000e+00 1.000000e+00 7.268023e-01
...
Is there an easiest way or package to do this without losing the information from the id’s?
You can use numcolwise , apply a function to only numeric columns of a data.frame.
To use other arguments: