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;
}
Aggregations