Search in sources :

Example 31 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class RelationshipPersister method persistExpressionExperimentSet.

private ExpressionExperimentSet persistExpressionExperimentSet(ExpressionExperimentSet entity) {
    if (!this.isTransient(entity))
        return entity;
    Collection<BioAssaySet> setMembers = new HashSet<>();
    for (BioAssaySet baSet : entity.getExperiments()) {
        if (this.isTransient(baSet)) {
            baSet = (BioAssaySet) this.persist(baSet);
        }
        setMembers.add(baSet);
    }
    entity.getExperiments().clear();
    entity.getExperiments().addAll(setMembers);
    return expressionExperimentSetDao.create(entity);
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) HashSet(java.util.HashSet)

Example 32 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class ExpressionExperimentSetValueObjectHelperImpl method convertToEntity.

/*
     * @see
     * ubic.gemma.core.expression.experiment.ExpressionExperimentSetValueObjectHelper#convertToLightValueObject(ubic.gemma
     * .model.analysis.expression.ExpressionExperimentSet)
     */
@Override
public ExpressionExperimentSet convertToEntity(ExpressionExperimentSetValueObject setVO) {
    if (setVO == null) {
        return null;
    }
    ExpressionExperimentSet entity;
    if (setVO.getId() == null || setVO.getId() < 0) {
        entity = ExpressionExperimentSet.Factory.newInstance();
        entity.setId(null);
    } else {
        entity = expressionExperimentSetService.load(setVO.getId());
    }
    entity.setDescription(setVO.getDescription());
    Collection<ExpressionExperiment> experiments = expressionExperimentService.load(setVO.getExpressionExperimentIds());
    if (experiments.isEmpty()) {
        throw new IllegalArgumentException("The value object must have some experiments associated before it can be converted and persisted");
    }
    Collection<BioAssaySet> bas = new HashSet<BioAssaySet>(experiments);
    entity.setExperiments(bas);
    entity.setName(setVO.getName());
    if (setVO.getTaxonId() != null && setVO.getTaxonId() >= 0) {
        Taxon tax = taxonService.load(setVO.getTaxonId());
        entity.setTaxon(tax);
    } else {
        Log.debug("Trying to convert DatabaseBackedExpressionExperimentSetValueObject with id =" + setVO.getId() + " to ExpressionExperimentSet entity. Unmatched ValueObject.getTaxonId() was :" + setVO.getTaxonId());
    }
    return entity;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) HashSet(java.util.HashSet)

