Search in sources :

Example 1 with ExperimentalDesignWriter

use of ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter in project Gemma by PavlidisLab.

the class ExpressionDataFileServiceImpl method writeDesignMatrix.

/**
 * Writes out the experimental design for the given experiment. The bioassays (col 0) matches match the header row
 * of the data matrix printed out by the {@link MatrixWriter}.
 *
 * @return file that was written
 */
private File writeDesignMatrix(File file, ExpressionExperiment expressionExperiment) throws IOException {
    OutputStream oStream;
    oStream = new GZIPOutputStream(new FileOutputStream(file));
    try (Writer writer = new OutputStreamWriter(oStream)) {
        ExperimentalDesignWriter edWriter = new ExperimentalDesignWriter();
        edWriter.write(writer, expressionExperiment, true);
    }
    return file;
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) GZIPOutputStream(java.util.zip.GZIPOutputStream) ExperimentalDesignWriter(ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter) MatrixWriter(ubic.gemma.core.datastructure.matrix.MatrixWriter) ExperimentalDesignWriter(ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter)

Example 2 with ExperimentalDesignWriter

use of ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter in project Gemma by PavlidisLab.

the class ExperimentalDesignWriterCLI method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception e = super.processCommandLine(args);
    if (e != null)
        return e;
    for (BioAssaySet ee : expressionExperiments) {
        if (ee instanceof ExpressionExperiment) {
            ExperimentalDesignWriter edWriter = new ExperimentalDesignWriter();
            try (PrintWriter writer = new PrintWriter(outFileName + "_" + FileTools.cleanForFileName(((ExpressionExperiment) ee).getShortName()) + ".txt")) {
                edWriter.write(writer, (ExpressionExperiment) ee, true);
                writer.flush();
                writer.close();
            } catch (IOException exception) {
                return exception;
            }
        } else {
            throw new UnsupportedOperationException("Can't handle non-EE BioAssaySets yet");
        }
    }
    return null;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExperimentalDesignWriter(ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter) IOException(java.io.IOException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 3 with ExperimentalDesignWriter

use of ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter in project Gemma by PavlidisLab.

the class ExpressionExperimentQCController method identifyPossibleOutliers.

@RequestMapping("/expressionExperiment/possibleOutliers.html")
public ModelAndView identifyPossibleOutliers(Long id) throws IOException {
    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;
    }
    // identify outliers
    if (!sampleCoexpressionMatrixService.hasMatrix(ee)) {
        log.warn("Experiment doesn't have correlation matrix computed (will not create right now)");
        return null;
    }
    DoubleMatrix<BioAssay, BioAssay> sampleCorrelationMatrix = sampleCoexpressionMatrixService.findOrCreate(ee);
    Collection<OutlierDetails> outliers = outlierDetectionService.identifyOutliersByMedianCorrelation(ee);
    Collection<BioAssay> bioAssays = new HashSet<>();
    if (!outliers.isEmpty()) {
        for (OutlierDetails details : outliers) {
            bioAssays.add(details.getBioAssay());
        }
    }
    // and write it out
    StringWriter writer = new StringWriter();
    StringBuffer buf = writer.getBuffer();
    ExpressionDataWriterUtils.appendBaseHeader(ee, "Sample outlier", buf);
    ExperimentalDesignWriter edWriter = new ExperimentalDesignWriter();
    ee = expressionExperimentService.thawLiter(ee);
    edWriter.write(writer, ee, bioAssays, false, true);
    ModelAndView mav = new ModelAndView(new TextView());
    mav.addObject(TextView.TEXT_PARAM, buf.toString());
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) TextView(ubic.gemma.web.view.TextView) ExperimentalDesignWriter(ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) OutlierDetails(ubic.gemma.core.analysis.preprocess.OutlierDetails) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with ExperimentalDesignWriter

use of ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter in project Gemma by PavlidisLab.

the class ExpressionExperimentQCController method identifyOutliersRemoved.

@RequestMapping("/expressionExperiment/outliersRemoved.html")
public ModelAndView identifyOutliersRemoved(Long id) throws IOException {
    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;
    }
    ee = expressionExperimentService.thawLite(ee);
    Collection<BioAssay> bioAssays = new HashSet<>();
    for (BioAssay assay : ee.getBioAssays()) {
        if (assay.getIsOutlier()) {
            bioAssays.add(assay);
        }
    }
    // and write it out
    StringWriter writer = new StringWriter();
    StringBuffer buf = writer.getBuffer();
    ExpressionDataWriterUtils.appendBaseHeader(ee, "Outliers removed", buf);
    ExperimentalDesignWriter edWriter = new ExperimentalDesignWriter();
    ee = expressionExperimentService.thawLiter(ee);
    edWriter.write(writer, ee, bioAssays, false, true);
    ModelAndView mav = new ModelAndView(new TextView());
    mav.addObject(TextView.TEXT_PARAM, buf.toString());
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) TextView(ubic.gemma.web.view.TextView) ExperimentalDesignWriter(ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ExperimentalDesignWriter (ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter)4 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)2 TextView (ubic.gemma.web.view.TextView)2 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 OutlierDetails (ubic.gemma.core.analysis.preprocess.OutlierDetails)1 MatrixWriter (ubic.gemma.core.datastructure.matrix.MatrixWriter)1 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)1