Search in sources :

Example 51 with BioAssayDimension

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

the class ExpressionPersister method persist.

@Override
public Object persist(Object entity) {
    if (entity == null)
        return null;
    if (entity instanceof ExpressionExperiment) {
        AbstractPersister.log.warn("Consider doing the 'setup' step in a separate transaction");
        this.getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO);
        ArrayDesignsForExperimentCache c = expressionExperimentPrePersistService.prepare((ExpressionExperiment) entity);
        return this.persist((ExpressionExperiment) entity, c);
    } else if (entity instanceof BioAssayDimension) {
        return this.persistBioAssayDimension((BioAssayDimension) entity, null);
    } else if (entity instanceof BioMaterial) {
        return this.persistBioMaterial((BioMaterial) entity);
    } else if (entity instanceof BioAssay) {
        return this.persistBioAssay((BioAssay) entity, null);
    } else if (entity instanceof Compound) {
        return this.persistCompound((Compound) entity);
    } else if (entity instanceof ExpressionExperimentSubSet) {
        return this.persistExpressionExperimentSubSet((ExpressionExperimentSubSet) entity);
    }
    return super.persist(entity);
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) Compound(ubic.gemma.model.expression.biomaterial.Compound) ArrayDesignsForExperimentCache(ubic.gemma.persistence.util.ArrayDesignsForExperimentCache) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 52 with BioAssayDimension

use of ubic.gemma.model.expression.bioAssayData.BioAssayDimension 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 53 with BioAssayDimension

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

the class QuantitationTypeData method getSignalChannelB.

public ExpressionDataDoubleMatrix getSignalChannelB() {
    if (dat == null)
        dat = this.getQuantitationTypesNeeded();
    List<BioAssayDimension> dimensions = this.getBioAssayDimensions();
    List<QuantitationType> qTypes = new ArrayList<>();
    for (BioAssayDimension dimension : dimensions) {
        QuantitationType qType = dat.getSignalChannelB(dimension);
        if (qType != null)
            qTypes.add(qType);
    }
    if (qTypes.size() != 0) {
        return this.makeMatrix(qTypes);
    }
    return null;
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Example 54 with BioAssayDimension

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

the class QuantitationTypeData method getSignalChannelA.

public ExpressionDataDoubleMatrix getSignalChannelA() {
    if (dat == null)
        dat = this.getQuantitationTypesNeeded();
    List<BioAssayDimension> dimensions = this.getBioAssayDimensions();
    List<QuantitationType> qTypes = new ArrayList<>();
    for (BioAssayDimension dimension : dimensions) {
        QuantitationType signalChannelA = dat.getSignalChannelA(dimension);
        QuantitationType signalChannelB = dat.getSignalChannelB(dimension);
        QuantitationType backgroundChannelA = dat.getBackgroundChannelA(dimension);
        QuantitationType bkgSubChannelA = dat.getBkgSubChannelA(dimension);
        boolean channelANeedsReconstruction = this.checkChannelA(signalChannelA, signalChannelB, backgroundChannelA, bkgSubChannelA);
        if (channelANeedsReconstruction) {
            return this.getSignalChannelAFancy(dimension);
        }
        if (signalChannelA != null)
            qTypes.add(signalChannelA);
    }
    if (qTypes.size() != 0) {
        return this.makeMatrix(qTypes);
    }
    return null;
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Example 55 with BioAssayDimension

use of ubic.gemma.model.expression.bioAssayData.BioAssayDimension 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)

Aggregations

BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)59 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)29 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)20 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)16 DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)15 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)15 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)15 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)11 StandardQuantitationType (ubic.gemma.model.common.quantitationtype.StandardQuantitationType)10 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)9 ProcessedExpressionDataVector (ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)9 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)6 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 Transactional (org.springframework.transaction.annotation.Transactional)4 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)4 StopWatch (org.apache.commons.lang3.time.StopWatch)3 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)3 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)3 DoubleArrayList (cern.colt.list.DoubleArrayList)2