Search in sources :

Example 1 with Formatter

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;
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) DoubleMatrix2D(cern.colt.matrix.DoubleMatrix2D) DenseDoubleMatrix2D(cern.colt.matrix.impl.DenseDoubleMatrix2D) Formatter(cern.colt.matrix.doublealgo.Formatter) ModelAndView(org.springframework.web.servlet.ModelAndView) MeanVarianceRelation(ubic.gemma.model.expression.bioAssayData.MeanVarianceRelation) TextView(ubic.gemma.web.view.TextView) DenseDoubleMatrix2D(cern.colt.matrix.impl.DenseDoubleMatrix2D) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)1 Formatter (cern.colt.matrix.doublealgo.Formatter)1 DenseDoubleMatrix2D (cern.colt.matrix.impl.DenseDoubleMatrix2D)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)1 MeanVarianceRelation (ubic.gemma.model.expression.bioAssayData.MeanVarianceRelation)1 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)1 TextView (ubic.gemma.web.view.TextView)1