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