use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class GeoConverterTest method testConvertGSE2982.
@SuppressWarnings("unchecked")
@Test
public void testConvertGSE2982() throws Exception {
InputStream is = new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/expression/geo/gse2982Short/GSE2982_family.soft.gz"));
GeoFamilyParser parser = new GeoFamilyParser();
parser.parse(is);
GeoSeries series = ((GeoParseResult) parser.getResults().iterator().next()).getSeriesMap().get("GSE2982");
DatasetCombiner datasetCombiner = new DatasetCombiner();
GeoSampleCorrespondence correspondence = datasetCombiner.findGSECorrespondence(series);
series.setSampleCorrespondence(correspondence);
Object result = this.gc.convert(series);
assertNotNull(result);
Collection<ExpressionExperiment> ees = (Collection<ExpressionExperiment>) result;
assertEquals(1, ees.size());
ExpressionExperiment ee = ees.iterator().next();
boolean ok = false;
for (RawExpressionDataVector dedv : ee.getRawExpressionDataVectors()) {
QuantitationType qt = dedv.getQuantitationType();
if (qt.getIsPreferred()) {
ok = true;
assertEquals("VALUE", qt.getName());
assertEquals(StandardQuantitationType.AMOUNT, qt.getType());
assertTrue(qt.getIsRatio());
}
}
assertTrue(ok);
}
use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class TwoChannelMissingValueCLI method processExperiment.
private boolean processExperiment(ExpressionExperiment ee) {
Collection<QuantitationType> types = eeService.getQuantitationTypes(ee);
ee = this.eeService.thawLite(ee);
if (!force && this.noNeedToRun(ee, MissingValueAnalysisEvent.class))
return false;
QuantitationType previousMissingValueQt = null;
for (QuantitationType qType : types) {
if (qType.getType() == StandardQuantitationType.PRESENTABSENT) {
if (previousMissingValueQt != null) {
AbstractCLI.log.warn("More than one present/absent quantitationtype!");
}
previousMissingValueQt = qType;
}
}
if (previousMissingValueQt != null && !force) {
AbstractCLI.log.warn(ee + " already has missing value vectors, skipping");
return false;
}
if (force && previousMissingValueQt != null) {
AbstractCLI.log.info("Removing old present/absent data");
rawService.removeDataForQuantitationType(previousMissingValueQt);
procService.removeDataForQuantitationType(previousMissingValueQt);
quantitationTypeService.remove(previousMissingValueQt);
}
AbstractCLI.log.info("Got " + ee + ", thawing...");
AbstractCLI.log.info("Computing missing value data..");
Collection<RawExpressionDataVector> missingValueVectors = tcmv.computeMissingValues(ee, s2n, this.extraMissingValueIndicators);
if (missingValueVectors.size() == 0) {
AbstractCLI.log.warn("No missing value vectors computed");
return false;
}
try {
preprocessorService.process(ee, true);
} catch (PreprocessingException e) {
AbstractCLI.log.error("Error during postprocessing of " + ee + " , make sure additional steps are completed", e);
}
return true;
}
use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class ExpressionExperimentServiceTest method testGetRawExpressionDataVectors.
@Test
public final void testGetRawExpressionDataVectors() {
ExpressionExperiment eel = this.getTestPersistentCompleteExpressionExperiment(false);
Collection<CompositeSequence> designElements = new HashSet<>();
QuantitationType quantitationType = eel.getRawExpressionDataVectors().iterator().next().getQuantitationType();
Collection<RawExpressionDataVector> allv = eel.getRawExpressionDataVectors();
assertNotNull(quantitationType);
assertTrue(allv.size() > 1);
for (RawExpressionDataVector anAllv : allv) {
CompositeSequence designElement = anAllv.getDesignElement();
assertNotNull(designElement);
designElements.add(designElement);
if (designElements.size() == 2)
break;
}
assertEquals(2, designElements.size());
Collection<? extends DesignElementDataVector> vectors = rawExpressionDataVectorService.find(designElements, quantitationType);
assertEquals(2, vectors.size());
}
use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class ExpressionExperimentPlatformSwitchService method runOldAd.
private void runOldAd(ExpressionExperiment ee, ArrayDesign arrayDesign, Map<BioSequence, Collection<CompositeSequence>> designElementMap, BioAssayDimension maxBAD, Map<CompositeSequence, Collection<BioAssayDimension>> usedDesignElements, ArrayDesign oldAd) {
if (oldAd.equals(arrayDesign))
return;
oldAd = arrayDesignService.thaw(oldAd);
if (oldAd.getCompositeSequences().size() == 0 && !oldAd.getTechnologyType().equals(TechnologyType.NONE)) {
/*
* Bug 3451 - this is okay if it is a RNA-seq experiment etc. prior to data upload.
*/
throw new IllegalStateException(oldAd + " has no elements");
}
Collection<QuantitationType> qts = expressionExperimentService.getQuantitationTypes(ee, oldAd);
ExpressionExperimentPlatformSwitchService.log.info("Processing " + qts.size() + " quantitation types for vectors on " + oldAd);
for (QuantitationType type : qts) {
// use each design element only once per quantitation type + bioassaydimension per array design
usedDesignElements.clear();
Collection<RawExpressionDataVector> rawForQt = this.getRawVectorsForOneQuantitationType(oldAd, type);
Collection<ProcessedExpressionDataVector> processedForQt = this.getProcessedVectorsForOneQuantitationType(oldAd, type);
if (//
(rawForQt == null || rawForQt.size() == 0) && (processedForQt == null || processedForQt.size() == 0)) {
/*
* This can happen when the quantitation types vary for the array designs.
*/
ExpressionExperimentPlatformSwitchService.log.debug("No vectors for " + type + " on " + oldAd);
continue;
}
// This check assures we do not mix raw and processed vectors further down the line
if ((rawForQt != null && rawForQt.size() > 0) && (processedForQt != null && processedForQt.size() > 0)) {
throw new IllegalStateException("Two types of vector for quantitationType " + type);
}
Collection<DesignElementDataVector> vectors = new HashSet<>();
if (rawForQt != null) {
vectors.addAll(rawForQt);
}
if (processedForQt != null) {
vectors.addAll(processedForQt);
}
ExpressionExperimentPlatformSwitchService.log.info("Switching " + vectors.size() + " vectors for " + type + " from " + oldAd.getShortName() + " to " + arrayDesign.getShortName());
int count = 0;
// noinspection MismatchedQueryAndUpdateOfCollection // Only used for logging
Collection<DesignElementDataVector> unMatched = new HashSet<>();
for (DesignElementDataVector vector : vectors) {
assert RawExpressionDataVector.class.isAssignableFrom(vector.getClass()) : "Unexpected class: " + vector.getClass().getName();
CompositeSequence oldDe = vector.getDesignElement();
if (oldDe.getArrayDesign().equals(arrayDesign)) {
continue;
}
this.processVector(designElementMap, usedDesignElements, vector, maxBAD);
if (++count % 20000 == 0) {
ExpressionExperimentPlatformSwitchService.log.info("Found matches for " + count + " vectors for " + type);
}
}
/*
* This is bad.
*/
if (unMatched.size() > 0) {
throw new IllegalStateException("There were " + unMatched.size() + " vectors that couldn't be matched to the new design for: " + type + ", example: " + unMatched.iterator().next());
}
// Force collection update
if (rawForQt != null && rawForQt.size() > 0) {
int s = ee.getRawExpressionDataVectors().size();
ee.getRawExpressionDataVectors().removeAll(rawForQt);
assert s > ee.getRawExpressionDataVectors().size();
ee.getRawExpressionDataVectors().addAll(rawForQt);
assert s == ee.getRawExpressionDataVectors().size();
} else if (processedForQt != null && processedForQt.size() > 0) {
int s = ee.getProcessedExpressionDataVectors().size();
ee.getProcessedExpressionDataVectors().removeAll(processedForQt);
assert s > ee.getProcessedExpressionDataVectors().size();
ee.getProcessedExpressionDataVectors().addAll(processedForQt);
assert s == ee.getProcessedExpressionDataVectors().size();
}
}
}
use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class ExpressionExperimentServiceImpl method removeRawVectors.
@Override
@Transactional
public int removeRawVectors(ExpressionExperiment ee, QuantitationType qt) {
ExpressionExperiment eeToUpdate = this.load(ee.getId());
Collection<RawExpressionDataVector> vectorsToRemove = new ArrayList<>();
for (RawExpressionDataVector oldV : eeToUpdate.getRawExpressionDataVectors()) {
if (oldV.getQuantitationType().equals(qt)) {
vectorsToRemove.add(oldV);
}
}
if (vectorsToRemove.isEmpty()) {
throw new IllegalArgumentException("No vectors to remove for quantitation type=" + qt);
}
eeToUpdate.getRawExpressionDataVectors().removeAll(vectorsToRemove);
AbstractService.log.info("Removing unused quantitation type: " + qt);
eeToUpdate.getQuantitationTypes().remove(qt);
return vectorsToRemove.size();
}
Aggregations