Search in sources :

Example 21 with BioAssaySet

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

the class ExpressionDataCorrMatCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception exception = this.processCommandLine(args);
    for (BioAssaySet ee : expressionExperiments) {
        try {
            if (!(ee instanceof ExpressionExperiment)) {
                errorObjects.add(ee);
                continue;
            }
            this.processExperiment((ExpressionExperiment) ee);
            successObjects.add(ee);
        } catch (Exception e) {
            AbstractCLI.log.error("Error while processing " + ee, e);
            errorObjects.add(ee);
        }
    }
    this.summarizeProcessing();
    return exception;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 22 with BioAssaySet

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

the class DeleteExperimentsCli method doWork.

@Override
protected Exception doWork(String[] args) {
    this.force = true;
    Exception e = super.processCommandLine(args);
    if (e != null)
        return e;
    for (BioAssaySet bas : this.expressionExperiments) {
        this.eeService.remove((ExpressionExperiment) bas);
    }
    return null;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet)

Example 23 with BioAssaySet

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

the class ExpressionExperimentDataFileGeneratorCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception exp = this.processCommandLine(args);
    if (exp != null) {
        return exp;
    }
    BlockingQueue<BioAssaySet> queue = new ArrayBlockingQueue<>(expressionExperiments.size());
    // Add the Experiments to the queue for processing
    for (BioAssaySet ee : expressionExperiments) {
        if (ee instanceof ExpressionExperiment) {
            try {
                queue.put(ee);
            } catch (InterruptedException ie) {
                AbstractCLI.log.info(ie);
            }
        } else {
            throw new UnsupportedOperationException("Can't handle non-EE BioAssaySets yet");
        }
    }
    // Inner class for processing the experiments
    class Worker extends Thread {

        private SecurityContext context;

        private BlockingQueue<BioAssaySet> q;

        private Worker(BlockingQueue<BioAssaySet> q, SecurityContext context) {
            this.context = context;
            this.q = q;
        }

        @Override
        public void run() {
            SecurityContextHolder.setContext(this.context);
            while (true) {
                BioAssaySet ee = q.poll();
                if (ee == null) {
                    break;
                }
                AbstractCLI.log.info("Processing Experiment: " + ee.getName());
                ExpressionExperimentDataFileGeneratorCli.this.processExperiment((ExpressionExperiment) ee);
            }
        }
    }
    final SecurityContext context = SecurityContextHolder.getContext();
    Collection<Thread> threads = new ArrayList<>();
    for (int i = 1; i <= this.numThreads; i++) {
        Worker worker = new Worker(queue, context);
        threads.add(worker);
        AbstractCLI.log.info("Starting thread " + i);
        worker.start();
    }
    this.waitForThreadPoolCompletion(threads);
    this.summarizeProcessing();
    return null;
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ArrayList(java.util.ArrayList) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) SecurityContext(org.springframework.security.core.context.SecurityContext)

Example 24 with BioAssaySet

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

the class DiffExMetaAnalyzerServiceImpl method validate.

private void validate(ExpressionAnalysisResultSet rs) {
    if (rs.getExperimentalFactors().size() > 1) {
        throw new IllegalArgumentException("Cannot do a meta-analysis on interaction terms");
    }
    ExperimentalFactor factor = rs.getExperimentalFactors().iterator().next();
    /*
         * We need to check this just in the subset of samples actually used.
         */
    BioAssaySet experimentAnalyzed = rs.getAnalysis().getExperimentAnalyzed();
    assert experimentAnalyzed != null;
    if (experimentAnalyzed instanceof ExpressionExperimentSubSet) {
        ExpressionExperimentSubSet eesubset = (ExpressionExperimentSubSet) experimentAnalyzed;
        Collection<FactorValue> factorValuesUsed = expressionExperimentSubSetService.getFactorValuesUsed(eesubset, factor);
        if (factorValuesUsed.size() > 2) {
            throw new IllegalArgumentException("Cannot do a meta-analysis including a factor that has more than two levels: " + factor + " has " + factor.getFactorValues().size() + " levels from " + experimentAnalyzed);
        }
    } else {
        if (factor.getFactorValues().size() > 2) {
            /*
                 * Note that this doesn't account for continuous factors.
                 */
            throw new IllegalArgumentException("Cannot do a meta-analysis including a factor that has more than two levels: " + factor + " has " + factor.getFactorValues().size() + " levels from " + experimentAnalyzed);
        }
    }
}
Also used : FactorValue(ubic.gemma.model.expression.experiment.FactorValue) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) ExpressionExperimentSubSet(ubic.gemma.model.expression.experiment.ExpressionExperimentSubSet)

Example 25 with BioAssaySet

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

the class ExpressionExperimentSetServiceImpl method createFromValueObject.

@Override
@Transactional
public ExpressionExperimentSet createFromValueObject(ExpressionExperimentSetValueObject eesvo) {
    /*
         * Sanity check.
         */
    Collection<ExpressionExperimentSet> dups = this.findByName(eesvo.getName());
    if (dups == null || !dups.isEmpty()) {
        throw new IllegalArgumentException("Sorry, there is already a set with that name (" + eesvo.getName() + ")");
    }
    ExpressionExperimentSet newSet = ExpressionExperimentSet.Factory.newInstance();
    newSet.setName(eesvo.getName());
    newSet.setDescription(eesvo.getDescription());
    Collection<? extends BioAssaySet> datasetsAnalyzed = expressionExperimentService.load(eesvo.getExpressionExperimentIds());
    newSet.getExperiments().addAll(datasetsAnalyzed);
    if (eesvo.getTaxonId() != null)
        newSet.setTaxon(taxonService.load(eesvo.getTaxonId()));
    else {
        /*
             * Figure out the taxon from the experiments. mustn't be heterogeneous.
             */
        Taxon taxon = null;
        for (BioAssaySet bioAssaySet : newSet.getExperiments()) {
            Taxon eeTaxon = this.getTaxonForSet(bioAssaySet);
            if (taxon == null) {
                taxon = eeTaxon;
            } else {
                assert eeTaxon != null;
                if (!eeTaxon.equals(taxon)) {
                    throw new UnsupportedOperationException("EESets with mixed taxa are not supported");
                }
            }
        }
        if (taxon == null) {
            throw new IllegalStateException("Could not determine taxon for new EEset");
        }
        newSet.setTaxon(taxon);
    }
    if (newSet.getTaxon() == null) {
        throw new IllegalArgumentException("Unable to determine the taxon for the EESet");
    }
    ExpressionExperimentSet newEESet = this.create(newSet);
    // make groups private by default
    if (eesvo.getIsPublic()) {
        securityService.makePublic(newEESet);
    } else {
        securityService.makePrivate(newEESet);
    }
    return newEESet;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) Transactional(org.springframework.transaction.annotation.Transactional)

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