Search in sources :

Example 1 with AnalysisType

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

the class LowVarianceDataTest method test.

@Test
public void test() {
    ee = expressionExperimentService.thawLite(ee);
    AnalysisType aa = analysisService.determineAnalysis(ee, ee.getExperimentalDesign().getExperimentalFactors(), null, true);
    assertEquals(AnalysisType.TWO_WAY_ANOVA_NO_INTERACTION, aa);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    assertEquals(2, factors.size());
    config.setAnalysisType(aa);
    config.setFactorsToInclude(factors);
    analyzer = this.getBean(DiffExAnalyzer.class);
    Collection<DifferentialExpressionAnalysis> result = analyzer.run(ee, config);
    assertEquals(1, result.size());
    DifferentialExpressionAnalysis analysis = result.iterator().next();
    this.checkResults(analysis);
}
Also used : AnalysisType(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 2 with AnalysisType

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

the class TwoWayAnovaWithInteractionTest2 method test.

/*
     * NOTE I added a constant probe to this data after I set this up.
     *
     * <pre>
     * expMatFile &lt;- "GSE8441_expmat_8probes.txt"
     * expDesignFile &lt;- "606_GSE8441_expdesign.data.txt"
     * expMat &lt;- log2(read.table(expMatFile, header = TRUE, row.names = 1, sep = "\t", quote=""))
     * expDesign &lt;- read.table(expDesignFile, header = TRUE, row.names = 1, sep = "\t", quote="")
     *
     * expData &lt;- expMat[rownames(expDesign)]
     *
     * names(expData) == row.names(expDesign)
     * attach(expDesign)
     * lf&lt;-lm(unlist(expData["217757_at",])~Treatment*Sex )
     * summary(lf)
     * anova(lf)
     *
     * summary(lm(unlist(expData["202851_at",])~Treatment*Sex ))
     * anova(lm(unlist(expData["202851_at",])~Treatment*Sex ))
     *
     * # etc.
     * </pre>
     */
@Test
public void test() {
    AnalysisType aa = analysisService.determineAnalysis(ee, ee.getExperimentalDesign().getExperimentalFactors(), null, true);
    assertEquals(AnalysisType.TWO_WAY_ANOVA_WITH_INTERACTION, aa);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    assertEquals(2, factors.size());
    config.setAnalysisType(aa);
    config.setFactorsToInclude(factors);
    config.getInteractionsToInclude().add(factors);
    analyzer = this.getBean(DiffExAnalyzer.class);
    Collection<DifferentialExpressionAnalysis> result = analyzer.run(ee, config);
    assertEquals(1, result.size());
    DifferentialExpressionAnalysis analysis = result.iterator().next();
    this.checkResults(analysis);
    Collection<DifferentialExpressionAnalysis> persistent = differentialExpressionAnalyzerService.runDifferentialExpressionAnalyses(ee, config);
    DifferentialExpressionAnalysis refetched = differentialExpressionAnalysisService.load(persistent.iterator().next().getId());
    differentialExpressionAnalysisService.thaw(refetched);
    for (ExpressionAnalysisResultSet ears : refetched.getResultSets()) {
        differentialExpressionResultService.thaw(ears);
    }
    this.checkResults(refetched);
    differentialExpressionAnalyzerService.redoAnalysis(ee, refetched, true);
}
Also used : AnalysisType(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 3 with AnalysisType

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

the class ContinuousVariableDiffExTest method test.

@Test
public void test() {
    AnalysisType aa = analysisService.determineAnalysis(ee, ee.getExperimentalDesign().getExperimentalFactors(), null, true);
    assertEquals(AnalysisType.GENERICLM, aa);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    assertEquals(1, factors.size());
    config.setAnalysisType(aa);
    config.setFactorsToInclude(factors);
    analyzer = this.getBean(DiffExAnalyzer.class);
    Collection<DifferentialExpressionAnalysis> result = analyzer.run(ee, config);
    assertEquals(1, result.size());
    DifferentialExpressionAnalysis analysis = result.iterator().next();
    assertNotNull(analysis);
    Map<ExperimentalFactor, FactorValue> baselineLevels = ExpressionDataMatrixColumnSort.getBaselineLevels(ee.getExperimentalDesign().getExperimentalFactors());
    assertEquals(1, baselineLevels.size());
    FactorValue fv = baselineLevels.values().iterator().next();
    assertEquals(24.0, Double.parseDouble(fv.getMeasurement().getValue()), 0.0001);
// checkResults( analysis );
}
Also used : AnalysisType(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 4 with AnalysisType

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

the class AnalysisSelectionAndExecutionServiceImpl method determineAnalysis.

/**
 * FIXME this should probably deal with the case of outliers and also the {@link LinearModelAnalyzer}'s
 * EXCLUDE_CHARACTERISTICS_VALUES
 *
 * @return selected type of analysis such as t-test, two-way ANOVA, etc.
 */
@Override
public AnalysisType determineAnalysis(BioAssaySet bioAssaySet, DifferentialExpressionAnalysisConfig config) {
    if (config.getFactorsToInclude().isEmpty()) {
        throw new IllegalArgumentException("Must provide at least one factor");
    }
    if (config.getAnalysisType() == null) {
        AnalysisType type = this.determineAnalysis(bioAssaySet, config.getFactorsToInclude(), config.getSubsetFactor(), true);
        if (type.equals(AnalysisType.TWO_WAY_ANOVA_NO_INTERACTION)) {
            /*
                 * Ensure the config does not have interactions.
                 */
            AnalysisSelectionAndExecutionServiceImpl.log.info("Any interaction term will be dropped from the configuration as it " + "cannot be analyzed (no replicates? block incomplete?)");
            config.getInteractionsToInclude().clear();
        // config.setAnalysisType( type ); // don't need this side-effect.
        }
        config.setAnalysisType(type);
        return type;
    }
    if (config.getSubsetFactor() != null) {
        /*
             * Basically have to make the subsets, and then validate the choice of model on each of those. The following
             * just assumes that we're going to do something very simple.
             */
        return AnalysisType.GENERICLM;
    }
    switch(config.getAnalysisType()) {
        case OWA:
            if (config.getFactorsToInclude().size() != 1) {
                throw new IllegalArgumentException("Cannot run One-way ANOVA on more than one factor");
            }
            return AnalysisType.OWA;
        case TWO_WAY_ANOVA_WITH_INTERACTION:
            this.validateFactorsForTwoWayANOVA(config.getFactorsToInclude());
            if (!DifferentialExpressionAnalysisUtil.blockComplete(bioAssaySet, config.getFactorsToInclude())) {
                throw new IllegalArgumentException("Experimental design must be block complete to run Two-way ANOVA with interactions");
            }
            return AnalysisType.TWO_WAY_ANOVA_WITH_INTERACTION;
        case TWO_WAY_ANOVA_NO_INTERACTION:
            // NO interactions.
            this.validateFactorsForTwoWayANOVA(config.getFactorsToInclude());
            return AnalysisType.TWO_WAY_ANOVA_NO_INTERACTION;
        case TTEST:
            if (config.getFactorsToInclude().size() != 1) {
                throw new IllegalArgumentException("Cannot run t-test on more than one factor ");
            }
            for (ExperimentalFactor experimentalFactor : config.getFactorsToInclude()) {
                if (experimentalFactor.getFactorValues().size() < 2) {
                    throw new IllegalArgumentException("Need at least two levels per factor to run two-sample t-test");
                }
            }
            return AnalysisType.TTEST;
        case OSTTEST:
            // one sample t-test.
            if (config.getFactorsToInclude().size() != 1) {
                throw new IllegalArgumentException("Cannot run t-test on more than one factor ");
            }
            for (ExperimentalFactor experimentalFactor : config.getFactorsToInclude()) {
                if (experimentalFactor.getFactorValues().size() != 1) {
                    throw new IllegalArgumentException("Need only one level for the factor for one-sample t-test");
                }
            }
            return AnalysisType.OSTTEST;
        case GENERICLM:
            return AnalysisType.GENERICLM;
        default:
            throw new IllegalArgumentException("Analyses of that type (" + config.getAnalysisType() + ")are not yet supported");
    }
}
Also used : AnalysisType(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType)

Example 5 with AnalysisType

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

the class TwoWayAnovaWithInteractionsTest2 method test.

@Test
public void test() {
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    assertEquals(2, factors.size());
    for (BioAssay ba : ee.getBioAssays()) {
        assertEquals(2, ba.getSampleUsed().getFactorValues().size());
    }
    AnalysisType aa = analysisService.determineAnalysis(ee, ee.getExperimentalDesign().getExperimentalFactors(), null, true);
    assertEquals(AnalysisType.TWO_WAY_ANOVA_WITH_INTERACTION, aa);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    config.setAnalysisType(aa);
    config.setFactorsToInclude(factors);
    config.addInteractionToInclude(factors);
    analyzer = this.getBean(DiffExAnalyzer.class);
    Collection<DifferentialExpressionAnalysis> result = analyzer.run(ee, config);
    assertEquals(1, result.size());
    DifferentialExpressionAnalysis analysis = result.iterator().next();
    assertNotNull(analysis);
    assertEquals(3, analysis.getResultSets().size());
}
Also used : AnalysisType(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Aggregations

AnalysisType (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType)6 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)5 Test (org.junit.Test)4 DifferentialExpressionAnalysis (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)4 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)1 ExpressionAnalysisResultSet (ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)1 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)1 ExperimentalFactorValueObject (ubic.gemma.model.expression.experiment.ExperimentalFactorValueObject)1 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)1 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)1