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"));
}
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);
}
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"));
}
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);
}
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 <- "GSE8441_expmat_8probes.txt"
* expDesignFile <- "606_GSE8441_expdesign.data.txt"
* expMat <- log2(read.table(expMatFile, header = TRUE, row.names = 1, sep = "\t", quote=""))
* expDesign <- read.table(expDesignFile, header = TRUE, row.names = 1, sep = "\t", quote="")
*
* expData <- expMat[rownames(expDesign)]
*
* names(expData) == row.names(expDesign)
* attach(expDesign)
* lf<-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);
}
Aggregations