use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector 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.DesignElementDataVector in project Gemma by PavlidisLab.
the class QuantitationTypeData method getRanksByMean.
public Map<CompositeSequence, Double> getRanksByMean() {
Collection<QuantitationType> qtypes = this.getPreferredQTypes();
Map<CompositeSequence, Double> ranks = new HashMap<>();
for (DesignElementDataVector v : this.vectors) {
if (qtypes.contains(v.getQuantitationType()) && v instanceof ProcessedExpressionDataVector) {
ranks.put(v.getDesignElement(), ((ProcessedExpressionDataVector) v).getRankByMean());
}
}
return ranks;
}
use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector 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;
}
use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.
the class BaseExpressionDataMatrix method selectVectors.
Collection<DesignElementDataVector> selectVectors(Collection<? extends DesignElementDataVector> vectors, List<QuantitationType> qTypes) {
this.quantitationTypes.addAll(qTypes);
List<DesignElementDataVector> sorted = this.sortVectorsByDesignElement(vectors);
Collection<DesignElementDataVector> vectorsOfInterest = new LinkedHashSet<>();
int rowIndex = 0;
for (QuantitationType soughtType : qTypes) {
for (DesignElementDataVector vector : sorted) {
QuantitationType vectorQuantitationType = vector.getQuantitationType();
if (vectorQuantitationType.equals(soughtType)) {
if (this.expressionExperiment == null)
this.expressionExperiment = vector.getExpressionExperiment();
vectorsOfInterest.add(vector);
this.getQuantitationTypes().add(vectorQuantitationType);
CompositeSequence designElement = vector.getDesignElement();
this.bioAssayDimensions.put(designElement, vector.getBioAssayDimension());
this.addToRowMaps(rowIndex, designElement);
rowIndex++;
}
}
}
BaseExpressionDataMatrix.log.debug("Selected " + vectorsOfInterest.size() + " vectors");
return vectorsOfInterest;
}
use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.
the class BaseExpressionDataMatrix method selectVectors.
Collection<DesignElementDataVector> selectVectors(Collection<? extends DesignElementDataVector> vectors, Collection<QuantitationType> qTypes) {
this.quantitationTypes.addAll(qTypes);
Collection<DesignElementDataVector> vectorsOfInterest = new LinkedHashSet<>();
int i = 0;
for (DesignElementDataVector vector : vectors) {
QuantitationType vectorQuantitationType = vector.getQuantitationType();
if (qTypes.contains(vectorQuantitationType)) {
if (this.expressionExperiment == null)
this.expressionExperiment = vector.getExpressionExperiment();
vectorsOfInterest.add(vector);
CompositeSequence designElement = vector.getDesignElement();
bioAssayDimensions.put(designElement, vector.getBioAssayDimension());
this.addToRowMaps(i, designElement);
this.getQuantitationTypes().add(vectorQuantitationType);
i++;
}
}
return vectorsOfInterest;
}
Aggregations