Package org.snpeff.probablility
Class FisherExactTest
- java.lang.Object
-
- org.snpeff.probablility.FisherExactTest
-
public class FisherExactTest extends java.lang.Object
Calculate Fisher's exact test (based on hypergeometric distribution)- Author:
- pcingola
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canUseChiSquareApproximation(int k, int N, int D, int n)
Can ChiSquare approximation be used? A rule of the thumb says it can be used if every expected frequency is more than 10double
chiSquareApproximation(int k, int N, int D, int n)
Chi-Square approximation for Fisher's exact testdouble
chiSquareCDF(double chiSquare, int nu)
Chi-Square Cumulative Distribution Function probability that an observed chi-square value for a correct model should be less than chiSquare nu = the degrees of freedomdouble
chiSquareCDFComplementary(double chiSquare, int nu)
Chi-Square Complementary of Cumulative Distribution Function: 1 - chiSquareCDF(x, nu) probability that an observed chi-square value for a correct model should be greater than chiSquare nu = the degrees of freedomdouble
fisherExactTestDown(int k, int N, int D, int n)
Fisher's exact test for 'k' or less (lower tail)double
fisherExactTestDown(int k, int N, int D, int n, double threshold)
Fisher's exact test for less than 'k' (lower tail) It also compares to a 'threshold' value to speedup the process.double
fisherExactTestUp(int k, int N, int D, int n)
Fisher's exact test for 'k' or more (upper tail)double
fisherExactTestUp(int k, int N, int D, int n, double threshold)
Fisher's exact test for 'k' or more It also compares to a 'threshold' value to speedup the process.static FisherExactTest
get()
double
mean(int k, int N, int D, int n)
Calculate the mean References: http://en.wikipedia.org/wiki/Hypergeometric_distributiondouble
pValueDown(int k, int N, int D, int n)
double
pValueDown(int k, int N, int D, int n, double threshold)
Pvalue for 'k' or less Note: Includes 'k' It also compares to a 'threshold' value to speedup the process.double
pValueUp(int k, int N, int D, int n)
double
pValueUp(int k, int N, int D, int n, double threshold)
Fisher's exact test for more than 'k' It also compares to a 'threshold' value to speedup the process.java.lang.String
toR(int k, int N, int D, int n, boolean lowerTail)
Convert values to Fisher's 'R' commanddouble
variance(int k, int N, int D, int n)
Calculate the variance References: http://en.wikipedia.org/wiki/Hypergeometric_distribution
-
-
-
Method Detail
-
get
public static FisherExactTest get()
-
canUseChiSquareApproximation
public boolean canUseChiSquareApproximation(int k, int N, int D, int n)
Can ChiSquare approximation be used? A rule of the thumb says it can be used if every expected frequency is more than 10- Parameters:
k
- : white marbles drawnN
- : Total marblesD
- : White marbles => N-D : Black marblesn
- : marbles drawn => N-n : not drawn- Returns:
- Chi-Square approximation
-
chiSquareApproximation
public double chiSquareApproximation(int k, int N, int D, int n)
Chi-Square approximation for Fisher's exact test- Parameters:
k
- : white marbles drawnN
- : Total marblesD
- : White marbles => N-D : Black marblesn
- : marbles drawn => N-n : not drawn- Returns:
- Chi-Square approximation
-
chiSquareCDF
public double chiSquareCDF(double chiSquare, int nu)
Chi-Square Cumulative Distribution Function probability that an observed chi-square value for a correct model should be less than chiSquare nu = the degrees of freedom- Parameters:
chiSquare
-nu
-- Returns:
-
chiSquareCDFComplementary
public double chiSquareCDFComplementary(double chiSquare, int nu)
Chi-Square Complementary of Cumulative Distribution Function: 1 - chiSquareCDF(x, nu) probability that an observed chi-square value for a correct model should be greater than chiSquare nu = the degrees of freedom- Parameters:
chiSquare
-nu
-- Returns:
-
fisherExactTestDown
public double fisherExactTestDown(int k, int N, int D, int n)
Fisher's exact test for 'k' or less (lower tail)- Parameters:
k
- : white marbles drawnN
- : Total marblesD
- : White marbles => N-D : Black marblesn
- : marbles drawn => N-n : not drawn- Returns:
-
fisherExactTestDown
public double fisherExactTestDown(int k, int N, int D, int n, double threshold)
Fisher's exact test for less than 'k' (lower tail) It also compares to a 'threshold' value to speedup the process. Whenever cumulative probability is over the threshold, 1.0 is returned- Parameters:
k
- : white marbles drawnN
- : Total marblesD
- : White marbles => N-D : Black marblesn
- : marbles drawn => N-n : not drawntheshold
- Threshold value- Returns:
- Cumulative probability or 1.0 (if cumulative is over the threshold)
-
fisherExactTestUp
public double fisherExactTestUp(int k, int N, int D, int n)
Fisher's exact test for 'k' or more (upper tail)- Parameters:
k
- : white marbles drawnN
- : Total marblesD
- : White marbles => N-D : Black marblesn
- : marbles drawn => N-n : not drawn- Returns:
-
fisherExactTestUp
public double fisherExactTestUp(int k, int N, int D, int n, double threshold)
Fisher's exact test for 'k' or more It also compares to a 'threshold' value to speedup the process. Whenever cumulative probability is over the threshold, 1.0 is returned- Parameters:
k
- : white marbles drawnN
- : Total marblesD
- : White marbles => N-D : Black marblesn
- : marbles drawn => N-n : not drawntheshold
- Threshold value- Returns:
- Cumulative probability or 1.0 (if cumulative is over the threshold)
-
mean
public double mean(int k, int N, int D, int n)
Calculate the mean References: http://en.wikipedia.org/wiki/Hypergeometric_distribution
-
pValueDown
public double pValueDown(int k, int N, int D, int n)
-
pValueDown
public double pValueDown(int k, int N, int D, int n, double threshold)
Pvalue for 'k' or less Note: Includes 'k' It also compares to a 'threshold' value to speedup the process. Whenever cumulative probability is over the threshold, 1.0 is returned This is useful when we are interested on very small p-values- Parameters:
k
- : white marbles drawnN
- : Total marblesD
- : White marbles => N-D : Black marblesn
- : marbles drawn => N-n : not drawntheshold
- Threshold value- Returns:
- Cumulative probability or 1.0 (if cumulative is over the threshold)
-
pValueUp
public double pValueUp(int k, int N, int D, int n)
-
pValueUp
public double pValueUp(int k, int N, int D, int n, double threshold)
Fisher's exact test for more than 'k' It also compares to a 'threshold' value to speedup the process. Whenever cumulative probability is over the threshold, 1.0 is returned This is useful when we are interested on very small p-values- Parameters:
k
- : white marbles drawnN
- : Total marblesD
- : White marbles => N-D : Black marblesn
- : marbles drawn => N-n : not drawntheshold
- Threshold value- Returns:
- Cumulative probability or 1.0 (if cumulative is over the threshold)
-
toR
public java.lang.String toR(int k, int N, int D, int n, boolean lowerTail)
Convert values to Fisher's 'R' command- Returns:
-
variance
public double variance(int k, int N, int D, int n)
Calculate the variance References: http://en.wikipedia.org/wiki/Hypergeometric_distribution
-
-