Search in sources :

Example 1 with PreprocessingException

use of ubic.gemma.core.analysis.preprocess.PreprocessingException in project Gemma by PavlidisLab.

the class OutlierFlaggingServiceImpl method markAsMissing.

@Override
public void markAsMissing(Collection<BioAssay> bioAssays) {
    if (bioAssays == null || bioAssays.size() == 0)
        return;
    boolean hasNewOutliers = false;
    /*
         * FIXME: if there are two (or more) platforms, make sure we flag all bioassays that use the same biomaterial.
         * However, we are intending to turn all multiplatform datasets into single platform ones
         */
    for (BioAssay ba : bioAssays) {
        if (ba.getIsOutlier()) {
            continue;
        }
        hasNewOutliers = true;
        ba.setIsOutlier(true);
        bioAssayService.update(ba);
        this.audit(ba, "Sample " + ba.getName() + " marked as missing data.");
    }
    if (!hasNewOutliers) {
        System.out.println("No new outliers.");
        return;
    }
    ExpressionExperiment expExp = expressionExperimentService.findByBioAssay(bioAssays.iterator().next());
    auditTrailService.addUpdateEvent(expExp, SampleRemovalEvent.Factory.newInstance(), bioAssays.size() + " flagged as outliers", StringUtils.join(bioAssays, ","));
    try {
        preprocessorService.process(expExp);
    } catch (PreprocessingException e) {
        OutlierFlaggingServiceImpl.log.error("Error during postprocessing, make sure additional steps are completed", e);
    }
}
Also used : PreprocessingException(ubic.gemma.core.analysis.preprocess.PreprocessingException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 2 with PreprocessingException

use of ubic.gemma.core.analysis.preprocess.PreprocessingException in project Gemma by PavlidisLab.

the class TwoChannelMissingValueCLI method processExperiment.

private boolean processExperiment(ExpressionExperiment ee) {
    Collection<QuantitationType> types = eeService.getQuantitationTypes(ee);
    ee = this.eeService.thawLite(ee);
    if (!force && this.noNeedToRun(ee, MissingValueAnalysisEvent.class))
        return false;
    QuantitationType previousMissingValueQt = null;
    for (QuantitationType qType : types) {
        if (qType.getType() == StandardQuantitationType.PRESENTABSENT) {
            if (previousMissingValueQt != null) {
                AbstractCLI.log.warn("More than one present/absent quantitationtype!");
            }
            previousMissingValueQt = qType;
        }
    }
    if (previousMissingValueQt != null && !force) {
        AbstractCLI.log.warn(ee + " already has missing value vectors, skipping");
        return false;
    }
    if (force && previousMissingValueQt != null) {
        AbstractCLI.log.info("Removing old present/absent data");
        rawService.removeDataForQuantitationType(previousMissingValueQt);
        procService.removeDataForQuantitationType(previousMissingValueQt);
        quantitationTypeService.remove(previousMissingValueQt);
    }
    AbstractCLI.log.info("Got " + ee + ", thawing...");
    AbstractCLI.log.info("Computing missing value data..");
    Collection<RawExpressionDataVector> missingValueVectors = tcmv.computeMissingValues(ee, s2n, this.extraMissingValueIndicators);
    if (missingValueVectors.size() == 0) {
        AbstractCLI.log.warn("No missing value vectors computed");
        return false;
    }
    try {
        preprocessorService.process(ee, true);
    } catch (PreprocessingException e) {
        AbstractCLI.log.error("Error during postprocessing of " + ee + " , make sure additional steps are completed", e);
    }
    return true;
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) MissingValueAnalysisEvent(ubic.gemma.model.common.auditAndSecurity.eventType.MissingValueAnalysisEvent) PreprocessingException(ubic.gemma.core.analysis.preprocess.PreprocessingException) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Example 3 with PreprocessingException

use of ubic.gemma.core.analysis.preprocess.PreprocessingException in project Gemma by PavlidisLab.

the class ExpressionExperimentFormController method onSubmit.

@Override
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) {
    ExpressionExperimentEditValueObject eeCommand = (ExpressionExperimentEditValueObject) command;
    ExpressionExperiment expressionExperiment = expressionExperimentService.load(eeCommand.getId());
    if (expressionExperiment == null) {
        throw new IllegalArgumentException("Could not load experiment");
    }
    expressionExperiment = expressionExperimentService.thawLite(expressionExperiment);
    /*
         * Much more complicated
         */
    boolean changedQT = this.updateQuantTypes(request, expressionExperiment, eeCommand.getQuantitationTypes());
    boolean changedBMM = this.updateBioMaterialMap(request, expressionExperiment);
    if (changedQT || changedBMM) {
        try {
            preprocessorService.process(expressionExperiment);
        } catch (PreprocessingException e) {
            throw new RuntimeException("There was an error while updating the experiment after " + "making changes to the quantitation types and/or biomaterial map.", e);
        }
    }
    return new ModelAndView(new RedirectView("http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/expressionExperiment/showExpressionExperiment.html?id=" + eeCommand.getId()));
}
Also used : PreprocessingException(ubic.gemma.core.analysis.preprocess.PreprocessingException) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 4 with PreprocessingException

