Search in sources :

Example 1 with DiffExpressionSelectedFactorCommand

use of ubic.gemma.core.analysis.expression.diff.DiffExpressionSelectedFactorCommand in project Gemma by PavlidisLab.

the class DEDVController method getProbeDiffExValidation.

/**
 * This is probably no longer being really used?
 */
private Map<Long, Collection<DifferentialExpressionValueObject>> getProbeDiffExValidation(Collection<Gene> genes, Double threshold, Collection<DiffExpressionSelectedFactorCommand> factorMap) {
    if (factorMap == null)
        throw new IllegalArgumentException("Factor information is missing, please make sure factors are selected.");
    Map<Long, Collection<DifferentialExpressionValueObject>> validatedProbes = new HashMap<>();
    Collection<Long> wantedFactors = new HashSet<>();
    for (DiffExpressionSelectedFactorCommand factor : factorMap) {
        wantedFactors.add(factor.getEfId());
    }
    for (Gene gene : genes) {
        Collection<DifferentialExpressionValueObject> differentialExpression = geneDifferentialExpressionService.getDifferentialExpression(gene, threshold, factorMap);
        for (DifferentialExpressionValueObject diffVo : differentialExpression) {
            assert diffVo.getCorrP() <= threshold;
            Long eeId = diffVo.getExpressionExperiment().getId();
            if (!validatedProbes.containsKey(eeId)) {
                validatedProbes.put(eeId, new HashSet<DifferentialExpressionValueObject>());
            }
            Collection<ExperimentalFactorValueObject> factors = diffVo.getExperimentalFactors();
            for (ExperimentalFactorValueObject fac : factors) {
                if (wantedFactors.contains(fac.getId())) {
                    validatedProbes.get(eeId).add(diffVo);
                }
            }
        }
    }
    return validatedProbes;
}
Also used : DifferentialExpressionValueObject(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionValueObject) DiffExpressionSelectedFactorCommand(ubic.gemma.core.analysis.expression.diff.DiffExpressionSelectedFactorCommand) Gene(ubic.gemma.model.genome.Gene)

Example 2 with DiffExpressionSelectedFactorCommand

use of ubic.gemma.core.analysis.expression.diff.DiffExpressionSelectedFactorCommand in project Gemma by PavlidisLab.

the class DifferentialExpressionSearchController method getDifferentialExpressionMetaAnalysis.

/**
 * Returns the results of the meta-analysis.
 */
private DifferentialExpressionMetaAnalysisValueObject getDifferentialExpressionMetaAnalysis(Long geneId, Collection<DiffExpressionSelectedFactorCommand> selectedFactors, double threshold) {
    Gene g = geneService.load(geneId);
    if (g == null) {
        log.warn("No Gene with id=" + geneId);
        return null;
    }
    /* find experiments that have had the diff cli run on it and have the gene g (analyzed) - security filtered. */
    Collection<BioAssaySet> experimentsAnalyzed = differentialExpressionAnalysisService.findExperimentsWithAnalyses(g);
    if (experimentsAnalyzed.size() == 0) {
        throw new EntityNotFoundException("No results were found: no experiment analyzed those genes");
    }
    /* the 'chosen' factors (and their associated experiments) */
    Map<Long, Long> eeFactorsMap = new HashMap<>();
    for (DiffExpressionSelectedFactorCommand selectedFactor : selectedFactors) {
        Long eeId = selectedFactor.getEeId();
        eeFactorsMap.put(eeId, selectedFactor.getEfId());
        if (log.isDebugEnabled())
            log.debug(eeId + " --> " + selectedFactor.getEfId());
    }
    /*
         * filter experiments that had the diff cli run on it and are in the scope of eeFactorsMap eeIds
         * (active/available to the user).
         */
    Collection<BioAssaySet> activeExperiments;
    if (eeFactorsMap.keySet() == null || eeFactorsMap.isEmpty()) {
        activeExperiments = experimentsAnalyzed;
    } else {
        activeExperiments = new ArrayList<>();
        for (BioAssaySet ee : experimentsAnalyzed) {
            if (eeFactorsMap.keySet().contains(ee.getId())) {
                activeExperiments.add(ee);
            }
        }
    }
    if (activeExperiments.isEmpty()) {
        throw new EntityNotFoundException("No results were found: none of the experiments selected analyzed those genes");
    }
    return geneDifferentialExpressionService.getDifferentialExpressionMetaAnalysis(threshold, g, eeFactorsMap, activeExperiments);
}
Also used : DiffExpressionSelectedFactorCommand(ubic.gemma.core.analysis.expression.diff.DiffExpressionSelectedFactorCommand) Gene(ubic.gemma.model.genome.Gene) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException)

Aggregations

DiffExpressionSelectedFactorCommand (ubic.gemma.core.analysis.expression.diff.DiffExpressionSelectedFactorCommand)2 Gene (ubic.gemma.model.genome.Gene)2 DifferentialExpressionValueObject (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionValueObject)1 EntityNotFoundException (ubic.gemma.web.util.EntityNotFoundException)1