use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ExpressionExperimentServiceTest method testGetQuantitationTypesForArrayDesign.
@Test
public final void testGetQuantitationTypesForArrayDesign() {
ArrayDesign ad = ee.getRawExpressionDataVectors().iterator().next().getDesignElement().getArrayDesign();
Collection<QuantitationType> types = expressionExperimentService.getQuantitationTypes(ee, ad);
assertEquals(2, types.size());
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ExpressionExperimentPlatformSwitchService method locateMergedDesign.
private ArrayDesign locateMergedDesign(ExpressionExperiment expExp) {
// get the array designs for this EE
ArrayDesign arrayDesign = null;
Collection<ArrayDesign> oldArrayDesigns = expressionExperimentService.getArrayDesignsUsed(expExp);
// find the AD they have been merged into, make sure it is exists and they are all merged into the same AD.
for (ArrayDesign design : oldArrayDesigns) {
ArrayDesign mergedInto = design.getMergedInto();
mergedInto = arrayDesignService.thaw(mergedInto);
if (mergedInto == null) {
throw new IllegalArgumentException(design + " used by " + expExp + " is not merged into another design");
}
if (arrayDesign == null) {
arrayDesign = mergedInto;
arrayDesign = arrayDesignService.thaw(arrayDesign);
}
if (!mergedInto.equals(arrayDesign)) {
throw new IllegalArgumentException(design + " used by " + expExp + " is not merged into " + arrayDesign);
}
}
return arrayDesign;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ExpressionExperimentPlatformSwitchService method switchExperimentToArrayDesign.
/**
* If you know the arraydesigns are already in a merged state, you should use switchExperimentToMergedPlatform
*
* @param ee ee
* @param arrayDesign The array design to switch to. If some samples already use that array design, nothing will be
* changed for them.
*/
public ExpressionExperiment switchExperimentToArrayDesign(ExpressionExperiment ee, ArrayDesign arrayDesign) {
assert arrayDesign != null;
// remove stuff that will be in the way.
processedExpressionDataVectorService.removeProcessedDataVectors(ee);
sampleCoexpressionMatrixService.delete(ee);
for (ExpressionExperimentSubSet subset : expressionExperimentService.getSubSets(ee)) {
subsetService.remove(subset);
}
// get relation between sequence and designelements.
Map<BioSequence, Collection<CompositeSequence>> designElementMap = new HashMap<>();
Collection<CompositeSequence> elsWithNoSeq = new HashSet<>();
this.populateCSeq(arrayDesign, designElementMap, elsWithNoSeq);
ee = expressionExperimentService.thaw(ee);
ExpressionExperimentPlatformSwitchService.log.info(elsWithNoSeq.size() + " elements on the new platform have no associated sequence.");
designElementMap.put(ExpressionExperimentPlatformSwitchService.NULL_BIOSEQUENCE, elsWithNoSeq);
boolean multiPlatformPerSample = this.checkMultiPerSample(ee, arrayDesign);
/*
* For a multiplatform-per-sample case: (note that some samples might just be on one platform...)
* 1. Pick a BAD that can be used for all DataVectors (it has all BioAssays in it).
* 2. Switch vectors to use it - may require adding NaNs and reordering the vectors
* 3. Delete the Bioassays that are using other BADs
*/
/*
* Now we have to get the BADs. Problem to watch out for: they might not be the same length, we need one that
* includes all BioMaterials.
*/
Collection<BioAssayDimension> unusedBADs = new HashSet<>();
BioAssayDimension maxBAD = null;
int maxSize = 0;
if (multiPlatformPerSample) {
maxBAD = this.doMultiSample(ee, unusedBADs, maxSize);
}
Collection<ArrayDesign> oldArrayDesigns = expressionExperimentService.getArrayDesignsUsed(ee);
Map<CompositeSequence, Collection<BioAssayDimension>> usedDesignElements = new HashMap<>();
for (ArrayDesign oldAd : oldArrayDesigns) {
this.runOldAd(ee, arrayDesign, designElementMap, maxBAD, usedDesignElements, oldAd);
}
ee.setDescription(ee.getDescription() + " [Switched to use " + arrayDesign.getShortName() + " by Gemma]");
helperService.persist(ee, arrayDesign);
/*
* This might need to be done inside the transaction we're using to make the switch.
*/
if (maxBAD != null && !unusedBADs.isEmpty()) {
this.checkUnused(unusedBADs, maxBAD);
}
return ee;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class GeoServiceImpl method updateReports.
private void updateReports(Collection<?> entities) {
Collection<ArrayDesign> adsToUpdate = new HashSet<>();
for (Object entity : entities) {
if (entity instanceof ExpressionExperiment) {
ExpressionExperiment expressionExperiment = (ExpressionExperiment) entity;
expressionExperiment = this.expressionExperimentService.thaw(expressionExperiment);
this.expressionExperimentReportService.generateSummary(expressionExperiment.getId());
expressionExperiment = this.expressionExperimentService.thaw(expressionExperiment);
for (BioAssay ba : expressionExperiment.getBioAssays()) {
adsToUpdate.add(ba.getArrayDesignUsed());
}
} else if (entity instanceof ArrayDesign) {
adsToUpdate.add((ArrayDesign) entity);
}
}
for (ArrayDesign arrayDesign : adsToUpdate) {
this.arrayDesignReportService.generateArrayDesignReport(arrayDesign.getId());
}
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class GeoServiceImpl method matchToExistingPlatform.
private void matchToExistingPlatform(GeoConverter geoConverter, GeoPlatform rawGEOPlatform, ArrayDesignsForExperimentCache c) {
// we have to populate this.
Map<String, String> probeNamesInGemma = rawGEOPlatform.getProbeNamesInGemma();
// do a partial conversion. We will throw this away;
ArrayDesign geoArrayDesign = (ArrayDesign) geoConverter.convert(rawGEOPlatform);
if (geoArrayDesign == null) {
if (!rawGEOPlatform.useDataFromGeo()) {
// MPSS, exon arrays
return;
}
throw new IllegalStateException("Platform is missing");
}
// find in our system. Note we only use the short name. The full name can change in GEO, causing trouble.
ArrayDesign existing = arrayDesignService.findByShortName(geoArrayDesign.getShortName());
if (existing == null) {
AbstractGeoService.log.info(rawGEOPlatform + " looks new to Gemma");
for (CompositeSequence cs : geoArrayDesign.getCompositeSequences()) {
String geoProbeName = cs.getName();
probeNamesInGemma.put(geoProbeName, geoProbeName);
// no mapping needed. NB the converter fills
// this in already, we're just being defensive
// here.
}
} else {
AbstractGeoService.log.info("Platform " + rawGEOPlatform.getGeoAccession() + " exists in Gemma, checking for correct probe names and re-matching if necessary ...");
String columnWithGeoNames;
columnWithGeoNames = this.getGEOIDColumnName(rawGEOPlatform, geoArrayDesign);
if (columnWithGeoNames == null) {
// no problem: this means the design has no elements, so it is actually a placeholder (e.g., MPSS)
return;
}
AbstractGeoService.log.info("Loading probes ...");
Map<CompositeSequence, BioSequence> m = arrayDesignService.getBioSequences(existing);
c.add(existing, m);
this.getGemmaIDColumnNameInGEO(rawGEOPlatform, m, columnWithGeoNames);
}
}
Aggregations