List of usage examples for org.apache.commons.math3.distribution HypergeometricDistribution cumulativeProbability
public double cumulativeProbability(int x)
From source file:ch.unil.genescore.pathway.GeneSetLibrary.java
License:asdf
/** Compute enrichment for the given set using hypergeometric distribution (magenta-option) * quantile refers to the cutoff used to assign ins and outs. * *//* w ww . j a v a 2s . c o m*/ protected double[] computeHypGeomPvalue2(double[] set, double[] totSet) { ArrayList<Double> quantiles = Pascal.set.hypGeomQuantiles_; double[] pvals = new double[quantiles.size()]; if (set.length == 0) { for (int i = 0; i < quantiles.size(); i++) { pvals[i] = 1; } return pvals; } for (int j = 0; j < quantiles.size(); j++) { double[] valAr = totSet.clone(); Arrays.sort(valAr); int n = (int) Math.floor(valAr.length * quantiles.get(j)); double cutoffVal = valAr[n]; int setSize = valAr.length - n - 1; int q = 0; for (double g : set) { if (g > cutoffVal) q += 1; } HypergeometricDistribution myHypgeom = new HypergeometricDistribution(valAr.length, setSize, set.length); double pval = 1 - myHypgeom.cumulativeProbability((q - 1)); pvals[j] = pval; } return (pvals); }
From source file:ch.unil.genescore.pathway.GeneSetLibrary.java
License:asdf
protected void computeHypGeomPvalue(GeneSet set) { ArrayList<Double> quantiles = Pascal.set.hypGeomQuantiles_; double[] pvals = new double[quantiles.size()]; if (set.getGenes().size() == 0) { for (int i = 0; i < quantiles.size(); i++) { pvals[i] = 1;/* w ww . ja v a2 s .co m*/ } set.setHypGeomPvalues(pvals); return; } for (int j = 0; j < quantiles.size(); j++) { double[] valAr = new double[genesForSimulation_.size()]; for (int i = 0; i < genesForSimulation_.size(); i++) { valAr[i] = genesForSimulation_.get(i).getChi2Stat(); } Arrays.sort(valAr); int n = (int) Math.floor(valAr.length * quantiles.get(j)); double cutoffVal = valAr[n]; int setSize = valAr.length - n - 1; HashSet<Gene> pathwayGenes = set.getGenes(); if (pathwayGenes.size() == 0) return; int q = 0; for (Gene g : pathwayGenes) { if (g.getChi2Stat() > cutoffVal) q += 1; } HypergeometricDistribution myHypgeom = new HypergeometricDistribution(valAr.length, setSize, pathwayGenes.size()); double pval = 1 - myHypgeom.cumulativeProbability((q - 1)); pvals[j] = pval; } set.setHypGeomPvalues(pvals); }