use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class ExperimentalDesignImporterTestB method testParseLoadDelete.
@Test
public final void testParseLoadDelete() throws Exception {
try (InputStream is = this.getClass().getResourceAsStream("/data/loader/expression/gill2007temperatureGemmaAnnotationData.txt")) {
experimentalDesignImporter.importDesign(ee, is);
}
this.checkResults();
this.aclTestUtils.checkEEAcls(ee);
ee = this.expressionExperimentService.load(ee.getId());
ee = expressionExperimentService.thawLite(ee);
int s = ee.getExperimentalDesign().getExperimentalFactors().size();
ExperimentalFactor toDelete = ee.getExperimentalDesign().getExperimentalFactors().iterator().next();
experimentalFactorService.delete(toDelete);
ee = this.expressionExperimentService.load(ee.getId());
ee = expressionExperimentService.thawLite(ee);
assertEquals(s - 1, ee.getExperimentalDesign().getExperimentalFactors().size());
for (BioAssay ba : ee.getBioAssays()) {
BioMaterial bm = ba.getSampleUsed();
for (FactorValue fv : bm.getFactorValues()) {
assertTrue(!fv.getExperimentalFactor().equals(toDelete));
}
}
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class DiffExMetaAnalyzerServiceImpl method validate.
private void validate(ExpressionAnalysisResultSet rs) {
if (rs.getExperimentalFactors().size() > 1) {
throw new IllegalArgumentException("Cannot do a meta-analysis on interaction terms");
}
ExperimentalFactor factor = rs.getExperimentalFactors().iterator().next();
/*
* We need to check this just in the subset of samples actually used.
*/
BioAssaySet experimentAnalyzed = rs.getAnalysis().getExperimentAnalyzed();
assert experimentAnalyzed != null;
if (experimentAnalyzed instanceof ExpressionExperimentSubSet) {
ExpressionExperimentSubSet eesubset = (ExpressionExperimentSubSet) experimentAnalyzed;
Collection<FactorValue> factorValuesUsed = expressionExperimentSubSetService.getFactorValuesUsed(eesubset, factor);
if (factorValuesUsed.size() > 2) {
throw new IllegalArgumentException("Cannot do a meta-analysis including a factor that has more than two levels: " + factor + " has " + factor.getFactorValues().size() + " levels from " + experimentAnalyzed);
}
} else {
if (factor.getFactorValues().size() > 2) {
/*
* Note that this doesn't account for continuous factors.
*/
throw new IllegalArgumentException("Cannot do a meta-analysis including a factor that has more than two levels: " + factor + " has " + factor.getFactorValues().size() + " levels from " + experimentAnalyzed);
}
}
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalysisConfig method toString.
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("# AnalysisType: ").append(this.analysisType).append("\n");
buf.append("# Factors: ").append(StringUtils.join(this.factorsToInclude, " "));
buf.append("\n");
if (this.subsetFactor != null) {
buf.append("# SubsetFactor: ").append(this.subsetFactor).append("\n");
} else if (this.subsetFactorValue != null) {
buf.append("# Subset analysis for ").append(this.subsetFactorValue);
}
if (!interactionsToInclude.isEmpty()) {
buf.append("# Interactions: ").append(StringUtils.join(interactionsToInclude, ":")).append("\n");
}
if (!baseLineFactorValues.isEmpty()) {
buf.append("# Baselines:\n");
for (ExperimentalFactor ef : baseLineFactorValues.keySet()) {
buf.append("# ").append(ef.getName()).append(": Baseline = ").append(baseLineFactorValues.get(ef)).append("\n");
}
}
if (this.ebayes) {
buf.append("# Empirical Bayes moderated statistics used\n");
}
return buf.toString();
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class BioAssayDimensionValueObject method makeDummyBioAssayDimension.
private BioAssayDimension makeDummyBioAssayDimension() {
assert this.id == null;
BioAssayDimension fakeBd = BioAssayDimension.Factory.newInstance("Placeholder representing: " + name, description, new ArrayList<BioAssay>());
Map<Long, ExperimentalFactor> fakeEfs = new HashMap<>();
for (BioAssayValueObject bav : this.bioAssays) {
BioAssay ba = BioAssay.Factory.newInstance();
ba.setId(bav.getId());
ba.setName(bav.getName());
ba.setDescription("Fake placeholder");
BioMaterial sampleUsed = BioMaterial.Factory.newInstance();
BioMaterialValueObject bmVo = bav.getSample();
assert bmVo != null;
sampleUsed.setId(bmVo.getId());
sampleUsed.setName(bmVo.getName());
sampleUsed.setDescription("Fake placeholder");
for (IdentifiableValueObject iVo : bmVo.getFactorValueObjects()) {
FactorValueValueObject fvVo = (FactorValueValueObject) iVo;
FactorValue fv = FactorValue.Factory.newInstance();
assert fvVo.getId() != null;
fv.setId(fvVo.getId());
assert fvVo.getValue() != null;
fv.setValue(fvVo.getValue());
Long efId = fvVo.getFactorId();
ExperimentalFactor ef;
if (fakeEfs.containsKey(efId)) {
ef = fakeEfs.get(efId);
} else {
ef = ExperimentalFactor.Factory.newInstance();
ef.setId(efId);
ef.setName(fvVo.getCategory());
ef.setType(fvVo.isMeasurement() ? FactorType.CONTINUOUS : FactorType.CATEGORICAL);
fakeEfs.put(efId, ef);
}
ef.getFactorValues().add(fv);
fv.setExperimentalFactor(ef);
sampleUsed.getFactorValues().add(fv);
}
ba.setSampleUsed(sampleUsed);
ArrayDesign ad = ArrayDesign.Factory.newInstance();
ArrayDesignValueObject adVo = bav.getArrayDesign();
assert adVo != null;
ad.setId(adVo.getId());
ad.setShortName(adVo.getShortName());
ad.setDescription("Fake placeholder");
ba.setArrayDesignUsed(ad);
fakeBd.getBioAssays().add(ba);
}
return fakeBd;
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class ExpressionAnalysisResultSet method toString.
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
for (DifferentialExpressionAnalysisResult dear : this.getResults()) {
int count = 0;
CompositeSequence cs = dear.getProbe();
buf.append(cs.getName()).append("\t");
for (BioSequence2GeneProduct bs2gp : cs.getBiologicalCharacteristic().getBioSequence2GeneProduct()) {
Gene g = bs2gp.getGeneProduct().getGene();
if (g != null) {
buf.append(bs2gp.getGeneProduct().getGene().getOfficialSymbol()).append(",");
count++;
}
}
if (count != 0)
// removing trailing ,
buf.deleteCharAt(buf.lastIndexOf(","));
buf.append("\t");
count = 0;
for (ExperimentalFactor ef : this.getExperimentalFactors()) {
buf.append(ef.getName()).append(",");
count++;
}
if (count != 0)
// removing trailing ,
buf.deleteCharAt(buf.lastIndexOf(","));
buf.append("\t");
buf.append(dear.getCorrectedPvalue()).append("\n");
}
return buf.toString();
}
Aggregations