Search in sources :

Example 26 with DesignElementDataVector

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

the class QuantitationTypeData method getPreferredQTypes.

public List<QuantitationType> getPreferredQTypes() {
    List<QuantitationType> result = new ArrayList<>();
    List<BioAssayDimension> dimensions = this.getBioAssayDimensions();
    if (dimensions.size() == 0) {
        throw new IllegalArgumentException("No bioAssayDimensions!");
    }
    for (BioAssayDimension dimension : dimensions) {
        for (DesignElementDataVector vector : vectors) {
            if (!vector.getBioAssayDimension().equals(dimension))
                continue;
            QuantitationType qType = vector.getQuantitationType();
            if (!qType.getIsPreferred() && !qType.getIsMaskedPreferred())
                continue;
            // if we get here, we're in the right place.
            result.add(qType);
            // on to the next dimension.
            break;
        }
    }
    return result;
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Example 27 with DesignElementDataVector

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

the class QuantitationTypeData method getRanksByMean.

public Map<CompositeSequence, Double> getRanksByMean() {
    Collection<QuantitationType> qtypes = this.getPreferredQTypes();
    Map<CompositeSequence, Double> ranks = new HashMap<>();
    for (DesignElementDataVector v : this.vectors) {
        if (qtypes.contains(v.getQuantitationType()) && v instanceof ProcessedExpressionDataVector) {
            ranks.put(v.getDesignElement(), ((ProcessedExpressionDataVector) v).getRankByMean());
        }
    }
    return ranks;
}
Also used : 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) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 28 with DesignElementDataVector

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

the class QuantitationTypeData method getQuantitationTypesNeeded.

/**
 * @return If there are multiple valid choices, we choose the first one seen, unless a later one has fewer missing value.
 */
