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() );
}
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;
}
}
}
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);
}
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());
}
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);
}
Aggregations