1 package baseCode.math;
2
3 import cern.colt.list.DoubleArrayList;
4
5 /***
6 * Methods for p-value correction of sets of hypothesis tests.
7 * <p>
8 * Copyright (c) 2004
9 * </p>
10 * <p>
11 * Institution:: Columbia University
12 * </p>
13 *
14 * @author Paul Pavlidis
15 * @version $Id: MultipleTestCorrection.java,v 1.6 2004/07/27 03:18:57 pavlidis Exp $
16 */
17 public class MultipleTestCorrection {
18
19 /***
20 * Determine the Bonferroni pvalue threshold to maintain the family wise error rate (assuming pvalues are
21 * independent).
22 *
23 * @param pvalues The pvalues
24 * @param fwe The family wise error rate
25 * @return The minimum pvalue that maintains the FWE
26 */
27 public static double BonferroniCut( DoubleArrayList pvalues, double fwe ) {
28 int numpvals = pvalues.size();
29 return fwe / numpvals;
30 }
31
32 /***
33 * Benjamini-Hochberg method. Determines the maximum p value to maintain the false discovery rate. (Assuming pvalues
34 * are independent);
35 *
36 * @param pvalues list of pvalues. Need not be sorted.
37 * @param fdr false discovery rate
38 * @return The maximum pvalue that maintains the false discovery rate
39 */
40 public static double BenjaminiHochbergCut( DoubleArrayList pvalues,
41 double fdr ) {
42 int numpvals = pvalues.size();
43 DoubleArrayList pvalcop = pvalues.copy();
44 pvalcop.sort();
45 pvalcop.reverse();
46
47 int n = pvalcop.size();
48 double thresh = fdr * n / numpvals;
49
50 for ( int i = 0; i < n; i++ ) {
51 double p = pvalcop.get( i );
52
53 if ( p < thresh ) {
54 return p;
55 }
56 }
57 return 0.0;
58 }
59
60 }