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