Search in sources :

Example 1 with MatrixWriter

use of ubic.gemma.core.datastructure.matrix.MatrixWriter 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 MatrixWriter

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

the class ExpressionDataFileServiceImpl method writeJson.

private void writeJson(File file, ExpressionDataMatrix<?> expressionDataMatrix) throws IOException {
    try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) {
        MatrixWriter matrixWriter = new MatrixWriter();
        matrixWriter.writeJSON(writer, expressionDataMatrix);
    }
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) MatrixWriter(ubic.gemma.core.datastructure.matrix.MatrixWriter) ExperimentalDesignWriter(ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter) MatrixWriter(ubic.gemma.core.datastructure.matrix.MatrixWriter)

Example 3 with MatrixWriter

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

the class ExpressionDataFileServiceImpl method writeJson.

private void writeJson(File file, PrimitiveType representation, Collection<DesignElementDataVector> vectors) throws IOException {
    this.rawExpressionDataVectorService.thawRawAndProcessed(vectors);
    ExpressionDataMatrix<?> expressionDataMatrix = ExpressionDataMatrixBuilder.getMatrix(representation, vectors);
    try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) {
        MatrixWriter matrixWriter = new MatrixWriter();
        matrixWriter.writeJSON(writer, expressionDataMatrix);
    }
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) MatrixWriter(ubic.gemma.core.datastructure.matrix.MatrixWriter) ExperimentalDesignWriter(ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter) MatrixWriter(ubic.gemma.core.datastructure.matrix.MatrixWriter)

Example 4 with MatrixWriter

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

the class LinearModelAnalyzer method outputForDebugging.

/**
 * Create files that can be used in R to check the results.
 */
private void outputForDebugging(ExpressionDataDoubleMatrix dmatrix, ObjectMatrix<String, String, Object> designMatrix) {
    MatrixWriter mw = new MatrixWriter();
    try (FileWriter writer = new FileWriter(File.createTempFile("data.", ".txt"));
        FileWriter out = new FileWriter(File.createTempFile("design.", ".txt"))) {
        mw.write(writer, dmatrix, null, true, false);
        ubic.basecode.io.writer.MatrixWriter<String, String> dem = new ubic.basecode.io.writer.MatrixWriter<>(out);
        dem.writeMatrix(designMatrix, true);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : FileWriter(java.io.FileWriter) IOException(java.io.IOException) MatrixWriter(ubic.gemma.core.datastructure.matrix.MatrixWriter)

Aggregations

MatrixWriter (ubic.gemma.core.datastructure.matrix.MatrixWriter)4 GZIPOutputStream (java.util.zip.GZIPOutputStream)3 ExperimentalDesignWriter (ubic.gemma.core.datastructure.matrix.ExperimentalDesignWriter)3 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 ZipOutputStream (java.util.zip.ZipOutputStream)1