use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class AbstractMatrixRowPairAnalysis method init.
/**
* Initialize caches.
*/
private void init() {
this.initGeneToProbeMap();
List<ExpressionDataMatrixRowElement> rowElements = this.dataMatrix.getRowElements();
hasGenesCache = new boolean[rowElements.size()];
for (ExpressionDataMatrixRowElement element : rowElements) {
CompositeSequence de = element.getDesignElement();
rowMapCache.put(element, de);
Set<Gene> geneIdSet = this.probeToGeneMap.get(de);
Integer i = element.getIndex();
hasGenesCache[i] = geneIdSet != null && geneIdSet.size() > 0;
}
assert rowMapCache.size() > 0;
AbstractMatrixRowPairAnalysis.log.info("Initialized caches for probe/gene information");
}
use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class DiffExMetaAnalyzerServiceImpl method checkAndAddResultSet.
private void checkAndAddResultSet(Collection<DifferentialExpressionAnalysisResult> resultsToUse, Collection<CompositeSequence> probes, ExpressionAnalysisResultSet rs) {
Collection<DifferentialExpressionAnalysisResult> results = rs.getResults();
DiffExMetaAnalyzerServiceImpl.log.info(results.size() + " results to check ...");
for (DifferentialExpressionAnalysisResult r : results) {
assert r != null;
CompositeSequence probe = r.getProbe();
assert probe != null;
probes.add(probe);
boolean added = resultsToUse.add(r);
assert added : "Failed to add: " + r;
}
DiffExMetaAnalyzerServiceImpl.log.info(results.size() + " results checked for resultset with ID=" + rs.getId() + ", found " + probes.size() + " probes/elements so far for " + resultsToUse.size() + " results in total ...");
}
use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class AffyPowerToolsProbesetSummarize method convertDesignElementDataVectors.
/**
* Stolen from SimpleExpressionDataLoaderService
*
* @param expressionExperiment ee
* @param bioAssayDimension BA dim
* @param arrayDesign target design
* @param matrix matrix
* @return raw data vectors
*/
private Collection<RawExpressionDataVector> convertDesignElementDataVectors(ExpressionExperiment expressionExperiment, BioAssayDimension bioAssayDimension, ArrayDesign arrayDesign, DoubleMatrix<String, String> matrix) {
ByteArrayConverter bArrayConverter = new ByteArrayConverter();
Collection<RawExpressionDataVector> vectors = new HashSet<>();
Map<String, CompositeSequence> csMap = new HashMap<>();
for (CompositeSequence cs : arrayDesign.getCompositeSequences()) {
csMap.put(cs.getName(), cs);
}
for (int i = 0; i < matrix.rows(); i++) {
byte[] bdata = bArrayConverter.doubleArrayToBytes(matrix.getRow(i));
RawExpressionDataVector vector = RawExpressionDataVector.Factory.newInstance();
vector.setData(bdata);
CompositeSequence cs = csMap.get(matrix.getRowName(i));
if (cs == null) {
continue;
}
vector.setDesignElement(cs);
vector.setQuantitationType(this.quantitationType);
vector.setExpressionExperiment(expressionExperiment);
vector.setBioAssayDimension(bioAssayDimension);
vectors.add(vector);
}
AffyPowerToolsProbesetSummarize.log.info("Setup " + vectors.size() + " data vectors for " + matrix.rows() + " results from APT");
return vectors;
}
use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class ArrayDesignMergeServiceImpl method makeBioSeqMap.
/**
* If we're merging into an existing platform, it is important that this method is called for that platform first.
*
* @param globalBsMap Map that tells us, in effect, how many probes to make for the sequence. Modified by this.
*/
private ArrayDesign makeBioSeqMap(Map<BioSequence, Collection<CompositeSequence>> globalBsMap, ArrayDesign arrayDesign) {
Map<BioSequence, Collection<CompositeSequence>> bsMap = new HashMap<>();
arrayDesign = this.arrayDesignService.thaw(arrayDesign);
int count = 0;
for (CompositeSequence cs : arrayDesign.getCompositeSequences()) {
BioSequence bs = cs.getBiologicalCharacteristic();
if (bs == null) {
// this is common. We could try to match them up based on the probe name, because there is nothing else
// to go on.
bs = ExpressionExperimentPlatformSwitchService.NULL_BIOSEQUENCE;
}
if (!globalBsMap.containsKey(bs)) {
globalBsMap.put(bs, new HashSet<CompositeSequence>());
}
if (!bsMap.containsKey(bs)) {
bsMap.put(bs, new HashSet<CompositeSequence>());
}
bsMap.get(bs).add(cs);
/*
* We need at one probe for each time the sequence appears on one platform. Here we ensure that the global
* map has enough 'slots'.
*/
if (globalBsMap.get(bs).size() < bsMap.get(bs).size()) {
globalBsMap.get(bs).add(cs);
}
}
if (++count % 10000 == 0) {
ArrayDesignMergeServiceImpl.log.info("Processed " + count + " probes");
}
return arrayDesign;
}
use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.
the class ArrayDesignMergeServiceImpl method makeNewProbes.
/**
* Makes the new or additional probes (non-persistent) for the merged array design. If mergeWithExisting=true,
* probes from arrayDesign will not be included; just the ones that we need to add to it will be returned.
*
* @param globalBsMap Map that tells us, in effect, how many probes to make for the sequence.
*/
private Collection<CompositeSequence> makeNewProbes(ArrayDesign arrayDesign, Map<BioSequence, Collection<CompositeSequence>> globalBsMap, boolean mergeWithExisting) {
Collection<CompositeSequence> newProbes = new HashSet<>();
ArrayDesignMergeServiceImpl.log.info(globalBsMap.size() + " unique sequences");
Collection<String> probeNames = new HashSet<>();
for (BioSequence bs : globalBsMap.keySet()) {
// should be the placeholder NULL_BIOSEQUENCE
assert bs != null;
for (CompositeSequence cs : globalBsMap.get(bs)) {
if (mergeWithExisting && cs.getArrayDesign().equals(arrayDesign)) {
assert arrayDesign.getId() != null;
/*
* Only add probes from the _other_ array designs.
*/
continue;
}
CompositeSequence newCs = CompositeSequence.Factory.newInstance();
if (!bs.equals(ExpressionExperimentPlatformSwitchService.NULL_BIOSEQUENCE)) {
newCs.setBiologicalCharacteristic(bs);
}
String name = this.getProbeName(probeNames, cs);
probeNames.add(name);
newCs.setName(name);
newCs.setDescription((cs.getDescription() == null ? "" : cs.getDescription()) + " (via merge)");
newCs.setArrayDesign(arrayDesign);
newProbes.add(newCs);
if (ArrayDesignMergeServiceImpl.log.isDebugEnabled())
ArrayDesignMergeServiceImpl.log.debug("Made merged probe for " + bs + ": " + newCs + " for old probe on " + cs.getArrayDesign().getShortName());
}
}
ArrayDesignMergeServiceImpl.log.info("Made " + newProbes.size() + " new probes");
return newProbes;
}
Aggregations