Search in sources :

Example 51 with QuantitationType

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);
}
Also used : QuantitationTypeImpl(ubic.gemma.model.common.quantitationtype.QuantitationTypeImpl) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType)

Example 52 with QuantitationType

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.");
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType)

Example 53 with QuantitationType

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;
}
Also used : DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Example 54 with QuantitationType

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");
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) GeoSeries(ubic.gemma.core.loader.expression.geo.model.GeoSeries) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 55 with QuantitationType

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());
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) GeoSeries(ubic.gemma.core.loader.expression.geo.model.GeoSeries) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Aggregations

QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)74 StandardQuantitationType (ubic.gemma.model.common.quantitationtype.StandardQuantitationType)30 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)20 DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)18 Test (org.junit.Test)16 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)14 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)13 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)11 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)10 ProcessedExpressionDataVector (ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)10 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)8 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)7 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)6 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)6 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)6 InputStream (java.io.InputStream)5 GZIPInputStream (java.util.zip.GZIPInputStream)5 GeoSeries (ubic.gemma.core.loader.expression.geo.model.GeoSeries)5 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)5 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)4