Search in sources :

Example 6 with ByteArrayConverter

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);
}
Also used : Histogram(ubic.basecode.math.distribution.Histogram) ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) DifferentialExpressionAnalysisResult(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult) PvalueDistribution(ubic.gemma.model.analysis.expression.diff.PvalueDistribution)

Example 7 with ByteArrayConverter

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);
            }
        }
    }
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType)

Example 8 with ByteArrayConverter

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);
    }
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with ByteArrayConverter

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;
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 10 with ByteArrayConverter

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;
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) IntegerMatrix(ubic.basecode.dataStructure.matrix.IntegerMatrix) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Aggregations

ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)32 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)11 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)11 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)10 DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)9 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)6 ProcessedExpressionDataVector (ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)5 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)5 Test (org.junit.Test)4 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)4 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)4 DoubleArrayList (cern.colt.list.DoubleArrayList)3 Transactional (org.springframework.transaction.annotation.Transactional)3 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)3 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 XYSeries (org.jfree.data.xy.XYSeries)2