Search in sources :

Example 21 with DifferentialExpressionAnalysis

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

the class DifferentialExpressionAnalyzerServiceImpl method persistAnalyses.

private Collection<DifferentialExpressionAnalysis> persistAnalyses(ExpressionExperiment expressionExperiment, Collection<DifferentialExpressionAnalysis> diffExpressionAnalyses, DifferentialExpressionAnalysisConfig config) {
    Collection<DifferentialExpressionAnalysis> results = new HashSet<>();
    for (DifferentialExpressionAnalysis analysis : diffExpressionAnalyses) {
        DifferentialExpressionAnalysis persistentAnalysis = this.persistAnalysis(expressionExperiment, analysis, config);
        results.add(persistentAnalysis);
    }
    return results;
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)

Example 22 with DifferentialExpressionAnalysis

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

the class DifferentialExpressionAnalyzerServiceImpl method extendResultSets.

private void extendResultSets(Collection<DifferentialExpressionAnalysis> results, Collection<ExpressionAnalysisResultSet> toUpdateResultSets) {
    for (DifferentialExpressionAnalysis a : results) {
        boolean found = false;
        for (ExpressionAnalysisResultSet oldrs : toUpdateResultSets) {
            assert oldrs.getId() != null;
            this.differentialExpressionResultService.thaw(oldrs);
            for (ExpressionAnalysisResultSet temprs : a.getResultSets()) {
                /*
                     * Compare the config
                     */
                if (this.configsAreEqual(temprs, oldrs)) {
                    found = true;
                    this.extendResultSet(oldrs, temprs);
                    break;
                }
            }
            if (!found)
                throw new IllegalStateException("Failed to find a matching existing result set for " + oldrs);
        }
    }
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)

Example 23 with DifferentialExpressionAnalysis

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

the class DifferentialExpressionAnalyzerServiceImpl method deleteAnalyses.

@Override
public int deleteAnalyses(ExpressionExperiment expressionExperiment) {
    Collection<DifferentialExpressionAnalysis> diffAnalysis = differentialExpressionAnalysisService.findByInvestigation(expressionExperiment);
    int result = 0;
    if (diffAnalysis == null || diffAnalysis.isEmpty()) {
        DifferentialExpressionAnalyzerServiceImpl.log.debug("No differential expression analyses to remove for " + expressionExperiment.getShortName());
        return result;
    }
    for (DifferentialExpressionAnalysis de : diffAnalysis) {
        DifferentialExpressionAnalyzerServiceImpl.log.info("Deleting old differential expression analysis for experiment " + expressionExperiment.getShortName() + ": Analysis ID=" + de.getId());
        differentialExpressionAnalysisService.remove(de);
        this.deleteStatistics(expressionExperiment, de);
        this.deleteAnalysisFiles(de);
        result++;
    }
    return result;
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)

Example 24 with DifferentialExpressionAnalysis

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

the class DifferentialExpressionAnalysisConfig method toAnalysis.

/**
 * @return representation of this analysis with populated protocol holding information from this.
 */
public DifferentialExpressionAnalysis toAnalysis() {
    DifferentialExpressionAnalysis analysis = DifferentialExpressionAnalysis.Factory.newInstance();
    Protocol protocol = Protocol.Factory.newInstance();
    protocol.setName("Differential expression analysis settings");
    protocol.setDescription(this.toString());
    analysis.setProtocol(protocol);
    return analysis;
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) Protocol(ubic.gemma.model.common.protocol.Protocol)

Example 25 with DifferentialExpressionAnalysis

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

the class DifferentialExpressionSearchController method getFactors.

/**
 * AJAX entry.
 * Value objects returned contain experiments that have 2 factors and have had the diff analysis run on it.
 */
public Collection<ExpressionExperimentExperimentalFactorValueObject> getFactors(final Collection<Long> eeIds) {
    Collection<ExpressionExperimentExperimentalFactorValueObject> result = new HashSet<>();
    final Collection<Long> securityFilteredIds = securityFilterExpressionExperimentIds(eeIds);
    if (securityFilteredIds.size() == 0) {
        return result;
    }
    log.debug("Getting factors for experiments with ids: " + StringUtils.abbreviate(securityFilteredIds.toString(), 100));
    Collection<Long> filteredEeIds = new HashSet<>();
    Map<Long, Collection<DifferentialExpressionAnalysis>> diffAnalyses = differentialExpressionAnalysisService.findByInvestigationIds(securityFilteredIds);
    if (diffAnalyses.isEmpty()) {
        log.debug("No differential expression analyses for given ids: " + StringUtils.join(filteredEeIds, ','));
        return result;
    }
    Collection<ExpressionExperimentValueObject> eevos = this.expressionExperimentService.loadValueObjects(diffAnalyses.keySet(), false);
    Map<Long, ExpressionExperimentValueObject> eevoMap = new HashMap<>();
    for (ExpressionExperimentValueObject eevo : eevos) {
        eevoMap.put(eevo.getId(), eevo);
    }
    for (Long id : diffAnalyses.keySet()) {
        Collection<DifferentialExpressionAnalysis> analyses = diffAnalyses.get(id);
        for (DifferentialExpressionAnalysis analysis : analyses) {
            differentialExpressionAnalysisService.thaw(analysis);
            Collection<ExperimentalFactor> factors = new HashSet<>();
            for (FactorAssociatedAnalysisResultSet fars : analysis.getResultSets()) {
                // FIXME includes factors making up interaction terms, but shouldn't
                // matter, because they will be included as main effects too. If not, this will be wrong!
                factors.addAll(fars.getExperimentalFactors());
            }
            filteredEeIds.add(id);
            ExpressionExperimentValueObject eevo = eevoMap.get(id);
            ExpressionExperimentExperimentalFactorValueObject eeefvo = new ExpressionExperimentExperimentalFactorValueObject();
            eeefvo.setExpressionExperiment(eevo);
            eeefvo.setNumFactors(factors.size());
            for (ExperimentalFactor ef : factors) {
                ExperimentalFactorValueObject efvo = geneDifferentialExpressionService.configExperimentalFactorValueObject(ef);
                eeefvo.getExperimentalFactors().add(efvo);
            }
            result.add(eeefvo);
        }
    }
    log.info("Filtered experiments.  Returning factors for experiments with ids: " + StringUtils.abbreviate(filteredEeIds.toString(), 100));
    return result;
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionExperimentExperimentalFactorValueObject(ubic.gemma.web.controller.expression.experiment.ExpressionExperimentExperimentalFactorValueObject) FactorAssociatedAnalysisResultSet(ubic.gemma.model.analysis.expression.FactorAssociatedAnalysisResultSet) ExpressionExperimentExperimentalFactorValueObject(ubic.gemma.web.controller.expression.experiment.ExpressionExperimentExperimentalFactorValueObject)

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