use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.
the class BaseExpressionDataMatrix method selectVectors.
/**
* Selects all the vectors passed in (uses them to initialize the data)
*/
void selectVectors(Collection<? extends DesignElementDataVector> vectors) {
QuantitationType quantitationType = null;
int i = 0;
List<DesignElementDataVector> sorted = this.sortVectorsByDesignElement(vectors);
for (DesignElementDataVector vector : sorted) {
if (this.expressionExperiment == null)
this.expressionExperiment = vector.getExpressionExperiment();
QuantitationType vectorQuantitationType = vector.getQuantitationType();
CompositeSequence designElement = vector.getDesignElement();
this.bioAssayDimensions.put(designElement, vector.getBioAssayDimension());
if (quantitationType == null) {
quantitationType = vectorQuantitationType;
this.getQuantitationTypes().add(vectorQuantitationType);
} else {
if (quantitationType != vectorQuantitationType) {
throw new IllegalArgumentException("Cannot pass vectors from more than one quantitation type");
}
}
this.addToRowMaps(i, designElement);
i++;
}
}
use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.
the class ExpressionExperimentPlatformSwitchService method runOldAd.
private void runOldAd(ExpressionExperiment ee, ArrayDesign arrayDesign, Map<BioSequence, Collection<CompositeSequence>> designElementMap, BioAssayDimension maxBAD, Map<CompositeSequence, Collection<BioAssayDimension>> usedDesignElements, ArrayDesign oldAd) {
if (oldAd.equals(arrayDesign))
return;
oldAd = arrayDesignService.thaw(oldAd);
if (oldAd.getCompositeSequences().size() == 0 && !oldAd.getTechnologyType().equals(TechnologyType.NONE)) {
/*
* Bug 3451 - this is okay if it is a RNA-seq experiment etc. prior to data upload.
*/
throw new IllegalStateException(oldAd + " has no elements");
}
Collection<QuantitationType> qts = expressionExperimentService.getQuantitationTypes(ee, oldAd);
ExpressionExperimentPlatformSwitchService.log.info("Processing " + qts.size() + " quantitation types for vectors on " + oldAd);
for (QuantitationType type : qts) {
// use each design element only once per quantitation type + bioassaydimension per array design
usedDesignElements.clear();
Collection<RawExpressionDataVector> rawForQt = this.getRawVectorsForOneQuantitationType(oldAd, type);
Collection<ProcessedExpressionDataVector> processedForQt = this.getProcessedVectorsForOneQuantitationType(oldAd, type);
if (//
(rawForQt == null || rawForQt.size() == 0) && (processedForQt == null || processedForQt.size() == 0)) {
/*
* This can happen when the quantitation types vary for the array designs.
*/
ExpressionExperimentPlatformSwitchService.log.debug("No vectors for " + type + " on " + oldAd);
continue;
}
// This check assures we do not mix raw and processed vectors further down the line
if ((rawForQt != null && rawForQt.size() > 0) && (processedForQt != null && processedForQt.size() > 0)) {
throw new IllegalStateException("Two types of vector for quantitationType " + type);
}
Collection<DesignElementDataVector> vectors = new HashSet<>();
if (rawForQt != null) {
vectors.addAll(rawForQt);
}
if (processedForQt != null) {
vectors.addAll(processedForQt);
}
ExpressionExperimentPlatformSwitchService.log.info("Switching " + vectors.size() + " vectors for " + type + " from " + oldAd.getShortName() + " to " + arrayDesign.getShortName());
int count = 0;
// noinspection MismatchedQueryAndUpdateOfCollection // Only used for logging
Collection<DesignElementDataVector> unMatched = new HashSet<>();
for (DesignElementDataVector vector : vectors) {
assert RawExpressionDataVector.class.isAssignableFrom(vector.getClass()) : "Unexpected class: " + vector.getClass().getName();
CompositeSequence oldDe = vector.getDesignElement();
if (oldDe.getArrayDesign().equals(arrayDesign)) {
continue;
}
this.processVector(designElementMap, usedDesignElements, vector, maxBAD);
if (++count % 20000 == 0) {
ExpressionExperimentPlatformSwitchService.log.info("Found matches for " + count + " vectors for " + type);
}
}
/*
* This is bad.
*/
if (unMatched.size() > 0) {
throw new IllegalStateException("There were " + unMatched.size() + " vectors that couldn't be matched to the new design for: " + type + ", example: " + unMatched.iterator().next());
}
// Force collection update
if (rawForQt != null && rawForQt.size() > 0) {
int s = ee.getRawExpressionDataVectors().size();
ee.getRawExpressionDataVectors().removeAll(rawForQt);
assert s > ee.getRawExpressionDataVectors().size();
ee.getRawExpressionDataVectors().addAll(rawForQt);
assert s == ee.getRawExpressionDataVectors().size();
} else if (processedForQt != null && processedForQt.size() > 0) {
int s = ee.getProcessedExpressionDataVectors().size();
ee.getProcessedExpressionDataVectors().removeAll(processedForQt);
assert s > ee.getProcessedExpressionDataVectors().size();
ee.getProcessedExpressionDataVectors().addAll(processedForQt);
assert s == ee.getProcessedExpressionDataVectors().size();
}
}
}
use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.
the class RawExpressionDataVectorDaoImpl method find.
@Override
public RawExpressionDataVector find(RawExpressionDataVector designElementDataVector) {
BusinessKey.checkKey(designElementDataVector);
DetachedCriteria crit = DetachedCriteria.forClass(RawExpressionDataVector.class);
crit.createCriteria("designElement").add(Restrictions.eq("name", designElementDataVector.getDesignElement().getName())).createCriteria("arrayDesign").add(Restrictions.eq("name", designElementDataVector.getDesignElement().getArrayDesign().getName()));
crit.createCriteria("quantitationType").add(Restrictions.eq("name", designElementDataVector.getQuantitationType().getName()));
crit.createCriteria("expressionExperiment").add(Restrictions.eq("name", designElementDataVector.getExpressionExperiment().getName()));
List<?> results = this.getHibernateTemplate().findByCriteria(crit);
Object result = null;
if (results != null) {
if (results.size() > 1) {
throw new org.springframework.dao.InvalidDataAccessResourceUsageException("More than one instance of '" + DesignElementDataVector.class.getName() + "' was found when executing query");
} else if (results.size() == 1) {
result = results.iterator().next();
}
}
return (RawExpressionDataVector) result;
}
use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.
the class QuantitationTypeData method getPreferredDataVectors.
/**
* @return The 'preferred' data vectors - NOT the processed data vectors!
*/
private Collection<DesignElementDataVector> getPreferredDataVectors() {
Collection<DesignElementDataVector> result = new HashSet<>();
List<BioAssayDimension> dimensions = this.getBioAssayDimensions();
List<QuantitationType> qtypes = this.getPreferredQTypes();
for (DesignElementDataVector vector : vectors) {
if (!(vector instanceof ProcessedExpressionDataVector) && dimensions.contains(vector.getBioAssayDimension()) && qtypes.contains(vector.getQuantitationType()))
result.add(vector);
}
return result;
}
use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.
the class QuantitationTypeData method populateMissingValueInfo.
private void populateMissingValueInfo() {
ByteArrayConverter bac = new ByteArrayConverter();
for (DesignElementDataVector vector : vectors) {
QuantitationType qt = vector.getQuantitationType();
if (!numMissingValues.containsKey(qt)) {
numMissingValues.put(qt, 0);
}
for (Double d : bac.byteArrayToDoubles(vector.getData())) {
if (d.isNaN()) {
anyMissing = true;
numMissingValues.put(qt, numMissingValues.get(qt) + 1);
}
}
}
}
Aggregations