use of ubic.gemma.core.analysis.preprocess.batcheffects.BatchEffectDetails in project Gemma by PavlidisLab.
the class GeeqServiceImpl method scoreBatchEffect.
private void scoreBatchEffect(ExpressionExperiment ee, Geeq gq, boolean infoDetected) {
double score;
boolean hasInfo = true;
boolean hasStrong = false;
boolean hasNone = false;
boolean corrected = false;
if (infoDetected) {
boolean manual = gq.isManualBatchEffectActive();
if (!manual) {
BatchEffectDetails be = expressionExperimentService.getBatchEffect(ee);
if (be == null) {
Log.warn(this.getClass(), GeeqServiceImpl.ERR_B_EFFECT_BAD_STATE);
hasInfo = false;
} else {
hasStrong = be.getPvalue() < 0.0001;
hasNone = be.getPvalue() > 0.1;
corrected = be.getDataWasBatchCorrected();
}
} else {
hasStrong = gq.isManualHasStrongBatchEffect();
hasNone = gq.isManualHasNoBatchEffect();
}
}
score = !infoDetected || !hasInfo ? GeeqServiceImpl.P_00 : hasStrong ? GeeqServiceImpl.BATCH_EFF_STRONG : hasNone ? GeeqServiceImpl.BATCH_EFF_NONE : GeeqServiceImpl.BATCH_EFF_WEAK;
gq.setBatchCorrected(corrected);
gq.setqScoreBatchEffect(score);
}
use of ubic.gemma.core.analysis.preprocess.batcheffects.BatchEffectDetails in project Gemma by PavlidisLab.
the class LinkAnalysisServiceImpl method qcCheck.
/**
* Reject if experiment has outliers or batch effects.
*/
private void qcCheck(LinkAnalysisConfig config, ExpressionExperiment ee) throws UnsuitableForAnalysisException {
if (config.isCheckForOutliers()) {
Collection<OutlierDetails> outliers = outlierDetectionService.identifyOutliersByMedianCorrelation(ee);
if (!outliers.isEmpty()) {
throw new UnsuitableForAnalysisException(ee, "Potential outlier samples detected");
}
}
if (config.isCheckForBatchEffect()) {
BatchEffectDetails batchEffect = eeService.getBatchEffect(ee);
if (batchEffect.getDataWasBatchCorrected()) {
LinkAnalysisServiceImpl.log.info("Data are batch-corrected");
return;
}
if (batchEffect.hasNoBatchInfo()) {
// we may change this behaviour...
throw new UnsuitableForAnalysisException(ee, "No batch information available, out of an abundance of caution we are skipping");
}
if (batchEffect.getPvalue() < 0.001) {
double componentVarianceProportion = batchEffect.getComponentVarianceProportion();
Integer component = batchEffect.getComponent();
// this far.
if (component > 2 && componentVarianceProportion < 0.1) {
return;
}
throw new UnsuitableForAnalysisException(ee, String.format("Strong batch effect detected (%s)", batchEffect));
}
}
}
use of ubic.gemma.core.analysis.preprocess.batcheffects.BatchEffectDetails in project Gemma by PavlidisLab.
the class ExpressionExperimentServiceImpl method getBatchEffect.
@Override
@Transactional(readOnly = true)
public BatchEffectDetails getBatchEffect(ExpressionExperiment ee) {
ee = this.thawLiter(ee);
BatchEffectDetails details = new BatchEffectDetails(this.checkHasBatchInfo(ee), this.getHasBeenBatchCorrected(ee));
if (details.hasNoBatchInfo())
return details;
for (ExperimentalFactor ef : ee.getExperimentalDesign().getExperimentalFactors()) {
if (BatchInfoPopulationServiceImpl.isBatchFactor(ef)) {
SVDValueObject svd = svdService.getSvdFactorAnalysis(ee.getId());
if (svd == null)
break;
double minP = 1.0;
for (Integer component : svd.getFactorPvals().keySet()) {
Map<Long, Double> cmpEffects = svd.getFactorPvals().get(component);
Double pVal = cmpEffects.get(ef.getId());
if (pVal != null && pVal < minP) {
details.setPvalue(pVal);
details.setComponent(component + 1);
details.setComponentVarianceProportion(svd.getVariances()[component]);
minP = pVal;
}
}
return details;
}
}
return details;
}
use of ubic.gemma.core.analysis.preprocess.batcheffects.BatchEffectDetails in project Gemma by PavlidisLab.
the class ExpressionExperimentServiceImpl method getBatchEffectDescription.
@Override
@Transactional(readOnly = true)
public String getBatchEffectDescription(ExpressionExperiment ee) {
BatchEffectDetails beDetails = this.getBatchEffect(ee);
String result = "";
if (beDetails == null || beDetails.hasNoBatchInfo()) {
result = "";
} else {
if (beDetails.getDataWasBatchCorrected()) {
// Checked for in ExpressionExperimentDetails.js::renderStatus()
result = "Data has been batch-corrected";
} else if (beDetails.getComponent() != null && beDetails.getPvalue() < ExpressionExperimentServiceImpl.BATCH_EFFECT_THRESHOLD) {
String pc = beDetails.getComponent() != null ? " (PC " + beDetails.getComponent() + ")" : "";
result = "This data set may have a batch artifact" + pc + ", p=" + String.format("%.2g", beDetails.getPvalue());
}
}
return Strings.emptyToNull(result);
}
Aggregations