Search in sources :

Example 51 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class PersistentDummyObjectHelper method addTestAnalyses.

public void addTestAnalyses(ExpressionExperiment ee) {
    /*
         * Add analyses
         */
    CoexpressionAnalysis pca = CoexpressionAnalysis.Factory.newInstance();
    pca.setName(RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
    pca.setExperimentAnalyzed(ee);
    persisterHelper.persist(pca);
    /*
         * Diff
         */
    DifferentialExpressionAnalysis expressionAnalysis = DifferentialExpressionAnalysis.Factory.newInstance();
    Protocol protocol = Protocol.Factory.newInstance();
    protocol.setName("Differential expression analysis settings");
    protocol.setDescription("qvalue: " + true);
    expressionAnalysis.setProtocol(protocol);
    expressionAnalysis.setExperimentAnalyzed(ee);
    persisterHelper.persist(expressionAnalysis);
}
Also used : CoexpressionAnalysis(ubic.gemma.model.analysis.expression.coexpression.CoexpressionAnalysis) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) Protocol(ubic.gemma.model.common.protocol.Protocol)

Example 52 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class DifferentialExpressionAnalysisTaskImpl method execute.

@Override
public TaskResult execute() {
    if (taskCommand instanceof DifferentialExpressionAnalysisRemoveTaskCommand) {
        DifferentialExpressionAnalysis toRemove = ((DifferentialExpressionAnalysisRemoveTaskCommand) taskCommand).getToRemove();
        if (toRemove == null) {
            throw new IllegalArgumentException("Analysis to remove must not be null");
        }
        log.info("Removing analysis ...");
        this.differentialExpressionAnalysisService.remove(toRemove);
        return new TaskResult(taskCommand, true);
    }
    Collection<DifferentialExpressionAnalysis> results = doAnalysis();
    Collection<DifferentialExpressionAnalysis> minimalResults = new HashSet<>();
    for (DifferentialExpressionAnalysis r : results) {
        /* Don't send the full analysis to the space. Instead, create a minimal result. */
        DifferentialExpressionAnalysis minimalResult = DifferentialExpressionAnalysis.Factory.newInstance();
        minimalResult.setName(r.getName());
        minimalResult.setDescription(r.getDescription());
        minimalResult.setAuditTrail(r.getAuditTrail());
        minimalResults.add(minimalResult);
    }
    return new TaskResult(taskCommand, minimalResults);
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) TaskResult(ubic.gemma.core.job.TaskResult) HashSet(java.util.HashSet)

Example 53 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class DifferentialExpressionAnalysisTaskImpl method doAnalysis.

private Collection<DifferentialExpressionAnalysis> doAnalysis() {
    ExpressionExperiment ee = taskCommand.getExpressionExperiment();
    if (taskCommand.getToRedo() != null) {
        log.info("Redoing analysis");
        ee = expressionExperimentService.thawLite(ee);
        return differentialExpressionAnalyzerService.redoAnalysis(ee, taskCommand.getToRedo(), true);
    }
    ee = expressionExperimentService.thawLite(ee);
    Collection<DifferentialExpressionAnalysis> diffAnalyses = differentialExpressionAnalysisService.getAnalyses(ee);
    if (!diffAnalyses.isEmpty()) {
        log.info("This experiment has some existing analyses; if they overlap with the new analysis they will be deleted after the run.");
    }
    Collection<DifferentialExpressionAnalysis> results;
    Collection<ExperimentalFactor> factors = taskCommand.getFactors();
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    boolean rnaSeq = expressionExperimentService.isRNASeq(ee);
    config.setUseWeights(rnaSeq);
    config.setFactorsToInclude(factors);
    config.setSubsetFactor(taskCommand.getSubsetFactor());
    if (taskCommand.isIncludeInteractions() && factors.size() == 2) {
        /*
             * We should not include 'batch' in an interaction. But I don't want to enforce that here.
             */
        for (ExperimentalFactor ef : factors) {
            if (BatchInfoPopulationServiceImpl.isBatchFactor(ef)) {
                log.warn("Batch is included in the interaction!");
            }
        }
        // might get dropped.
        config.addInteractionToInclude(factors);
    }
    DifferentialExpressionAnalyzerServiceImpl.AnalysisType analyzer = analysisSelectionAndExecutionService.determineAnalysis(ee, config);
    if (analyzer == null) {
        throw new IllegalStateException("Data set cannot be analyzed");
    }
    config.setAnalysisType(analyzer);
    results = differentialExpressionAnalyzerService.runDifferentialExpressionAnalyses(ee, config);
    return results;
}
Also used : DifferentialExpressionAnalysisConfig(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalysisConfig) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) DifferentialExpressionAnalyzerServiceImpl(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl)

Aggregations

DifferentialExpressionAnalysis (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)53 Test (org.junit.Test)26 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)26 ExpressionAnalysisResultSet (ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)21 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)13 DifferentialExpressionAnalysisResult (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult)11 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)8 HashSet (java.util.HashSet)5 ContrastResult (ubic.gemma.model.analysis.expression.diff.ContrastResult)5 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)5 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)5 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)5 AnalysisType (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType)4 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Transactional (org.springframework.transaction.annotation.Transactional)3 DifferentialExpressionAnalysisConfig (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalysisConfig)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 DoubleMatrixReader (ubic.basecode.io.reader.DoubleMatrixReader)2 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)2