use of ubic.basecode.io.ByteArrayConverter in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalyzerServiceImpl method addPvalueDistribution.
private void addPvalueDistribution(ExpressionAnalysisResultSet resultSet) {
Histogram pvalHist = new Histogram("", 100, 0.0, 1.0);
for (DifferentialExpressionAnalysisResult result : resultSet.getResults()) {
Double pvalue = result.getPvalue();
if (pvalue != null)
pvalHist.fill(pvalue);
}
PvalueDistribution pvd = PvalueDistribution.Factory.newInstance();
pvd.setNumBins(100);
ByteArrayConverter bac = new ByteArrayConverter();
pvd.setBinCounts(bac.doubleArrayToBytes(pvalHist.getArray()));
// do not save yet.
resultSet.setPvalueDistribution(pvd);
}
use of ubic.basecode.io.ByteArrayConverter 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);
}
}
}
}
use of ubic.basecode.io.ByteArrayConverter in project Gemma by PavlidisLab.
the class CoexpressionDaoImpl method updateRelativeNodeDegrees.
@Override
@Transactional
public void updateRelativeNodeDegrees(Map<Long, List<Double>> relRanksPerGenePositive, Map<Long, List<Double>> relRanksPerGeneNegative) {
Session session = this.getSessionFactory().getCurrentSession();
ByteArrayConverter bac = new ByteArrayConverter();
int i = 0;
for (Long g : relRanksPerGenePositive.keySet()) {
i = this.process(relRanksPerGenePositive.get(g), session, bac, i, g, true);
}
for (Long g : relRanksPerGeneNegative.keySet()) {
i = this.process(relRanksPerGeneNegative.get(g), session, bac, i, g, false);
}
}
use of ubic.basecode.io.ByteArrayConverter 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.basecode.io.ByteArrayConverter in project Gemma by PavlidisLab.
the class ExpressionDataIntegerMatrix method createMatrix.
/**
* Fill in the data
*
* @return DoubleMatrixNamed
*/
private IntegerMatrix<CompositeSequence, Integer> createMatrix(Collection<? extends DesignElementDataVector> vectors, int maxSize) {
int numRows = this.rowDesignElementMapByInteger.keySet().size();
IntegerMatrix<CompositeSequence, Integer> mat = new IntegerMatrix<>(numRows, maxSize);
for (int j = 0; j < mat.columns(); j++) {
mat.addColumnName(j);
}
// initialize the matrix to 0
for (int i = 0; i < mat.rows(); i++) {
for (int j = 0; j < mat.columns(); j++) {
mat.set(i, j, 0);
}
}
ByteArrayConverter bac = new ByteArrayConverter();
Map<Integer, CompositeSequence> rowNames = new TreeMap<>();
for (DesignElementDataVector vector : vectors) {
CompositeSequence designElement = vector.getDesignElement();
assert designElement != null : "No design element for " + vector;
Integer rowIndex = this.rowElementMap.get(designElement);
assert rowIndex != null;
rowNames.put(rowIndex, designElement);
byte[] bytes = vector.getData();
int[] vals = bac.byteArrayToInts(bytes);
BioAssayDimension dimension = vector.getBioAssayDimension();
Collection<BioAssay> bioAssays = dimension.getBioAssays();
assert bioAssays.size() == vals.length : "Expected " + vals.length + " got " + bioAssays.size();
Iterator<BioAssay> it = bioAssays.iterator();
this.setMatBioAssayValues(mat, rowIndex, ArrayUtils.toObject(vals), bioAssays, it);
}
for (int i = 0; i < mat.rows(); i++) {
mat.addRowName(rowNames.get(i));
}
ExpressionDataIntegerMatrix.log.debug("Created a " + mat.rows() + " x " + mat.columns() + " matrix");
return mat;
}
Aggregations