use of ubic.gemma.model.expression.bioAssayData.ExperimentExpressionLevelsValueObject in project Gemma by PavlidisLab.
the class ProcessedExpressionDataVectorServiceImpl method addExperimentGeneVectors.
/**
* Creates an ExperimentExpressionLevelValueObject for the given experiment and collection of double vector VOs, and
* adds it to the given vos collection.
*
* @param vos the collection to add the result to.
* @param ee the experiment the vectors belong to.
* @param vectors the vectors to create the new ExperimentExpressionLevelsVO with.
*/
private void addExperimentGeneVectors(Collection<ExperimentExpressionLevelsValueObject> vos, ExpressionExperiment ee, Collection<DoubleVectorValueObject> vectors, boolean keepGeneNonSpecific, String consolidateMode) {
Map<Gene, List<DoubleVectorValueObject>> vectorsPerGene = new HashMap<>();
if (vectors == null) {
return;
}
for (DoubleVectorValueObject v : vectors) {
if (!v.getExpressionExperiment().getId().equals(ee.getId())) {
continue;
}
if (v.getGenes() == null || v.getGenes().isEmpty()) {
if (!vectorsPerGene.containsKey(null)) {
vectorsPerGene.put(null, new LinkedList<DoubleVectorValueObject>());
}
vectorsPerGene.get(null).add(v);
}
for (Long gId : v.getGenes()) {
Gene g = geneService.load(gId);
if (g != null) {
if (!vectorsPerGene.containsKey(g)) {
vectorsPerGene.put(g, new LinkedList<DoubleVectorValueObject>());
}
vectorsPerGene.get(g).add(v);
}
}
}
vos.add(new ExperimentExpressionLevelsValueObject(ee.getId(), vectorsPerGene, keepGeneNonSpecific, consolidateMode));
}
use of ubic.gemma.model.expression.bioAssayData.ExperimentExpressionLevelsValueObject in project Gemma by PavlidisLab.
the class ProcessedExpressionDataVectorServiceImpl method getExpressionLevels.
@Override
@Transactional(readOnly = true)
public Collection<ExperimentExpressionLevelsValueObject> getExpressionLevels(Collection<ExpressionExperiment> ees, Collection<Gene> genes, boolean keepGeneNonSpecific, String consolidateMode) {
Collection<DoubleVectorValueObject> vectors = this.getProcessedDataArrays(ees, EntityUtils.getIds(genes));
Collection<ExperimentExpressionLevelsValueObject> vos = new ArrayList<>(ees.size());
// Adapted from DEDV controller
for (ExpressionExperiment ee : ees) {
Map<Gene, List<DoubleVectorValueObject>> vectorsPerGene = new HashMap<>();
for (DoubleVectorValueObject v : vectors) {
if (!v.getExpressionExperiment().getId().equals(ee.getId())) {
continue;
}
if (v.getGenes() == null || v.getGenes().isEmpty()) {
continue;
}
for (Gene g : genes) {
if (v.getGenes().contains(g.getId())) {
if (!vectorsPerGene.containsKey(g)) {
vectorsPerGene.put(g, new LinkedList<DoubleVectorValueObject>());
}
vectorsPerGene.get(g).add(v);
}
}
}
vos.add(new ExperimentExpressionLevelsValueObject(ee.getId(), vectorsPerGene, keepGeneNonSpecific, consolidateMode));
}
return vos;
}
use of ubic.gemma.model.expression.bioAssayData.ExperimentExpressionLevelsValueObject in project Gemma by PavlidisLab.
the class ProcessedExpressionDataVectorServiceImpl method getExpressionLevelsDiffEx.
@Override
@Transactional(readOnly = true)
public Collection<ExperimentExpressionLevelsValueObject> getExpressionLevelsDiffEx(Collection<ExpressionExperiment> ees, Long diffExResultSetId, double threshold, int max, boolean keepGeneNonSpecific, String consolidateMode) {
Collection<ExperimentExpressionLevelsValueObject> vos = new ArrayList<>();
// Adapted from DEDV controller
for (ExpressionExperiment ee : ees) {
Collection<DoubleVectorValueObject> vectors = this.getDiffExVectors(diffExResultSetId, threshold, max);
this.addExperimentGeneVectors(vos, ee, vectors, keepGeneNonSpecific, consolidateMode);
}
return vos;
}
use of ubic.gemma.model.expression.bioAssayData.ExperimentExpressionLevelsValueObject in project Gemma by PavlidisLab.
the class ProcessedExpressionDataVectorServiceImpl method getExpressionLevelsPca.
@Override
@Transactional(readOnly = true)
public Collection<ExperimentExpressionLevelsValueObject> getExpressionLevelsPca(Collection<ExpressionExperiment> ees, int limit, int component, boolean keepGeneNonSpecific, String consolidateMode) {
Collection<ExperimentExpressionLevelsValueObject> vos = new ArrayList<>(ees.size());
// Adapted from DEDV controller
for (ExpressionExperiment ee : ees) {
Collection<DoubleVectorValueObject> vectors = svdService.getTopLoadedVectors(ee.getId(), component, limit).values();
this.addExperimentGeneVectors(vos, ee, vectors, keepGeneNonSpecific, consolidateMode);
}
return vos;
}
Aggregations