Search in sources :

Example 31 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project Gemma by PavlidisLab.

the class ExpressionExperimentQCController method getCorrelHistFromFile.

/**
 * For backwards compatibility - read from the file. Remove this method when no longer needed.
 */
private XYSeries getCorrelHistFromFile(ExpressionExperiment ee) throws IOException {
    File file = this.locateProbeCorrFile(ee);
    // Current format is to have just one file for each analysis.
    if (file == null) {
        return null;
    } else if (!file.canRead()) {
        return null;
    }
    try (BufferedReader in = new BufferedReader(new FileReader(file))) {
        XYSeries series = new XYSeries(ee.getId(), true, true);
        DoubleArrayList counts = new DoubleArrayList();
        while (in.ready()) {
            String line = in.readLine().trim();
            if (line.startsWith("#"))
                continue;
            String[] split = StringUtils.split(line);
            if (split.length < 2)
                continue;
            try {
                double x = Double.parseDouble(split[0]);
                double y = Double.parseDouble(split[1]);
                series.add(x, y);
                counts.add(y);
            } catch (NumberFormatException e) {
            // line wasn't useable.. no big deal. Heading is included.
            }
        }
        if (!counts.isEmpty()) {
            // Backfill.
            this.corrDistFileToPersistent(file, ee, counts);
        }
        return series;
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 32 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project Gemma by PavlidisLab.

the class ExpressionExperimentQCController method getEigenGene.

/**
 * Get the eigengene for the given component.
 * The values are rescaled so that jfreechart can cope. Small numbers give it fits.
 */
private Double[] getEigenGene(SVDValueObject svdo, Integer component) {
    DoubleArrayList eigenGeneL = new DoubleArrayList(ArrayUtils.toPrimitive(svdo.getvMatrix().getColObj(component)));
    DescriptiveWithMissing.standardize(eigenGeneL);
    return ArrayUtils.toObject(eigenGeneL.elements());
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 33 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project beast-mcmc by beast-dev.

the class KernelDensityEstimator2D method bandwidthNRD.

// bandwidth.nrd =
// function (x)
// {
// r <- quantile(x, c(0.25, 0.75))
// h <- (r[2] - r[1])/1.34
// 4 * 1.06 * min(sqrt(var(x)), h) * length(x)^(-1/5)
// }
public double bandwidthNRD(double[] in) {
    DoubleArrayList inList = new DoubleArrayList(in.length);
    for (double d : in) inList.add(d);
    inList.sort();
    final double h = (Descriptive.quantile(inList, 0.75) - Descriptive.quantile(inList, 0.25)) / 1.34;
    return 4 * 1.06 * Math.min(Math.sqrt(DiscreteStatistics.variance(in)), h) * Math.pow(in.length, -0.2);
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 34 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project EnrichmentMapApp by BaderLab.

the class HeatMapTableModel method median.

private static double median(double[] vals) {
    if (vals.length == 0)
        return 0.0;
    // DoubleArrayList is just a wrapper for vals, we must make a copy of the array 
    // before sorting or else the expression values will be moved to the wrong order.
    double[] copy = Arrays.copyOf(vals, vals.length);
    Arrays.sort(copy);
    return Descriptive.median(new DoubleArrayList(copy));
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 35 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project Gemma by PavlidisLab.

the class ProcessedExpressionDataVectorCreateHelperServiceImpl method computeRanks.

private Collection<ProcessedExpressionDataVector> computeRanks(Collection<ProcessedExpressionDataVector> processedDataVectors, ExpressionDataDoubleMatrix intensities) {
    DoubleArrayList ranksByMean = this.getRanks(intensities, ProcessedExpressionDataVectorDao.RankMethod.mean);
    assert ranksByMean != null;
    DoubleArrayList ranksByMax = this.getRanks(intensities, ProcessedExpressionDataVectorDao.RankMethod.max);
    assert ranksByMax != null;
    for (ProcessedExpressionDataVector vector : processedDataVectors) {
        CompositeSequence de = vector.getDesignElement();
        if (intensities.getRow(de) == null) {
            ProcessedExpressionDataVectorCreateHelperServiceImpl.log.warn("No intensity value for " + de + ", rank for vector will be null");
            vector.setRankByMean(null);
            vector.setRankByMax(null);
            continue;
        }
        Integer i = intensities.getRowIndex(de);
        double rankByMean = ranksByMean.get(i) / ranksByMean.size();
        double rankByMax = ranksByMax.get(i) / ranksByMax.size();
        vector.setRankByMean(rankByMean);
        vector.setRankByMax(rankByMax);
    }
    return processedDataVectors;
}
Also used : ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector) DoubleArrayList(cern.colt.list.DoubleArrayList) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Aggregations

DoubleArrayList (cern.colt.list.DoubleArrayList)82 RegressionResult (edu.cmu.tetrad.regression.RegressionResult)11 ArrayList (java.util.ArrayList)9 AndersonDarlingTest (edu.cmu.tetrad.data.AndersonDarlingTest)8 IntArrayList (cern.colt.list.IntArrayList)6 DenseDoubleMatrix2D (cern.colt.matrix.impl.DenseDoubleMatrix2D)5 TetradVector (edu.cmu.tetrad.util.TetradVector)5 Test (org.junit.Test)5 DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)4 TetradMatrix (edu.cmu.tetrad.util.TetradMatrix)4 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)3 DenseDoubleMatrix1D (cern.colt.matrix.impl.DenseDoubleMatrix1D)3 Regression (edu.cmu.tetrad.regression.Regression)3 RegressionDataset (edu.cmu.tetrad.regression.RegressionDataset)3 StopWatch (org.apache.commons.lang3.time.StopWatch)2 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)2 Record (org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean.Record)2 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)2 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)2 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)2