Example 33 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class RNASeqDataAddCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception exception = super.processCommandLine(args);
    if (exception != null)
        return exception;
    DataUpdater serv = this.getBean(DataUpdater.class);
    if (this.justbackfillLog2cpm) {
        for (BioAssaySet bas : this.expressionExperiments) {
            try {
                ExpressionExperiment ee = (ExpressionExperiment) bas;
                Collection<QuantitationType> pqts = this.eeService.getPreferredQuantitationType(ee);
                if (pqts.size() > 1)
                    throw new IllegalArgumentException("Cannot process when there is more than one preferred QT");
                if (pqts.isEmpty())
                    throw new IllegalArgumentException("No preferred quantitation type for " + ee.getShortName());
                QuantitationType qt = pqts.iterator().next();
                if (!qt.getType().equals(StandardQuantitationType.COUNT)) {
                    AbstractCLI.log.warn("Preferred data is not counts for " + ee);
                    this.errorObjects.add(ee.getShortName() + ": Preferred data is not counts");
                    continue;
                }
                serv.log2cpmFromCounts(ee, qt);
                this.successObjects.add(ee);
            } catch (Exception e) {
                AbstractCLI.log.error(e, e);
                this.errorObjects.add(((ExpressionExperiment) bas).getShortName() + ": " + e.getMessage());
            }
        }
        this.summarizeProcessing();
        return null;
    }
    /*
         * Usual cases.
         */
    if (this.expressionExperiments.size() > 1) {
        throw new IllegalArgumentException("Sorry, can only process one experiment with this tool.");
    }
    ArrayDesign targetArrayDesign = this.locateArrayDesign(this.platformName);
    ExpressionExperiment ee = (ExpressionExperiment) this.expressionExperiments.iterator().next();
    if (this.expressionExperiments.size() > 1) {
        AbstractCLI.log.warn("This CLI can only deal with one experiment at a time; only the first one will be processed");
    }
    DoubleMatrixReader reader = new DoubleMatrixReader();
    try {
        DoubleMatrix<String, String> countMatrix = null;
        DoubleMatrix<String, String> rpkmMatrix = null;
        if (this.countFile != null) {
            countMatrix = reader.read(countFile);
        }
        if (this.rpkmFile != null) {
            rpkmMatrix = reader.read(rpkmFile);
        }
        serv.addCountData(ee, targetArrayDesign, countMatrix, rpkmMatrix, readLength, isPairedReads, allowMissingSamples);
    } catch (IOException e) {
        AbstractCLI.log.error("Failed while processing " + ee, e);
        return e;
    }
    return null;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) DataUpdater(ubic.gemma.core.loader.expression.geo.DataUpdater) IOException(java.io.IOException) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) IOException(java.io.IOException) DoubleMatrixReader(ubic.basecode.io.reader.DoubleMatrixReader)

Example 34 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class SVDCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = super.processCommandLine(args);
    if (err != null)
        return err;
    SVDService svdService = this.getBean(SVDService.class);
    for (BioAssaySet bas : this.expressionExperiments) {
        if (!force && this.noNeedToRun(bas, PCAAnalysisEvent.class)) {
            this.errorObjects.add(bas + ": Already has PCA; use -force to override");
            continue;
        }
        try {
            AbstractCLI.log.info("Processing: " + bas);
            ExpressionExperiment ee = (ExpressionExperiment) bas;
            svdService.svd(ee.getId());
            this.successObjects.add(bas.toString());
        } catch (Exception e) {
            AbstractCLI.log.error(e, e);
            this.errorObjects.add(bas + ": " + e.getMessage());
        }
    }
    this.summarizeProcessing();
    return null;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) SVDService(ubic.gemma.core.analysis.preprocess.svd.SVDService) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) PCAAnalysisEvent(ubic.gemma.model.common.auditAndSecurity.eventType.PCAAnalysisEvent)

Example 35 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class TwoChannelMissingValueCLI method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = this.processCommandLine(args);
    if (err != null)
        return err;
    for (BioAssaySet ee : expressionExperiments) {
        if (ee instanceof ExpressionExperiment) {
            this.processForMissingValues((ExpressionExperiment) ee);
        } else {
            throw new UnsupportedOperationException("Can't do two-channel missing values on " + ee.getClass().getName());
        }
    }
    this.summarizeProcessing();
    return null;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) PreprocessingException(ubic.gemma.core.analysis.preprocess.PreprocessingException)

Aggregations

BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)39 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)25 HashSet (java.util.HashSet)6 ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)6 Taxon (ubic.gemma.model.genome.Taxon)6 IOException (java.io.IOException)4 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)4 ArrayList (java.util.ArrayList)3 StopWatch (org.apache.commons.lang3.time.StopWatch)3 Transactional (org.springframework.transaction.annotation.Transactional)3 SecurityService (gemma.gsec.SecurityService)2 Element (org.w3c.dom.Element)2 PreprocessingException (ubic.gemma.core.analysis.preprocess.PreprocessingException)2 DataUpdater (ubic.gemma.core.loader.expression.geo.DataUpdater)2 DifferentialExpressionValueObject (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionValueObject)2 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)2 ExpressionExperimentSubSet (ubic.gemma.model.expression.experiment.ExpressionExperimentSubSet)2 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1