use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class ExpressionExperimentPlatformSwitchTest method test.
/**
* for bug 3451
*/
@Test
public void test() {
// GSE36025
//
// GPL9250
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGenerator());
Collection<?> results = geoService.fetchAndLoad("GSE36025", false, false, false);
ExpressionExperiment ee = (ExpressionExperiment) results.iterator().next();
results = geoService.fetchAndLoad("GPL13112", true, false, false);
ArrayDesign arrayDesign = (ArrayDesign) results.iterator().next();
arrayDesign = arrayDesignService.thaw(arrayDesign);
ee = experimentPlatformSwitchService.switchExperimentToArrayDesign(ee, arrayDesign);
assertNotNull(ee);
Collection<ArrayDesign> arrayDesignsUsed = experimentService.getArrayDesignsUsed(ee);
assertEquals(1, arrayDesignsUsed.size());
assertEquals(arrayDesign, arrayDesignsUsed.iterator().next());
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class SampleCoexpressionMatrixServiceTest method test.
@Test
public void test() {
ExpressionExperiment ee = super.getTestPersistentCompleteExpressionExperiment(false);
processedExpressionDataVectorService.computeProcessedExpressionData(ee);
DoubleMatrix<BioAssay, BioAssay> matrix = sampleCoexpressionMatrixService.create(ee);
this.check(matrix);
// recompute ...
matrix = sampleCoexpressionMatrixService.create(ee);
this.check(matrix);
matrix = sampleCoexpressionMatrixService.findOrCreate(ee);
this.check(matrix);
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class SecureValueObjectAuthorizationTest method setup.
@Before
public void setup() {
ExpressionExperiment publicEe = super.getTestPersistentBasicExpressionExperiment();
securityService.makePublic(publicEe);
publicExpressionExperimentId = publicEe.getId();
ee = super.getTestPersistentBasicExpressionExperiment();
ownersExpressionExperimentId = ee.getId();
this.makeUser(ownerUsername);
this.securityService.makeOwnedByUser(ee, ownerUsername);
this.makeUser(aDifferentUsername);
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class DatabaseViewGeneratorImpl method generateDifferentialExpressionView.
private void generateDifferentialExpressionView(Integer limit, Collection<ExpressionExperiment> experiments) throws IOException {
DatabaseViewGeneratorImpl.log.info("Generating dataset diffex view");
/*
* Get handle to output file
*/
File file = this.getViewFile(DatabaseViewGeneratorImpl.DATASET_DIFFEX_VIEW_BASENAME);
DatabaseViewGeneratorImpl.log.info("Writing to " + file);
try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) {
/*
* For each gene that is differentially expressed, print out a line per contrast
*/
writer.write("GemmaDsId\tEEShortName\tGeneNCBIId\tGemmaGeneId\tFactor\tFactorURI\tBaseline\tContrasting\tDirection\n");
int i = 0;
for (ExpressionExperiment ee : experiments) {
ee = expressionExperimentService.thawLite(ee);
Collection<DifferentialExpressionAnalysis> results = differentialExpressionAnalysisService.getAnalyses(ee);
if (results == null || results.isEmpty()) {
DatabaseViewGeneratorImpl.log.warn("No differential expression results found for " + ee);
continue;
}
// noinspection StatementWithEmptyBody // FIXME. Should probably skip for this purpose.
if (results.size() > 1) {
}
DatabaseViewGeneratorImpl.log.info("Processing: " + ee.getShortName());
for (DifferentialExpressionAnalysis analysis : results) {
analysis = this.differentialExpressionAnalysisService.thawFully(analysis);
for (ExpressionAnalysisResultSet ears : analysis.getResultSets()) {
// ears = differentialExpressionResultService.thawRawAndProcessed( ears );
FactorValue baselineGroup = ears.getBaselineGroup();
if (baselineGroup == null) {
// log.warn( "No baseline defined for " + ee ); // interaction
continue;
}
if (ExperimentalDesignUtils.isBatch(baselineGroup.getExperimentalFactor())) {
continue;
}
String baselineDescription = ExperimentalDesignUtils.prettyString(baselineGroup);
// Get the factor category name
StringBuilder factorName = new StringBuilder();
StringBuilder factorURI = new StringBuilder();
for (ExperimentalFactor ef : ears.getExperimentalFactors()) {
factorName.append(ef.getName()).append(",");
if (ef.getCategory() instanceof VocabCharacteristic) {
factorURI.append(ef.getCategory().getCategoryUri()).append(",");
}
}
factorName = new StringBuilder(StringUtils.removeEnd(factorName.toString(), ","));
factorURI = new StringBuilder(StringUtils.removeEnd(factorURI.toString(), ","));
if (ears.getResults() == null || ears.getResults().isEmpty()) {
DatabaseViewGeneratorImpl.log.warn("No differential expression analysis results found for " + ee);
continue;
}
// Generate probe details
for (DifferentialExpressionAnalysisResult dear : ears.getResults()) {
if (dear == null) {
DatabaseViewGeneratorImpl.log.warn("Missing results for " + ee + " skipping to next. ");
continue;
}
if (dear.getCorrectedPvalue() == null || dear.getCorrectedPvalue() > DatabaseViewGeneratorImpl.THRESH_HOLD)
continue;
String formatted = this.formatDiffExResult(ee, dear, factorName.toString(), factorURI.toString(), baselineDescription);
if (StringUtils.isNotBlank(formatted))
writer.write(formatted);
}
// dear loop
}
// ears loop
}
if (limit != null && (limit > 0 && ++i > limit))
break;
}
// EE loop
}
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class DatabaseViewGeneratorImpl method generateDatasetView.
private void generateDatasetView(Integer limit, Collection<ExpressionExperiment> experiments) throws IOException {
DatabaseViewGeneratorImpl.log.info("Generating dataset summary view");
/*
* Get handle to output file
*/
File file = this.getViewFile(DatabaseViewGeneratorImpl.DATASET_SUMMARY_VIEW_BASENAME);
DatabaseViewGeneratorImpl.log.info("Writing to " + file);
try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) {
writer.write("GemmaDsId\tSource\tSourceAccession\tShortName\tName\tDescription\ttaxon\tManufacturer\n");
/*
* Print out their names etc.
*/
int i = 0;
for (ExpressionExperiment ee : experiments) {
ee = expressionExperimentService.thawLite(ee);
DatabaseViewGeneratorImpl.log.info("Processing: " + ee.getShortName());
String acc = "";
String source = "";
if (ee.getAccession() != null && ee.getAccession().getAccession() != null) {
acc = ee.getAccession().getAccession();
source = ee.getAccession().getExternalDatabase().getName();
}
Long gemmaId = ee.getId();
String shortName = ee.getShortName();
String name = ee.getName();
String description = ee.getDescription();
description = StringUtils.replaceChars(description, '\t', ' ');
description = StringUtils.replaceChars(description, '\n', ' ');
description = StringUtils.replaceChars(description, '\r', ' ');
Taxon taxon = expressionExperimentService.getTaxon(ee);
if (taxon == null)
continue;
Collection<ArrayDesign> ads = expressionExperimentService.getArrayDesignsUsed(ee);
StringBuilder manufacturers = new StringBuilder();
// TODO could cache the arrayDesigns to make faster, thawing ad is time consuming
for (ArrayDesign ad : ads) {
ad = arrayDesignService.thawLite(ad);
if (ad.getDesignProvider() == null) {
DatabaseViewGeneratorImpl.log.debug("Array Design: " + ad.getShortName() + " has no design provoider assoicated with it. Skipping");
continue;
}
manufacturers.append(ad.getDesignProvider().getName()).append(",");
}
writer.write(String.format("%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", gemmaId, source, acc, shortName, name, description, taxon.getCommonName(), StringUtils.removeEnd(manufacturers.toString(), ",")));
if (limit != null && (limit > 0 && ++i > limit))
break;
}
}
}
Aggregations