Search in sources :

Example 6 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class OneWayAnovaAnalyzerTest method testOneWayAnova.

/**
 * Tests the OneWayAnova method.
 */
@Test
public void testOneWayAnova() throws Exception {
    if (!connected) {
        log.warn("Could not establish R connection.  Skipping test ...");
        return;
    }
    super.configureTestDataForOneWayAnova();
    this.configureMocks();
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    Collection<ExperimentalFactor> factors = expressionExperiment.getExperimentalDesign().getExperimentalFactors();
    config.setFactorsToInclude(factors);
    Collection<DifferentialExpressionAnalysis> expressionAnalyses = analyzer.run(expressionExperiment, config);
    DifferentialExpressionAnalysis expressionAnalysis = expressionAnalyses.iterator().next();
    Collection<ExpressionAnalysisResultSet> resultSets = expressionAnalysis.getResultSets();
    ExpressionAnalysisResultSet resultSet = resultSets.iterator().next();
    int numResults = resultSet.getResults().size();
    assertEquals(100, numResults);
/*
         * Check we got the histograms - only happens during persisting.
         */
// File dir = DifferentialExpressionFileUtils.getBaseDifferentialDirectory( expressionExperiment.getShortName()
// );
// 
// File histFile = new File( dir, expressionExperiment.getShortName() + ".pvalues"
// + DifferentialExpressionFileUtils.PVALUE_DIST_SUFFIX );
// assertTrue( histFile.exists() );
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet) Test(org.junit.Test)

Example 7 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class OneWayAnovaAnalyzerTest method testOnewayAnovaB.

