Search in sources :

Example 1 with NotPositiveException

use of org.apache.commons.math3.exception.NotPositiveException 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?");
    }
}
Also used : HypergeometricDistribution(org.apache.commons.math3.distribution.HypergeometricDistribution) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) NumberIsTooLargeException(org.apache.commons.math3.exception.NumberIsTooLargeException) NotStrictlyPositiveException(org.apache.commons.math3.exception.NotStrictlyPositiveException) NotPositiveException(org.apache.commons.math3.exception.NotPositiveException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 HypergeometricDistribution (org.apache.commons.math3.distribution.HypergeometricDistribution)1 NotPositiveException (org.apache.commons.math3.exception.NotPositiveException)1 NotStrictlyPositiveException (org.apache.commons.math3.exception.NotStrictlyPositiveException)1 NumberIsTooLargeException (org.apache.commons.math3.exception.NumberIsTooLargeException)1