private QuantitationTypeData getQuantitationTypesNeeded() {
    Collection<BioAssayDimension> dimensions = this.getBioAssayDimensions();
    QuantitationTypeData result = new QuantitationTypeData();
    this.populateMissingValueInfo();
    for (BioAssayDimension targetDimension : dimensions) {
        Collection<QuantitationType> checkedQts = new HashSet<>();
        for (DesignElementDataVector vector : vectors) {
            BioAssayDimension dim = vector.getBioAssayDimension();
            if (!dim.equals(targetDimension))
                continue;
            QuantitationType qType = vector.getQuantitationType();
            if (checkedQts.contains(qType))
                continue;
            checkedQts.add(qType);
            String name = qType.getName();
            if (qType.getIsPreferred() && result.getPreferred(dim) == null) {
                result.addPreferred(dim, qType);
                ExpressionDataMatrixBuilder.log.info("Preferred=" + qType);
            } else if (ChannelUtils.isBackgroundChannelA(name)) {
                if (result.getBackgroundChannelA(dim) != null) {
                    int i = numMissingValues.get(qType);
                    int j = numMissingValues.get(result.getBackgroundChannelA(dim));
                    if (i < j) {
                        ExpressionDataMatrixBuilder.log.info("Found better background A=" + qType);
                        result.addBackgroundChannelA(dim, qType);
                    }
                } else {
                    result.addBackgroundChannelA(dim, qType);
                    ExpressionDataMatrixBuilder.log.info("Background A=" + qType);
                }
            } else if (ChannelUtils.isBackgroundChannelB(name)) {
                if (result.getBackgroundChannelB(dim) != null) {
                    int i = numMissingValues.get(qType);
                    int j = numMissingValues.get(result.getBackgroundChannelB(dim));
                    if (i < j) {
                        ExpressionDataMatrixBuilder.log.info("Found better background B=" + qType);
                        result.addBackgroundChannelB(dim, qType);
                    }
                } else {
                    result.addBackgroundChannelB(dim, qType);
                    ExpressionDataMatrixBuilder.log.info("Background B=" + qType);
                }
            } else if (ChannelUtils.isSignalChannelA(name)) {
                if (result.getSignalChannelA(dim) != null) {
                    int i = numMissingValues.get(qType);
                    int j = numMissingValues.get(result.getSignalChannelA(dim));
                    if (i < j) {
                        ExpressionDataMatrixBuilder.log.info("Found better Signal A=" + qType);
                        result.addSignalChannelA(dim, qType);
                    }
                } else {
                    result.addSignalChannelA(dim, qType);
                    ExpressionDataMatrixBuilder.log.info("Signal A=" + qType);
                }
            } else if (ChannelUtils.isSignalChannelB(name)) {
                if (result.getSignalChannelB(dim) != null) {
                    int i = numMissingValues.get(qType);
                    int j = numMissingValues.get(result.getSignalChannelB(dim));
                    if (i < j) {
                        ExpressionDataMatrixBuilder.log.info("Found better Signal B=" + qType);
                        result.addSignalChannelB(dim, qType);
                    }
                } else {
                    result.addSignalChannelB(dim, qType);
                    ExpressionDataMatrixBuilder.log.info("Signal B=" + qType);
                }
            } else if (name.matches("CH1D_MEAN")) {
                // specific for SGD data bug
                result.addBkgSubChannelA(dim, qType);
            }
            if (!anyMissing && result.getSignalChannelA(dim) != null && result.getSignalChannelB(dim) != null && result.getBackgroundChannelA(dim) != null && result.getBackgroundChannelB(dim) != null && result.getPreferred(dim) != null) {
                // no need to go through them all.
                break;
            }
        }
    }
    return result;
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Example 29 with DesignElementDataVector

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

the class BaseExpressionDataMatrix method selectVectors.

Collection<DesignElementDataVector> selectVectors(Collection<? extends DesignElementDataVector> vectors, List<QuantitationType> qTypes) {
    this.quantitationTypes.addAll(qTypes);
    List<DesignElementDataVector> sorted = this.sortVectorsByDesignElement(vectors);
    Collection<DesignElementDataVector> vectorsOfInterest = new LinkedHashSet<>();
    int rowIndex = 0;
    for (QuantitationType soughtType : qTypes) {
        for (DesignElementDataVector vector : sorted) {
            QuantitationType vectorQuantitationType = vector.getQuantitationType();
            if (vectorQuantitationType.equals(soughtType)) {
                if (this.expressionExperiment == null)
                    this.expressionExperiment = vector.getExpressionExperiment();
                vectorsOfInterest.add(vector);
                this.getQuantitationTypes().add(vectorQuantitationType);
                CompositeSequence designElement = vector.getDesignElement();
                this.bioAssayDimensions.put(designElement, vector.getBioAssayDimension());
                this.addToRowMaps(rowIndex, designElement);
                rowIndex++;
            }
        }
    }
    BaseExpressionDataMatrix.log.debug("Selected " + vectorsOfInterest.size() + " vectors");
    return vectorsOfInterest;
}
Also used : DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 30 with DesignElementDataVector

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

the class BaseExpressionDataMatrix method selectVectors.

Collection<DesignElementDataVector> selectVectors(Collection<? extends DesignElementDataVector> vectors, Collection<QuantitationType> qTypes) {
    this.quantitationTypes.addAll(qTypes);
    Collection<DesignElementDataVector> vectorsOfInterest = new LinkedHashSet<>();
    int i = 0;
    for (DesignElementDataVector vector : vectors) {
        QuantitationType vectorQuantitationType = vector.getQuantitationType();
        if (qTypes.contains(vectorQuantitationType)) {
            if (this.expressionExperiment == null)
                this.expressionExperiment = vector.getExpressionExperiment();
            vectorsOfInterest.add(vector);
            CompositeSequence designElement = vector.getDesignElement();
            bioAssayDimensions.put(designElement, vector.getBioAssayDimension());
            this.addToRowMaps(i, designElement);
            this.getQuantitationTypes().add(vectorQuantitationType);
            i++;
        }
    }
    return vectorsOfInterest;
}
Also used : DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

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