Search in sources :

Example 1 with MeanVarianceEstimator

use of ubic.basecode.math.linearmodels.MeanVarianceEstimator in project Gemma by PavlidisLab.

the class MeanVarianceServiceImpl method calculateMeanVariance.

/**
 * @param matrix on which mean variance relation is computed with
 * @param mvr    object, if null, a new object is created
 * @return MeanVarianceRelation object
 */
private MeanVarianceRelation calculateMeanVariance(ExpressionDataDoubleMatrix matrix, MeanVarianceRelation mvr) {
    if (matrix == null) {
        log.warn("Experiment matrix is null");
        return null;
    }
    DoubleMatrix2D mat = new DenseDoubleMatrix2D(matrix.rows(), matrix.columns());
    for (int row = 0; row < mat.rows(); row++) {
        mat.viewRow(row).assign(matrix.getRawRow(row));
    }
    MeanVarianceEstimator mve = new MeanVarianceEstimator(mat);
    if (mvr == null) {
        mvr = MeanVarianceRelation.Factory.newInstance();
    }
    if (mve.getMeanVariance() != null) {
        mvr.setMeans(bac.doubleArrayToBytes(mve.getMeanVariance().viewColumn(0).toArray()));
        mvr.setVariances(bac.doubleArrayToBytes(mve.getMeanVariance().viewColumn(1).toArray()));
    }
    return mvr;
}
Also used : MeanVarianceEstimator(ubic.basecode.math.linearmodels.MeanVarianceEstimator) DoubleMatrix2D(cern.colt.matrix.DoubleMatrix2D) DenseDoubleMatrix2D(cern.colt.matrix.impl.DenseDoubleMatrix2D) DenseDoubleMatrix2D(cern.colt.matrix.impl.DenseDoubleMatrix2D)

Aggregations

DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)1 DenseDoubleMatrix2D (cern.colt.matrix.impl.DenseDoubleMatrix2D)1 MeanVarianceEstimator (ubic.basecode.math.linearmodels.MeanVarianceEstimator)1