use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class BatchInfoPopulationServiceImpl method getBatchDataFromRawFiles.
/**
* @param files Local copies of raw data files obtained from the data provider (e.g. GEO), adds audit event.
* @param ee ee
* @return boolean
*/
private boolean getBatchDataFromRawFiles(ExpressionExperiment ee, Collection<LocalFile> files) {
BatchInfoParser batchInfoParser = new BatchInfoParser();
ee = expressionExperimentService.thaw(ee);
if (ee.getAccession() == null) {
// in fact, currently it has to be from GEO.
throw new IllegalArgumentException("The experiment does not seem to be from an external source that would have batch information available.");
}
Map<BioMaterial, Date> dates = batchInfoParser.getBatchInfo(ee, files);
this.removeExistingBatchFactor(ee);
ExperimentalFactor factor = batchInfoPopulationHelperService.createBatchFactor(ee, dates);
if (!dates.isEmpty()) {
int numberOfBatches = factor == null || factor.getFactorValues().size() == 0 ? 0 : factor.getFactorValues().size();
List<Date> allDates = new ArrayList<>(dates.values());
Collections.sort(allDates);
String datesString = StringUtils.join(allDates, "\n");
BatchInfoPopulationServiceImpl.log.info("Got batch information for: " + ee.getShortName() + ", with " + numberOfBatches + " batches.");
this.auditTrailService.addUpdateEvent(ee, BatchInformationFetchingEvent.class, batchInfoParser.getScanDateExtractor().getClass().getSimpleName() + "; " + numberOfBatches + " batches.", "Dates of sample runs: " + datesString);
return true;
}
return false;
}
use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class SVDServiceHelperImpl method svd.
@Override
public SVDValueObject svd(ExpressionExperiment ee) {
assert ee != null;
Collection<ProcessedExpressionDataVector> vectors = processedExpressionDataVectorService.getProcessedDataVectors(ee);
if (vectors.isEmpty()) {
throw new IllegalArgumentException("Experiment must have processed data already to do SVD");
}
processedExpressionDataVectorService.thaw(vectors);
ExpressionDataDoubleMatrix mat = new ExpressionDataDoubleMatrix(vectors);
SVDServiceHelperImpl.log.info("Starting SVD");
ExpressionDataSVD svd = new ExpressionDataSVD(mat);
SVDServiceHelperImpl.log.info("SVD done, postprocessing and storing results.");
/*
* Save the results
*/
DoubleMatrix<Integer, BioMaterial> v = svd.getV();
BioAssayDimension b = mat.getBestBioAssayDimension();
PrincipalComponentAnalysis pca = this.updatePca(ee, svd, v, b);
return this.svdFactorAnalysis(pca);
}
use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class GeoDatasetServiceTest method testFetchAndLoadGSE13657.
/*
* Left out quantitation types due to bug in how quantitation types were cached during persisting, if the QTs didn't
* have descriptions.
*/
@Test
public void testFetchAndLoadGSE13657() throws Exception {
try {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
Collection<?> results = geoService.fetchAndLoad("GSE13657", false, true, false);
ee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
log.info("Test skipped because GSE13657 was already loaded - clean the DB before running the test");
return;
}
ee = this.eeService.thawLite(ee);
aclTestUtils.checkEEAcls(ee);
Collection<QuantitationType> qts = eeService.getQuantitationTypes(ee);
assertEquals(13, qts.size());
// make sure we got characteristics and treatments for both channels.
for (BioAssay ba : ee.getBioAssays()) {
BioMaterial bm = ba.getSampleUsed();
assertNotNull(bm);
log.info(bm + " " + bm.getDescription());
assertEquals(9, bm.getCharacteristics().size());
}
}
use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class ExperimentalDesignImporterTest method testParseWhereExtraValue.
/*
* test case where the design file has extra information not relevant to the current samples.
*/
@Test
public final void testParseWhereExtraValue() throws Exception {
try (InputStream is = this.getClass().getResourceAsStream("/data/loader/expression/experimentalDesignTestExtra.txt")) {
experimentalDesignImporter.importDesign(ee, is);
}
ee = this.eeService.thawLite(ee);
Collection<BioMaterial> bms = new HashSet<>();
for (BioAssay ba : ee.getBioAssays()) {
BioMaterial bm = ba.getSampleUsed();
bms.add(bm);
}
this.aclTestUtils.checkEEAcls(ee);
this.checkResults(bms);
}
use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalyzerServiceTest method setup.
@Before
public void setup() throws Exception {
ee = expressionExperimentService.findByShortName("GSE1611");
if (ee == null) {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("gds994Short")));
Collection<?> results = geoService.fetchAndLoad("GSE1611", false, true, false);
ee = (ExpressionExperiment) results.iterator().next();
}
processedDataVectorService.createProcessedDataVectors(ee);
ee = expressionExperimentService.findByShortName("GSE1611");
ee = expressionExperimentService.thawLite(ee);
differentialExpressionAnalyzerService.deleteAnalyses(ee);
assertEquals(2, ee.getExperimentalDesign().getExperimentalFactors().size());
for (BioAssay ba : ee.getBioAssays()) {
BioMaterial bm = ba.getSampleUsed();
assertEquals(bm + " " + ba, 2, bm.getFactorValues().size());
}
}
Aggregations