@Test
public void testOnewayAnovaB() throws Exception {
    if (!connected) {
        log.warn("Could not establish R connection.  Skipping test ...");
        return;
    }
    super.configureTestDataForOneWayAnova();
    this.configureMocks();
    /*
         * Add a factor with three levels
         */
    ExperimentalFactor experimentalFactorC = ExperimentalFactor.Factory.newInstance();
    experimentalFactorC.setName("groupash");
    experimentalFactorC.setId(5399424551L);
    experimentalFactorC.setType(FactorType.CATEGORICAL);
    expressionExperiment.getExperimentalDesign().getExperimentalFactors().add(experimentalFactorC);
    FactorValue controlGroup = null;
    for (int i = 1; i <= 3; i++) {
        FactorValue f = FactorValue.Factory.newInstance();
        f.setId(2000L + i);
        if (i != 2) {
            f.setValue(i + "_group");
        } else {
            f.setValue("control_group");
            controlGroup = f;
        }
        f.setExperimentalFactor(experimentalFactorC);
        experimentalFactorC.getFactorValues().add(f);
    }
    List<FactorValue> facV = new ArrayList<>(experimentalFactorC.getFactorValues());
    for (int i = 0; i < 8; i++) {
        super.biomaterials.get(i).getFactorValues().add(facV.get(i % 3));
    }
    Collection<ExperimentalFactor> factors = new HashSet<>();
    factors.add(experimentalFactorC);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    config.setFactorsToInclude(factors);
    Collection<DifferentialExpressionAnalysis> expressionAnalyses = analyzer.run(expressionExperiment, config);
    DifferentialExpressionAnalysis expressionAnalysis = expressionAnalyses.iterator().next();
    Collection<ExpressionAnalysisResultSet> resultSets = expressionAnalysis.getResultSets();
    ExpressionAnalysisResultSet resultSet = resultSets.iterator().next();
    int numResults = resultSet.getResults().size();
    assertEquals(100, numResults);
    assertEquals(controlGroup, resultSet.getBaselineGroup());
    factors = resultSet.getExperimentalFactors();
    assertEquals(1, factors.size());
    for (DifferentialExpressionAnalysisResult r : resultSet.getResults()) {
        CompositeSequence probe = r.getProbe();
        Double pvalue = r.getPvalue();
        // if ( pvalue != null ) assertNotNull( stat );
        assertNotNull(probe);
        switch(probe.getName()) {
            case "probe_98":
                assertEquals(0.1604, pvalue, 0.001);
                break;
            case "probe_10":
                assertEquals(0.8014, pvalue, 0.0001);
                break;
            case "probe_4":
                assertEquals(0.6531, pvalue, 0.0001);
                break;
        }
    }
}
Also used : FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) ArrayList(java.util.ArrayList) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) DifferentialExpressionAnalysisResult(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class AclAdviceTest method testAnalysisAcl.

@Test
public void testAnalysisAcl() {
    /*
         * Create an analysis, add a result set, persist. Problem is: what if we do things in a funny order. Must call
         * update on the Analysis.
         */
    ExpressionExperiment ee = this.getTestPersistentCompleteExpressionExperiment(false);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    DifferentialExpressionAnalysis diffExpressionAnalysis = config.toAnalysis();
    ExpressionAnalysisResultSet resultSet = ExpressionAnalysisResultSet.Factory.newInstance();
    resultSet.setAnalysis(diffExpressionAnalysis);
    resultSet.setExperimentalFactors(ee.getExperimentalDesign().getExperimentalFactors());
    diffExpressionAnalysis.getResultSets().add(resultSet);
    diffExpressionAnalysis.setExperimentAnalyzed(ee);
    diffExpressionAnalysis = differentialExpressionAnalyzerService.persistAnalysis(ee, diffExpressionAnalysis, config);
    aclTestUtils.checkHasAcl(ee);
    aclTestUtils.checkHasAcl(diffExpressionAnalysis);
    aclTestUtils.checkLacksAcl(resultSet);
    aclTestUtils.checkHasAces(ee);
    aclTestUtils.checkLacksAces(diffExpressionAnalysis);
    aclTestUtils.checkHasAclParent(diffExpressionAnalysis, ee);
}
Also used : DifferentialExpressionAnalysisConfig(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalysisConfig) 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 9 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class DifferentialExpressionAnalysisServiceTest method testFindByInvestigation.

@Test
public void testFindByInvestigation() {
    Collection<DifferentialExpressionAnalysis> results = analysisService.findByInvestigation(e1);
    assertEquals(1, results.size());
    DifferentialExpressionAnalysis dea = results.iterator().next();
    assertEquals(dea1_name, dea.getName());
    results = analysisService.findByInvestigation(e2);
    assertEquals(1, results.size());
    dea = results.iterator().next();
    assertEquals(dea2_name, dea.getName());
    results = analysisService.findByInvestigation(e3);
    assertEquals(2, results.size());
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 10 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class DifferentialExpressionAnalysisServiceTest method setup.

@Before
public void setup() {
    e1 = ExpressionExperiment.Factory.newInstance();
    e1.setShortName(RandomStringUtils.randomAlphabetic(6));
    e1 = expressionExperimentService.create(e1);
    e2 = ExpressionExperiment.Factory.newInstance();
    e2.setShortName(RandomStringUtils.randomAlphabetic(6));
    e2 = expressionExperimentService.create(e2);
    e3 = ExpressionExperiment.Factory.newInstance();
    e3.setShortName(RandomStringUtils.randomAlphabetic(6));
    e3 = expressionExperimentService.create(e3);
    ExpressionExperiment e4 = ExpressionExperiment.Factory.newInstance();
    e4.setShortName(RandomStringUtils.randomAlphabetic(6));
    expressionExperimentService.create(e4);
    // //////////////////
    DifferentialExpressionAnalysis eAnalysis1 = DifferentialExpressionAnalysis.Factory.newInstance();
    eAnalysis1.setExperimentAnalyzed(e1);
    dea1_name = RandomStringUtils.randomAlphabetic(6);
    eAnalysis1.setName(dea1_name);
    eAnalysis1.setDescription("An analysis Test 1");
    analysisService.create(eAnalysis1);
    // ///////////////
    DifferentialExpressionAnalysis eAnalysis2 = DifferentialExpressionAnalysis.Factory.newInstance();
    eAnalysis2.setExperimentAnalyzed(e2);
    dea2_name = RandomStringUtils.randomAlphabetic(6);
    eAnalysis2.setName(dea2_name);
    eAnalysis2.setDescription("An analysis Test 2");
    analysisService.create(eAnalysis2);
    // /////////////
    DifferentialExpressionAnalysis eAnalysis3 = DifferentialExpressionAnalysis.Factory.newInstance();
    eAnalysis3.setExperimentAnalyzed(e3);
    this.testAnalysisName = RandomStringUtils.randomAlphabetic(6);
    eAnalysis3.setName(testAnalysisName);
    eAnalysis3.setDescription("An analysis Test 3");
    analysisService.create(eAnalysis3);
    // ////
    DifferentialExpressionAnalysis eAnalysis4 = DifferentialExpressionAnalysis.Factory.newInstance();
    eAnalysis4.setExperimentAnalyzed(e3);
    testEESetName = RandomStringUtils.randomAlphabetic(6);
    eAnalysis4.setName(testEESetName);
    eAnalysis4.setDescription("An analysis Test 4");
    analysisService.create(eAnalysis4);
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) Before(org.junit.Before)

Aggregations

DifferentialExpressionAnalysis (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)53 Test (org.junit.Test)26 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)26 ExpressionAnalysisResultSet (ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)21 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)13 DifferentialExpressionAnalysisResult (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult)11 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)8 HashSet (java.util.HashSet)5 ContrastResult (ubic.gemma.model.analysis.expression.diff.ContrastResult)5 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)5 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)5 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)5 AnalysisType (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType)4 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Transactional (org.springframework.transaction.annotation.Transactional)3 DifferentialExpressionAnalysisConfig (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalysisConfig)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 DoubleMatrixReader (ubic.basecode.io.reader.DoubleMatrixReader)2 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)2