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;
}
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;
}
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;
}
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);
}
}
}
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;
}
Aggregations