use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class ProcessedExpressionDataVectorDaoImpl method getPreferredMaskedDataQuantitationType.
/**
* Make a quantitation type for attaching to the new processed data.
*
* @param preferredQt preferred QT
* @return QT
*/
private QuantitationType getPreferredMaskedDataQuantitationType(QuantitationType preferredQt) {
QuantitationType present = QuantitationType.Factory.newInstance();
present.setName(preferredQt.getName() + " - Processed version");
present.setDescription("Processed data (as per Gemma) for analysis, based on the preferred quantitation type raw data");
present.setGeneralType(preferredQt.getGeneralType());
// better be a number!
present.setRepresentation(preferredQt.getRepresentation());
present.setScale(preferredQt.getScale());
present.setIsBackground(false);
// This is the correct thing to do because it's not raw data.
present.setIsPreferred(false);
present.setIsMaskedPreferred(true);
present.setIsBackgroundSubtracted(preferredQt.getIsBackgroundSubtracted());
present.setIsBatchCorrected(preferredQt.getIsBatchCorrected());
present.setIsRecomputedFromRawData(// By "RAW" we mean CEL files or Fastq etc.
preferredQt.getIsRecomputedFromRawData());
present.setIsNormalized(preferredQt.getIsNormalized());
present.setIsRatio(preferredQt.getIsRatio());
present.setType(preferredQt.getType());
Long id = (Long) this.getSessionFactory().getCurrentSession().save(present);
return (QuantitationType) this.getSessionFactory().getCurrentSession().load(QuantitationTypeImpl.class, id);
}
use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class GeoConverterImpl method convertVectorsForPlatform.
/**
* For data coming from a single platform, create vectors.
*
* @param values A GeoValues object holding the parsed results.
*/
private void convertVectorsForPlatform(GeoValues values, ExpressionExperiment expExp, List<GeoSample> datasetSamples, GeoPlatform geoPlatform) {
assert datasetSamples.size() > 0 : "No samples in dataset";
if (!geoPlatform.useDataFromGeo()) {
// see bug 4181
GeoConverterImpl.log.warn("Platform characteristics indicate data from GEO should be ignored or will not be present anyway (" + geoPlatform + ")");
return;
}
GeoConverterImpl.log.info("Converting vectors for " + geoPlatform.getGeoAccession() + ", " + datasetSamples.size() + " samples.");
BioAssayDimension bioAssayDimension = this.convertGeoSampleList(datasetSamples, expExp);
if (bioAssayDimension.getBioAssays().size() == 0)
throw new IllegalStateException("No bioAssays in the BioAssayDimension");
this.sanityCheckQuantitationTypes(datasetSamples);
List<String> quantitationTypes = datasetSamples.iterator().next().getColumnNames();
List<String> quantitationTypeDescriptions = datasetSamples.iterator().next().getColumnDescriptions();
boolean first = true;
for (String quantitationType : quantitationTypes) {
// skip the first quantitationType, it's the ID or ID_REF.
if (first) {
first = false;
continue;
}
int columnAccordingToSample = quantitationTypes.indexOf(quantitationType);
int quantitationTypeIndex = values.getQuantitationTypeIndex(geoPlatform, quantitationType);
GeoConverterImpl.log.debug("Processing " + quantitationType + " (column=" + quantitationTypeIndex + " - according to sample, it's " + columnAccordingToSample + ")");
Map<String, List<Object>> dataVectors = this.makeDataVectors(values, datasetSamples, quantitationTypeIndex);
if (dataVectors == null || dataVectors.size() == 0) {
GeoConverterImpl.log.debug("No data for " + quantitationType + " (column=" + quantitationTypeIndex + ")");
continue;
}
GeoConverterImpl.log.info(dataVectors.size() + " data vectors for " + quantitationType);
Object exampleValue = dataVectors.values().iterator().next().iterator().next();
QuantitationType qt = QuantitationType.Factory.newInstance();
qt.setName(quantitationType);
String description = quantitationTypeDescriptions.get(columnAccordingToSample);
qt.setDescription(description);
QuantitationTypeParameterGuesser.guessQuantitationTypeParameters(qt, quantitationType, description, exampleValue);
int count = 0;
int skipped = 0;
for (String designElementName : dataVectors.keySet()) {
List<Object> dataVector = dataVectors.get(designElementName);
if (dataVector == null || dataVector.size() == 0)
continue;
RawExpressionDataVector vector = this.convertDesignElementDataVector(geoPlatform, expExp, bioAssayDimension, designElementName, dataVector, qt);
if (vector == null) {
skipped++;
if (GeoConverterImpl.log.isDebugEnabled())
GeoConverterImpl.log.debug("Null vector for DE=" + designElementName + " QT=" + quantitationType);
continue;
}
if (GeoConverterImpl.log.isTraceEnabled()) {
GeoConverterImpl.log.trace(designElementName + " " + qt.getName() + " " + qt.getRepresentation() + " " + dataVector.size() + " elements in vector");
}
expExp.getRawExpressionDataVectors().add(vector);
if (++count % GeoConverterImpl.LOGGING_VECTOR_COUNT_UPDATE == 0 && GeoConverterImpl.log.isDebugEnabled()) {
GeoConverterImpl.log.debug(count + " Data vectors added");
}
}
if (count > 0) {
expExp.getQuantitationTypes().add(qt);
if (GeoConverterImpl.log.isDebugEnabled() && count > 1000) {
GeoConverterImpl.log.debug(count + " Data vectors added for '" + quantitationType + "'");
}
} else {
GeoConverterImpl.log.info("No vectors were retained for " + quantitationType + " -- usually this is due to all values being missing.");
}
if (skipped > 0) {
GeoConverterImpl.log.info("Skipped " + skipped + " vectors");
}
}
GeoConverterImpl.log.info("Total of " + expExp.getRawExpressionDataVectors().size() + " vectors on platform " + geoPlatform + ", " + expExp.getQuantitationTypes().size() + " quantitation types.");
}
use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class GeoConverterTest method checkQts.
private boolean checkQts(ExpressionExperiment ee) {
boolean ok = false;
for (DesignElementDataVector dedv : ee.getRawExpressionDataVectors()) {
QuantitationType qt = dedv.getQuantitationType();
if (qt.getIsPreferred()) {
ok = true;
assertEquals("VALUE", qt.getName());
}
}
return ok;
}
use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class GeoConverterTest method test5091.
/*
* quantitation type problem. See bug 1760
*/
@SuppressWarnings("unchecked")
@Test
public void test5091() throws Exception {
GeoFamilyParser parser = new GeoFamilyParser();
try (InputStream is = new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/expression/geo/GSE5091Short/GSE5091_family.soft.gz"))) {
parser.parse(is);
}
GeoSeries series = ((GeoParseResult) parser.getResults().iterator().next()).getSeriesMap().get("GSE5091");
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();
for (QuantitationType qt : ee.getQuantitationTypes()) {
if (qt.getName().equals("VALUE")) {
assertEquals(PrimitiveType.DOUBLE, qt.getRepresentation());
return;
}
}
fail("Didn't find the 'value' quantitation type");
}
use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class GeoConverterTest method testParseGSE18707.
@Test
public void testParseGSE18707() throws Exception {
InputStream is = new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/expression/geo/GSE18707.soft.gz"));
GeoFamilyParser parser = new GeoFamilyParser();
parser.parse(is);
GeoSeries series = ((GeoParseResult) parser.getResults().iterator().next()).getSeriesMap().get("GSE18707");
DatasetCombiner datasetCombiner = new DatasetCombiner(false);
GeoSampleCorrespondence correspondence = datasetCombiner.findGSECorrespondence(series);
series.setSampleCorrespondence(correspondence);
Set<?> result = (Set<?>) this.gc.convert(series);
ExpressionExperiment e = (ExpressionExperiment) result.iterator().next();
assertEquals(100, e.getRawExpressionDataVectors().size());
// this is normal, before any processing.
assertEquals(1, e.getQuantitationTypes().size());
QuantitationType qt = e.getQuantitationTypes().iterator().next();
assertEquals("Processed Affymetrix Rosetta intensity values", qt.getDescription());
}
Aggregations