Search in sources :

Example 86 with ExperimentalFactor

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

the class CharacteristicBrowserController method populateParentInformation.

private void populateParentInformation(AnnotationValueObject avo, Object parent) {
    if (parent == null) {
        avo.setParentLink("[Parent hidden or not available, " + avo.getObjectClass() + " ID=" + avo.getId() + "]");
    } else if (parent instanceof ExpressionExperiment) {
        ExpressionExperiment ee = (ExpressionExperiment) parent;
        avo.setParentName(String.format("Experiment: %s", ee.getName()));
        avo.setParentLink(AnchorTagUtil.getExpressionExperimentLink(ee.getId(), avo.getParentName()));
    } else if (parent instanceof BioMaterial) {
        BioMaterial bm = (BioMaterial) parent;
        avo.setParentName(String.format("BioMat: %s", bm.getName()));
        avo.setParentLink(AnchorTagUtil.getBioMaterialLink(bm.getId(), avo.getParentName()));
        ExpressionExperiment ee = expressionExperimentService.findByBioMaterial(bm);
        if (ee != null) {
            avo.setParentOfParentName(String.format("%s", ee.getName()));
            // avo.setParentOfParentDescription( ee.getDescription() );
            avo.setParentOfParentLink(AnchorTagUtil.getExpressionExperimentLink(ee.getId(), avo.getParentOfParentName()));
        } else {
            log.warn("Expression experiment for " + bm + " was null");
        }
    } else if (parent instanceof FactorValue) {
        FactorValue fv = (FactorValue) parent;
        avo.setParentDescription(String.format("FactorValue: %s « Exp.Factor: %s", (fv.getValue() == null ? "" : ": " + fv.getValue()), fv.getExperimentalFactor().getName()));
        ExpressionExperiment ee = experimentalDesignService.getExpressionExperiment(fv.getExperimentalFactor().getExperimentalDesign());
        avo.setParentOfParentName(String.format("Experimental Design for: %s", ee.getName()));
        avo.setParentOfParentLink(AnchorTagUtil.getExperimentalDesignLink(fv.getExperimentalFactor().getExperimentalDesign().getId(), avo.getParentName()) + " « " + AnchorTagUtil.getExpressionExperimentLink(ee.getId(), String.format("%s (%s)", StringUtils.abbreviate(ee.getName(), 80), ee.getShortName())));
    } else if (parent instanceof ExperimentalFactor) {
        ExperimentalFactor ef = (ExperimentalFactor) parent;
        avo.setParentLink(AnchorTagUtil.getExperimentalDesignLink(ef.getExperimentalDesign().getId(), "Exp Fac: " + ef.getName() + " (" + StringUtils.abbreviate(ef.getDescription(), 50) + ")"));
        ExpressionExperiment ee = experimentalDesignService.getExpressionExperiment(ef.getExperimentalDesign());
        avo.setParentOfParentName(String.format("%s (%s)", StringUtils.abbreviate(ee.getName(), 80), ee.getShortName()));
        avo.setParentOfParentLink(AnchorTagUtil.getExpressionExperimentLink(ee.getId(), avo.getParentOfParentName()));
    } else if (parent instanceof PhenotypeAssociation) {
        PhenotypeAssociation pa = (PhenotypeAssociation) parent;
        avo.setParentLink("PhenotypeAssoc: " + pa.getGene().getOfficialSymbol());
        avo.setParentDescription(pa.getId().toString());
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) PhenotypeAssociation(ubic.gemma.model.association.phenotype.PhenotypeAssociation) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 87 with ExperimentalFactor

use of ubic.gemma.model.expression.experiment.ExperimentalFactor 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)

Example 88 with ExperimentalFactor

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

the class ExpressionExperimentQCController method getCategories.

/**
 * Support method for writeDetailedFactorAnalysis
 *
 * @param categories map of factor ID to text value. Strings will be unique, but possibly abbreviated and/or munged.
 */
private void getCategories(Map<Long, ExperimentalFactor> efIdMap, Long efId, Map<Long, String> categories) {
    ExperimentalFactor ef = efIdMap.get(efId);
    if (ef == null)
        return;
    int maxCategoryLabelLength = 10;
    for (FactorValue fv : ef.getFactorValues()) {
        String value = fv.getValue();
        if (StringUtils.isBlank(value) || value.equals("null")) {
            for (Characteristic c : fv.getCharacteristics()) {
                if (StringUtils.isNotBlank(c.getValue())) {
                    if (StringUtils.isNotBlank(value)) {
                        value = value + "; " + c.getValue();
                    } else {
                        value = c.getValue();
                    }
                }
            }
        }
        if (StringUtils.isBlank(value)) {
            value = fv.toString() + "--??";
        }
        if (value.startsWith(ExperimentalDesignUtils.BATCH_FACTOR_NAME_PREFIX)) {
            value = value.replaceFirst(ExperimentalDesignUtils.BATCH_FACTOR_NAME_PREFIX, "");
        } else {
            value = StringUtils.abbreviate(value, maxCategoryLabelLength);
        }
        while (categories.values().contains(value)) {
            // make unique, kludge, will end up with string of ++++
            value = value + "+";
        }
        categories.put(fv.getId(), value);
    }
}
Also used : FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) Characteristic(ubic.gemma.model.common.description.Characteristic)

Aggregations

ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)88 Test (org.junit.Test)31 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)30 DifferentialExpressionAnalysis (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)26 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)22 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)18 HashSet (java.util.HashSet)17 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)17 ExpressionAnalysisResultSet (ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)16 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)14 DifferentialExpressionAnalysisResult (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult)12 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)11 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)10 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)10 Before (org.junit.Before)8 Collection (java.util.Collection)7 ContrastResult (ubic.gemma.model.analysis.expression.diff.ContrastResult)6 AnalysisType (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType)5 ExperimentalFactorValueObject (ubic.gemma.model.expression.experiment.ExperimentalFactorValueObject)5 InputStream (java.io.InputStream)4