use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class DiffExWithInvalidInteraction2Test method test.
@Test
public void test() {
ee = expressionExperimentService.thawLite(ee);
Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
// includes batch
assertEquals(3, factors.size());
for (BioAssay ba : ee.getBioAssays()) {
assertEquals(3, ba.getSampleUsed().getFactorValues().size());
}
ExperimentalFactor strain = null;
ExperimentalFactor cell_type = null;
for (ExperimentalFactor ef : factors) {
if (ef.getCategory().getValue().equals("strain")) {
strain = ef;
} else if (ef.getCategory().getValue().equals("cell type")) {
cell_type = ef;
}
}
assertNotNull(cell_type);
assertNotNull(strain);
DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
config.getFactorsToInclude().add(strain);
config.getFactorsToInclude().add(cell_type);
config.addInteractionToInclude(cell_type, strain);
Collection<DifferentialExpressionAnalysis> result = analyzer.runDifferentialExpressionAnalyses(ee, config);
assertEquals(1, result.size());
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class DiffExWithInvalidInteraction2Test method setup.
@Before
public void setup() throws Exception {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(FileTools.resourceToPath("/data/analysis/expression")));
try {
Collection<?> results = geoService.fetchAndLoad("GSE37301", 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/7737_GSE37301_expdesign.data.txt"));
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactor 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.expression.experiment.ExperimentalFactor 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.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class AuditAdviceTest method checkEEAuditTrails.
private void checkEEAuditTrails(ExpressionExperiment ee, Collection<Long> trailIds, Collection<Long> eventIds) {
this.checkAuditTrail(ee, trailIds, eventIds);
for (BioAssay ba : ee.getBioAssays()) {
this.checkAuditTrail(ba, trailIds, eventIds);
BioMaterial bm = ba.getSampleUsed();
this.checkAuditTrail(bm, trailIds, eventIds);
for (Characteristic c : bm.getCharacteristics()) {
this.checkAuditTrail(c, trailIds, eventIds);
}
for (Treatment t : bm.getTreatments()) {
this.checkAuditTrail(t, trailIds, eventIds);
this.checkAuditTrail(t.getAction(), trailIds, eventIds);
// for ( CompoundMeasurement cm : t.getCompoundMeasurements() ) {
// checkAuditTrail( cm.getCompound().getCompoundIndices(), trailIds, eventIds );
// }
}
}
Collection<ExperimentalFactor> experimentalFactors = ee.getExperimentalDesign().getExperimentalFactors();
assertTrue(experimentalFactors.size() > 0);
for (ExperimentalFactor ef : experimentalFactors) {
this.checkAuditTrail(ef, trailIds, eventIds);
for (FactorValue fv : ef.getFactorValues()) {
for (Characteristic c : fv.getCharacteristics()) {
this.checkAuditTrail(c, trailIds, eventIds);
}
}
}
}
Aggregations