Search in sources :

Example 21 with ExperimentalFactor

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

the class LowVarianceDataTest method setup.

@Before
public void setup() throws Exception {
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(FileTools.resourceToPath("/data/analysis/expression")));
    try {
        Collection<?> results = geoService.fetchAndLoad("GSE19420", false, true, false);
        ee = (ExpressionExperiment) results.iterator().next();
    } catch (AlreadyExistsInSystemException e) {
        ee = (ExpressionExperiment) ((Collection<?>) e.getData()).iterator().next();
    }
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> toremove = new HashSet<>(ee.getExperimentalDesign().getExperimentalFactors());
    for (ExperimentalFactor ef : toremove) {
        experimentalFactorService.delete(ef);
        ee.getExperimentalDesign().getExperimentalFactors().remove(ef);
    }
    expressionExperimentService.update(ee);
    processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    ee = expressionExperimentService.thaw(ee);
    designImporter.importDesign(ee, this.getClass().getResourceAsStream("/data/analysis/expression/2976_GSE19420_expdesign.data.txt"));
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) Collection(java.util.Collection) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 22 with ExperimentalFactor

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

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

the class SubsettedAnalysis2Test method setup.

@Before
public void setup() throws Exception {
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(FileTools.resourceToPath("/data/analysis/expression/gse12991short")));
    try {
        Collection<?> results = geoService.fetchAndLoad("GSE12991", false, true, false);
        ee = (ExpressionExperiment) results.iterator().next();
    } catch (AlreadyExistsInSystemException e) {
        ee = (ExpressionExperiment) ((Collection<?>) e.getData()).iterator().next();
    }
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> toremove = new HashSet<>(ee.getExperimentalDesign().getExperimentalFactors());
    for (ExperimentalFactor ef : toremove) {
        experimentalFactorService.delete(ef);
        ee.getExperimentalDesign().getExperimentalFactors().remove(ef);
    }
    expressionExperimentService.update(ee);
    processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    ee = expressionExperimentService.thaw(ee);
    designImporter.importDesign(ee, this.getClass().getResourceAsStream("/data/analysis/expression/gse12991short/6283_GSE12991_expdesign.data.txt"));
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) Collection(java.util.Collection) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 24 with ExperimentalFactor

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

the class TwoWayAnovaWithInteractionTest2 method checkResults.

public void checkResults(DifferentialExpressionAnalysis analysis) {
    Collection<ExpressionAnalysisResultSet> resultSets = analysis.getResultSets();
    assertEquals(3, resultSets.size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (ExpressionAnalysisResultSet rs : resultSets) {
        boolean interaction = false;
        boolean sexFactor = false;
        Collection<DifferentialExpressionAnalysisResult> results = rs.getResults();
        if (rs.getExperimentalFactors().size() == 1) {
            ExperimentalFactor factor = rs.getExperimentalFactors().iterator().next();
            sexFactor = factor.getName().equals("Sex");
        } else {
            interaction = true;
        }
        assertEquals(8, results.size());
        /*
             * Test values here are computed in R, using anova(lm(unlist(expData["205969_at",])~Treatment*Sex )) etc.
             */
        for (DifferentialExpressionAnalysisResult r : results) {
            CompositeSequence probe = r.getProbe();
            Double pvalue = r.getPvalue();
            switch(probe.getName()) {
                case "205969_at":
                    if (sexFactor) {
                        found1 = true;
                        assertEquals(0.3333, pvalue, 0.001);
                    } else if (interaction) {
                        found2 = true;
                        assertEquals(0.8480, pvalue, 0.001);
                    } else {
                        found3 = true;
                        assertEquals(0.1323, pvalue, 0.001);
                    }
                    break;
                case "217757_at":
                    if (interaction) {
                        found4 = true;
                        assertEquals(0.7621, pvalue, 0.001);
                    }
                    break;
                case "constant":
                    fail("Should not have found a result for constant probe");
                    break;
            }
        }
    }
    assertTrue(found1 && found2 && found3 && found4);
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysisResult(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)

Example 25 with ExperimentalFactor

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

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