Search in sources :

Example 6 with ExpressionExperimentDetailsValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject in project Gemma by PavlidisLab.

the class ExpressionExperimentReportServiceImpl method populateReportInformation.

@Override
public void populateReportInformation(Collection<ExpressionExperimentDetailsValueObject> vos) {
    StopWatch timer = new StopWatch();
    timer.start();
    List<Long> ids = new ArrayList<>();
    for (ExpressionExperimentValueObject vo : vos) {
        ids.add(vo.getId());
    }
    Collection<ExpressionExperimentDetailsValueObject> cachedVos = this.retrieveSummaryObjects(ids);
    Map<Long, ExpressionExperimentDetailsValueObject> id2cachedVo = EntityUtils.getIdMap(cachedVos);
    for (ExpressionExperimentDetailsValueObject eeVo : vos) {
        ExpressionExperimentDetailsValueObject cacheVo = id2cachedVo.get(eeVo.getId());
        if (cacheVo != null) {
            eeVo.setBioMaterialCount(cacheVo.getBioMaterialCount());
            eeVo.setProcessedExpressionVectorCount(cacheVo.getProcessedExpressionVectorCount());
            eeVo.setCoexpressionLinkCount(cacheVo.getCoexpressionLinkCount());
            eeVo.setDateCached(cacheVo.getDateCached());
            eeVo.setDifferentialExpressionAnalyses(cacheVo.getDifferentialExpressionAnalyses());
            eeVo.setLastUpdated(cacheVo.getLastUpdated());
        }
    }
    timer.stop();
    if (timer.getTime() > 1000) {
        log.info(vos.size() + " EE reports fetched in " + timer.getTime() + "ms");
    }
}
Also used : ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) ExpressionExperimentDetailsValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 7 with ExpressionExperimentDetailsValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject in project Gemma by PavlidisLab.

the class ExpressionExperimentReportServiceImpl method generateSummaryObjects.

private Collection<ExpressionExperimentDetailsValueObject> generateSummaryObjects(Collection<Long> ids) {
    Collection<ExpressionExperimentDetailsValueObject> vos = expressionExperimentService.loadDetailsValueObjects(null, false, ids, null, 0, 0);
    this.getStats(vos);
    for (ExpressionExperimentValueObject vo : vos) {
        this.evictFromCache(vo.getId());
        statsCache.put(new Element(vo.getId(), vo));
    }
    return vos;
}
Also used : ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) Element(net.sf.ehcache.Element) ExpressionExperimentDetailsValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject)

Example 8 with ExpressionExperimentDetailsValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject in project Gemma by PavlidisLab.

the class DifferentialExpressionSearchTaskImpl method addConditionsToSearchResultValueObject.

/**
 * Get information on the conditions to be searched. This is not part of the query for the results themselves, but
 * uses the database to get metadata/summaries about the analyses that will be used. Initializes the searchResult
 * value object. Later, values which are non-missing will be replaced with either 'non-significant' or 'significant'
 * results.
 *
 * @param searchResult to be initialized
 * @return list of the resultSets that should be queried.
 */
