Search in sources :

Example 6 with Histogram

use of ubic.basecode.math.distribution.Histogram in project Gemma by PavlidisLab.

the class DifferentialExpressionResultDaoImpl method loadPvalueDistribution.

@Override
public Histogram loadPvalueDistribution(Long resultSetId) {
    List<?> pvds = this.getHibernateTemplate().findByNamedParam("select rs.pvalueDistribution from ExpressionAnalysisResultSet rs where rs.id=:rsid ", "rsid", resultSetId);
    if (pvds.isEmpty()) {
        return null;
    }
    assert pvds.size() == 1;
    PvalueDistribution pvd = (PvalueDistribution) pvds.get(0);
    ByteArrayConverter bac = new ByteArrayConverter();
    double[] counts = bac.byteArrayToDoubles(pvd.getBinCounts());
    Integer numBins = pvd.getNumBins();
    assert numBins == counts.length;
    Histogram hist = new Histogram(resultSetId.toString(), numBins, 0.0, 1.0);
    for (int i = 0; i < numBins; i++) {
        hist.fill(i, (int) counts[i]);
    }
    return hist;
}
Also used : BigInteger(java.math.BigInteger) Histogram(ubic.basecode.math.distribution.Histogram) ByteArrayConverter(ubic.basecode.io.ByteArrayConverter)

Aggregations

Histogram (ubic.basecode.math.distribution.Histogram)6 XYSeries (org.jfree.data.xy.XYSeries)2 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)2 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)1 DenseDoubleMatrix1D (cern.colt.matrix.impl.DenseDoubleMatrix1D)1 Gamma (cern.jet.random.Gamma)1 Normal (cern.jet.random.Normal)1 MersenneTwister (cern.jet.random.engine.MersenneTwister)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 BigInteger (java.math.BigInteger)1 Test (org.junit.Test)1 ExpressionDataMatrixRowElement (ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement)1 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)1 DifferentialExpressionAnalysis (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)1 DifferentialExpressionAnalysisResult (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult)1 ExpressionAnalysisResultSet (ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)1 PvalueDistribution (ubic.gemma.model.analysis.expression.diff.PvalueDistribution)1