Search in sources :

Example 1 with CoexpCorrelationDistribution

use of ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution in project Gemma by PavlidisLab.

the class ExpressionExperimentQCController method corrDistFileToPersistent.

/**
 * For conversion from legacy system.
 */
private void corrDistFileToPersistent(File file, ExpressionExperiment ee, DoubleArrayList counts) {
    log.info("Converting from pvalue distribution file to persistent stored version");
    ByteArrayConverter bac = new ByteArrayConverter();
    Double[] countArray = (Double[]) counts.toList().toArray(new Double[] {});
    byte[] bytes = bac.doubleArrayToBytes(countArray);
    CoexpCorrelationDistribution coexpd = CoexpCorrelationDistribution.Factory.newInstance();
    coexpd.setNumBins(counts.size());
    coexpd.setBinCounts(bytes);
    try {
        coexpressionAnalysisService.addCoexpCorrelationDistribution(ee, coexpd);
        if (file.delete()) {
            log.info("Old file deleted");
        } else {
            log.info("Old file could not be deleted");
        }
    } catch (Exception e) {
        log.info("Could not save the corr dist: " + e.getMessage());
    }
}
Also used : CoexpCorrelationDistribution(ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution) ByteArrayConverter(ubic.basecode.io.ByteArrayConverter)

Example 2 with CoexpCorrelationDistribution

use of ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution in project Gemma by PavlidisLab.

the class ExpressionExperimentQCController method getCorrelHist.

/**
 * @return JFreeChart XYSeries representing the histogram.
 * @throws FileNotFoundException - only if the coexp dist is being read from a file; when migration to db storage is
 *                               complete this can be removed
 * @throws IOException           - only if the coexp dist is being read from a file; when migration to db storage is complete
 *                               this can be removed
 */
private XYSeries getCorrelHist(ExpressionExperiment ee) throws IOException {
    CoexpCorrelationDistribution coexpCorrelationDistribution = coexpressionAnalysisService.getCoexpCorrelationDistribution(ee);
    if (coexpCorrelationDistribution == null) {
        // try to get it from the file.
        return this.getCorrelHistFromFile(ee);
    }
    XYSeries series = new XYSeries(ee.getId(), true, true);
    byte[] binCountsBytes = coexpCorrelationDistribution.getBinCounts();
    ByteArrayConverter bac = new ByteArrayConverter();
    double[] binCounts = bac.byteArrayToDoubles(binCountsBytes);
    Integer numBins = coexpCorrelationDistribution.getNumBins();
    double step = 2.0 / numBins;
    double lim = -1.0;
    for (double d : binCounts) {
        series.add(lim, d);
        lim += step;
    }
    return series;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) CoexpCorrelationDistribution(ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution) ByteArrayConverter(ubic.basecode.io.ByteArrayConverter)

Example 3 with CoexpCorrelationDistribution

use of ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution in project Gemma by PavlidisLab.

the class LinkAnalysis method getCorrelationDistribution.

public CoexpCorrelationDistribution getCorrelationDistribution() {
    CoexpCorrelationDistribution result = CoexpCorrelationDistribution.Factory.newInstance();
    DoubleArrayList histogramArrayList = this.metricMatrix.getHistogramArrayList();
    result.setNumBins(histogramArrayList.size());
    ByteArrayConverter bac = new ByteArrayConverter();
    result.setBinCounts(bac.doubleArrayToBytes(MatrixUtil.fromList(histogramArrayList).toArray()));
    return result;
}
Also used : CoexpCorrelationDistribution(ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution) ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 4 with CoexpCorrelationDistribution

use of ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution in project Gemma by PavlidisLab.

the class LinkAnalysisServiceImpl method analyze.

private void analyze(ExpressionExperiment ee, FilterConfig filterConfig, LinkAnalysisConfig linkAnalysisConfig, LinkAnalysis la, Collection<ProcessedExpressionDataVector> dataVectors) {
    this.qcCheck(linkAnalysisConfig, ee);
    ExpressionDataDoubleMatrix datamatrix = expressionDataMatrixService.getFilteredMatrix(ee, filterConfig, dataVectors);
    this.setUpForAnalysis(ee, la, dataVectors, datamatrix);
    Map<CompositeSequence, Set<Gene>> probeToGeneMap = la.getProbeToGeneMap();
    assert !probeToGeneMap.isEmpty();
    /*
         * remove probes that have no gene mapped to them, not just those that have no sequence
         */
    datamatrix = this.filterUnmappedProbes(datamatrix, probeToGeneMap);
    this.checkDatamatrix(datamatrix);
    LinkAnalysisServiceImpl.log.info("Starting link analysis... " + ee);
    this.normalize(datamatrix, linkAnalysisConfig);
    /*
         * Link analysis section.
         */
    this.addAnalysisObj(ee, filterConfig, linkAnalysisConfig, la);
    la.analyze();
    CoexpCorrelationDistribution corrDist = la.getCorrelationDistribution();
    // another qc check.
    if (linkAnalysisConfig.isCheckCorrelationDistribution()) {
        this.diagnoseCorrelationDistribution(ee, corrDist);
    }
}
Also used : CoexpCorrelationDistribution(ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution) ExpressionDataDoubleMatrix(ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Aggregations

CoexpCorrelationDistribution (ubic.gemma.model.analysis.expression.coexpression.CoexpCorrelationDistribution)4 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)3 DoubleArrayList (cern.colt.list.DoubleArrayList)1 XYSeries (org.jfree.data.xy.XYSeries)1 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)1 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)1