private List<DiffExResultSetSummaryValueObject> addConditionsToSearchResultValueObject(DifferentialExpressionGenesConditionsValueObject searchResult) {
    StopWatch watch = new StopWatch("addConditionsToSearchResultValueObject");
    watch.start("Add conditions to search result value object");
    List<DiffExResultSetSummaryValueObject> usedResultSets = new LinkedList<>();
    int i = 0;
    DifferentialExpressionSearchTaskImpl.log.info("Loading " + experimentGroupName + " experiments...");
    // database hit: important that this be fast.
    Map<ExpressionExperimentDetailsValueObject, Collection<DifferentialExpressionAnalysisValueObject>> analyses = differentialExpressionAnalysisService.getAnalysesByExperiment(EntityUtils.getIds(experimentGroup));
    experiment: for (ExpressionExperimentDetailsValueObject bas : analyses.keySet()) {
        Collection<DifferentialExpressionAnalysisValueObject> analysesForExperiment = this.filterAnalyses(analyses.get(bas));
        if (analysesForExperiment.isEmpty()) {
            continue;
        }
        /*
             * There will often just be one analysis for the experiment. Exception would be when there is subsetting.
             */
        for (DifferentialExpressionAnalysisValueObject analysis : analysesForExperiment) {
            List<DiffExResultSetSummaryValueObject> resultSets = this.filterResultSets(analysis);
            usedResultSets.addAll(resultSets);
            if (resultSets.isEmpty()) {
                DifferentialExpressionSearchTaskImpl.log.info("No resultSets usable for " + bas.getId());
            }
            for (DiffExResultSetSummaryValueObject resultSet : resultSets) {
                // sanity check.
                assert resultSet.getNumberOfDiffExpressedProbes() != null;
                // interactions not okay
                assert resultSet.getExperimentalFactors().size() == 1;
                ExperimentalFactorValueObject factor = resultSet.getExperimentalFactors().iterator().next();
                Collection<FactorValueValueObject> factorValues = this.filterFactorValues(analysis, factor.getValues(), resultSet.getBaselineGroup().getId());
                if (factorValues.isEmpty()) {
                    /*
                         * This can only happen if there is just a baseline factorvalue. Even for one-sided tests //
                         * that // won't be the case.
                         */
                    DifferentialExpressionSearchTaskImpl.log.warn("Nothing usable for resultSet=" + resultSet.getResultSetId());
                    continue;
                }
                for (FactorValueValueObject factorValue : factorValues) {
                    Condition condition = searchResult.new Condition(bas, analysis, resultSet, factorValue);
                    condition.setExperimentGroupName(experimentGroupName);
                    /*
                         * SANITY CHECKS these fields should be filled in. If not, we are going to skip the results.
                         */
                    if (condition.getNumberDiffExpressedProbes() == -1) {
                        DifferentialExpressionSearchTaskImpl.log.warn(bas + ": Error: No hit list sizes for resultSet with ID=" + resultSet.getResultSetId());
                        continue;
                    }
                    if (condition.getNumberOfProbesOnArray() == null || condition.getNumberDiffExpressedProbes() == null) {
                        DifferentialExpressionSearchTaskImpl.log.error(bas + ": Error: Null counts for # diff ex probe or # probes on array, Skipping");
                        continue experiment;
                    } else if (condition.getNumberOfProbesOnArray() < condition.getNumberDiffExpressedProbes()) {
                        DifferentialExpressionSearchTaskImpl.log.error(bas + ": Error: More diff expressed probes than probes on array. Skipping.");
                        continue experiment;
                    }
                    searchResult.addCondition(condition);
                    i++;
                }
            }
        }
    }
    watch.stop();
    if (watch.getTotalTimeMillis() > 100) {
        // This does not include getting the actual diff ex results.
        DifferentialExpressionSearchTaskImpl.log.info("Get information on conditions/analyses for " + i + " factorValues: " + watch.getTotalTimeMillis() + "ms");
    }
    return usedResultSets;
}
Also used : FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) Condition(ubic.gemma.core.tasks.visualization.DifferentialExpressionGenesConditionsValueObject.Condition) ExpressionExperimentDetailsValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject) ExperimentalFactorValueObject(ubic.gemma.model.expression.experiment.ExperimentalFactorValueObject) StopWatch(org.springframework.util.StopWatch)

Example 9 with ExpressionExperimentDetailsValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject in project Gemma by PavlidisLab.

the class DiffExMetaAnalyzerServiceTest method extraTests2.

private void extraTests2(ExpressionExperiment ds1, ExpressionExperiment ds2, ExpressionExperiment ds3) {
    Collection<Gene> geneCollection = geneService.findByOfficialSymbol("ACTA2");
    assertTrue(!geneCollection.isEmpty());
    Gene g = geneCollection.iterator().next();
    assertNotNull(differentialExpressionResultService.find(g));
    assertNotNull(differentialExpressionResultService.find(g, EntityUtils.getIds(Arrays.asList(ds1, ds2, ds3))));
    assertNotNull(differentialExpressionResultService.find(EntityUtils.getIds(Arrays.asList(ds1, ds2, ds3)), 0.05, 10));
    assertNotNull(differentialExpressionResultService.find(g, 0.05, 10));
    assertTrue(!differentialExpressionResultService.find(g).isEmpty());
    assertTrue(!differentialExpressionResultService.find(g, EntityUtils.getIds(Arrays.asList(ds1, ds2, ds3))).isEmpty());
    assertTrue(!differentialExpressionResultService.find(EntityUtils.getIds(Arrays.asList(ds1, ds2, ds3)), 0.05, 10).isEmpty());
    assertTrue(!differentialExpressionResultService.find(g, 0.05, 10).isEmpty());
    Map<ExpressionExperimentDetailsValueObject, Collection<DifferentialExpressionAnalysisValueObject>> analysesByExperiment = differentialExpressionAnalysisService.getAnalysesByExperiment(EntityUtils.getIds(Arrays.asList(ds1, ds2, ds3)));
    Collection<DiffExResultSetSummaryValueObject> resultSets = new HashSet<>();
    for (ExpressionExperimentDetailsValueObject evo : analysesByExperiment.keySet()) {
        for (DifferentialExpressionAnalysisValueObject deavo : analysesByExperiment.get(evo)) {
            resultSets.addAll(deavo.getResultSets());
        }
    }
    Map<Long, Map<Long, DiffExprGeneSearchResult>> ffResultSets = differentialExpressionResultService.findDiffExAnalysisResultIdsInResultSets(resultSets, Collections.singletonList(g.getId()));
    assertNotNull(ffResultSets);
    assertTrue(!ffResultSets.isEmpty());
}
Also used : Gene(ubic.gemma.model.genome.Gene) ExpressionExperimentDetailsValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject)

Example 10 with ExpressionExperimentDetailsValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject in project Gemma by PavlidisLab.

the class CuratableValueObjectTest method testCuratableValueObjectInteraction.

@Test
public void testCuratableValueObjectInteraction() {
    ArrayDesignValueObject adVO = this.arrayDesignService.loadValueObject(arrayDesign);
    assertFalse(adVO.getTroubled());
    ExpressionExperimentDetailsValueObject eeDVO = new ExpressionExperimentDetailsValueObject(this.expressionExperimentService.loadValueObject(expressionExperiment));
    eeDVO.setArrayDesigns(Collections.singleton(adVO));
    assertFalse(eeDVO.getTroubled());
    assertFalse(eeDVO.getActuallyTroubled());
    assertFalse(eeDVO.getPlatformTroubled());
    // Make array design troubled
    this.curationDetailsService.update(this.arrayDesign, AuditEvent.Factory.newInstance(new Date(), AuditAction.UPDATE, "testing trouble update on platform", "trouble update details", null, TroubledStatusFlagEvent.Factory.newInstance()));
    adVO = this.arrayDesignService.loadValueObject(arrayDesign);
    assertTrue(adVO.getTroubled());
    eeDVO = new ExpressionExperimentDetailsValueObject(this.expressionExperimentService.loadValueObject(expressionExperiment));
    eeDVO.setArrayDesigns(Collections.singleton(adVO));
    assertTrue(eeDVO.getTroubled());
    assertFalse(eeDVO.getActuallyTroubled());
    assertTrue(eeDVO.getPlatformTroubled());
    // Make expression experiment troubled
    this.curationDetailsService.update(this.expressionExperiment, AuditEvent.Factory.newInstance(new Date(), AuditAction.UPDATE, "testing trouble update on expression experiment", "trouble update details", null, TroubledStatusFlagEvent.Factory.newInstance()));
    eeDVO = new ExpressionExperimentDetailsValueObject(this.expressionExperimentService.loadValueObject(expressionExperiment));
    eeDVO.setArrayDesigns(Collections.singleton(adVO));
    assertTrue(eeDVO.getTroubled());
    assertTrue(eeDVO.getActuallyTroubled());
    assertTrue(eeDVO.getPlatformTroubled());
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) ExpressionExperimentDetailsValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject) Date(java.util.Date) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Aggregations

ExpressionExperimentDetailsValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject)11 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)4 StopWatch (org.apache.commons.lang3.time.StopWatch)3 Test (org.junit.Test)3 BaseSpringWebTest (ubic.gemma.web.util.BaseSpringWebTest)3 Element (net.sf.ehcache.Element)2 ArrayDesignValueObject (ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)2 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 StopWatch (org.springframework.util.StopWatch)1 Condition (ubic.gemma.core.tasks.visualization.DifferentialExpressionGenesConditionsValueObject.Condition)1 DifferentialExpressionAnalysisValueObject (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisValueObject)1 Auditable (ubic.gemma.model.common.Auditable)1 AuditEvent (ubic.gemma.model.common.auditAndSecurity.AuditEvent)1 ExperimentalFactorValueObject (ubic.gemma.model.expression.experiment.ExperimentalFactorValueObject)1 FactorValueValueObject (ubic.gemma.model.expression.experiment.FactorValueValueObject)1 Gene (ubic.gemma.model.genome.Gene)1