use of ubic.gemma.core.analysis.preprocess.PreprocessingException in project Gemma by PavlidisLab.

the class OutlierFlaggingServiceImpl method unmarkAsMissing.

@Override
public void unmarkAsMissing(Collection<BioAssay> bioAssays) {
    if (bioAssays.isEmpty())
        return;
    boolean hasReversions = false;
    for (BioAssay bioAssay : bioAssays) {
        if (!bioAssay.getIsOutlier()) {
            continue;
        }
        // Rather long transaction.
        hasReversions = true;
        bioAssay.setIsOutlier(false);
        bioAssayService.update(bioAssay);
    }
    if (!hasReversions) {
        return;
    }
    ExpressionExperiment expExp = expressionExperimentService.findByBioAssay(bioAssays.iterator().next());
    auditTrailService.addUpdateEvent(expExp, SampleRemovalReversionEvent.Factory.newInstance(), "Marked " + bioAssays.size() + " bioassays as non-missing", StringUtils.join(bioAssays, ""));
    assert expExp != null;
    // several transactions
    try {
        preprocessorService.process(expExp);
    } catch (PreprocessingException e) {
        OutlierFlaggingServiceImpl.log.error("Error during postprocessing, make sure additional steps are completed", e);
    }
}
Also used : PreprocessingException(ubic.gemma.core.analysis.preprocess.PreprocessingException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 5 with PreprocessingException

use of ubic.gemma.core.analysis.preprocess.PreprocessingException in project Gemma by PavlidisLab.

the class SimpleExpressionDataLoaderServiceImpl method create.

/**
 * For use in tests.
 */
private ExpressionExperiment create(SimpleExpressionExperimentMetaData metaData, DoubleMatrix<String, String> matrix) {
    ExpressionExperiment experiment = this.convert(metaData, matrix);
    experiment = persisterHelper.persist(experiment, persisterHelper.prepare(experiment));
    assert experiment.getShortName() != null;
    try {
        preprocessorService.process(experiment);
    } catch (PreprocessingException e) {
        SimpleExpressionDataLoaderServiceImpl.log.error("Error during postprocessing: " + e.getMessage(), e.getCause() != null ? e.getCause() : e);
    }
    return experiment;
}
Also used : PreprocessingException(ubic.gemma.core.analysis.preprocess.PreprocessingException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Aggregations

PreprocessingException (ubic.gemma.core.analysis.preprocess.PreprocessingException)5 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)4 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)2 ModelAndView (org.springframework.web.servlet.ModelAndView)1 RedirectView (org.springframework.web.servlet.view.RedirectView)1 MissingValueAnalysisEvent (ubic.gemma.model.common.auditAndSecurity.eventType.MissingValueAnalysisEvent)1 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)1 StandardQuantitationType (ubic.gemma.model.common.quantitationtype.StandardQuantitationType)1 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)1