use of org.apache.commons.math3.exception.NumberIsTooLargeException in project PhenomeScape by soulj.
the class GOTermAnalyser method calculateGOTermPValues.
public void calculateGOTermPValues(PhenomeExpressSubnetwork subnetwork, ProteinNetwork proteinNetwork) throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException, Exception {
Map<GOTerm, Integer> subnetworkGoTerms = goTermsinSubnetwork(proteinNetwork, subnetwork);
int networkSize = proteinNetwork.getNodeCount();
double minProb = 2.0;
GOTerm bestGOTerm = null;
for (GOTerm goterm : subnetworkGoTerms.keySet()) {
HypergeometricDistribution hypergeometricDistribution = new HypergeometricDistribution(networkSize, goterm.getNumAnnotation(), subnetwork.getNodeList().size());
double prob = 1.0 - hypergeometricDistribution.cumulativeProbability(subnetworkGoTerms.get(goterm));
if (prob < minProb) {
minProb = prob;
bestGOTerm = goterm;
} else if (prob == minProb) {
if (subnetworkGoTerms.get(goterm) > subnetworkGoTerms.get(bestGOTerm)) {
minProb = prob;
bestGOTerm = goterm;
}
}
}
subnetwork.setBestGOTerm(bestGOTerm);
subnetwork.setGoTermPvalue(minProb);
if (bestGOTerm == null) {
throw new Exception("No matching GOTerms - Wrong species selected?");
}
}
Aggregations