Search in sources :

Example 6 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class BaseExpressionDataMatrix method selectVectors.

/**
 * Selects all the vectors passed in (uses them to initialize the data)
 */
void selectVectors(Collection<? extends DesignElementDataVector> vectors) {
    QuantitationType quantitationType = null;
    int i = 0;
    List<DesignElementDataVector> sorted = this.sortVectorsByDesignElement(vectors);
    for (DesignElementDataVector vector : sorted) {
        if (this.expressionExperiment == null)
            this.expressionExperiment = vector.getExpressionExperiment();
        QuantitationType vectorQuantitationType = vector.getQuantitationType();
        CompositeSequence designElement = vector.getDesignElement();
        this.bioAssayDimensions.put(designElement, vector.getBioAssayDimension());
        if (quantitationType == null) {
            quantitationType = vectorQuantitationType;
            this.getQuantitationTypes().add(vectorQuantitationType);
        } else {
            if (quantitationType != vectorQuantitationType) {
                throw new IllegalArgumentException("Cannot pass vectors from more than one quantitation type");
            }
        }
        this.addToRowMaps(i, designElement);
        i++;
    }
}
Also used : DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 7 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector 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();
        }
    }
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 8 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class RawExpressionDataVectorDaoImpl method find.

@Override
public RawExpressionDataVector find(RawExpressionDataVector designElementDataVector) {
    BusinessKey.checkKey(designElementDataVector);
    DetachedCriteria crit = DetachedCriteria.forClass(RawExpressionDataVector.class);
    crit.createCriteria("designElement").add(Restrictions.eq("name", designElementDataVector.getDesignElement().getName())).createCriteria("arrayDesign").add(Restrictions.eq("name", designElementDataVector.getDesignElement().getArrayDesign().getName()));
    crit.createCriteria("quantitationType").add(Restrictions.eq("name", designElementDataVector.getQuantitationType().getName()));
    crit.createCriteria("expressionExperiment").add(Restrictions.eq("name", designElementDataVector.getExpressionExperiment().getName()));
    List<?> results = this.getHibernateTemplate().findByCriteria(crit);
    Object result = null;
    if (results != null) {
        if (results.size() > 1) {
            throw new org.springframework.dao.InvalidDataAccessResourceUsageException("More than one instance of '" + DesignElementDataVector.class.getName() + "' was found when executing query");
        } else if (results.size() == 1) {
            result = results.iterator().next();
        }
    }
    return (RawExpressionDataVector) result;
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) DetachedCriteria(org.hibernate.criterion.DetachedCriteria) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)

Example 9 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class QuantitationTypeData method getPreferredDataVectors.

/**
 * @return The 'preferred' data vectors - NOT the processed data vectors!
 */
private Collection<DesignElementDataVector> getPreferredDataVectors() {
    Collection<DesignElementDataVector> result = new HashSet<>();
    List<BioAssayDimension> dimensions = this.getBioAssayDimensions();
    List<QuantitationType> qtypes = this.getPreferredQTypes();
    for (DesignElementDataVector vector : vectors) {
        if (!(vector instanceof ProcessedExpressionDataVector) && dimensions.contains(vector.getBioAssayDimension()) && qtypes.contains(vector.getQuantitationType()))
            result.add(vector);
    }
    return result;
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Example 10 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class QuantitationTypeData method populateMissingValueInfo.

private void populateMissingValueInfo() {
    ByteArrayConverter bac = new ByteArrayConverter();
    for (DesignElementDataVector vector : vectors) {
        QuantitationType qt = vector.getQuantitationType();
        if (!numMissingValues.containsKey(qt)) {
            numMissingValues.put(qt, 0);
        }
        for (Double d : bac.byteArrayToDoubles(vector.getData())) {
            if (d.isNaN()) {
                anyMissing = true;
                numMissingValues.put(qt, numMissingValues.get(qt) + 1);
            }
        }
    }
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Aggregations

DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)33 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)18 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)18 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)15 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)9 StandardQuantitationType (ubic.gemma.model.common.quantitationtype.StandardQuantitationType)9 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)8 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)6 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)5 ProcessedExpressionDataVector (ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)5 Collection (java.util.Collection)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)2 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)2 InputStream (java.io.InputStream)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1