use of cern.colt.matrix.doublealgo.Formatter in project Gemma by PavlidisLab.
the class ExpressionExperimentQCController method visualizeMeanVariance.
/**
* @param id of experiment
* @param size Multiplier on the cell size. 1 or null for standard small size.
* @param text if true, output a tabbed file instead of a png
* @param os response output stream
* @return ModelAndView object if text is true, otherwise null
*/
@RequestMapping("/expressionExperiment/visualizeMeanVariance.html")
public ModelAndView visualizeMeanVariance(Long id, Double size, Boolean text, OutputStream os) throws Exception {
if (id == null) {
log.warn("No id!");
return null;
}
ExpressionExperiment ee = expressionExperimentService.load(id);
if (ee == null) {
log.warn("Could not load experiment with id " + id);
return null;
}
MeanVarianceRelation mvr = meanVarianceService.find(ee);
if (mvr == null) {
return null;
}
if (text != null && text) {
final ByteArrayConverter bac = new ByteArrayConverter();
double[] means = bac.byteArrayToDoubles(mvr.getMeans());
double[] variances = bac.byteArrayToDoubles(mvr.getVariances());
DoubleMatrix2D matrix = new DenseDoubleMatrix2D(means.length, 2);
matrix.viewColumn(0).assign(means);
matrix.viewColumn(1).assign(variances);
String matrixString = new Formatter("%1.2G").toTitleString(matrix, null, new String[] { "mean", "variance" }, null, null, null, null);
ModelAndView mav = new ModelAndView(new TextView());
mav.addObject(TextView.TEXT_PARAM, matrixString);
return mav;
}
this.writeMeanVariance(os, mvr, size);
return null;
}
Aggregations