public IlluminaMetricCounts(final String barcode, final String barcodeName, final Integer laneNumber) { this.tileToClusterHistogram = new Histogram<>(); this.tileToPfClusterHistogram = new Histogram<>(); this.metrics = new IlluminaBasecallingMetrics(); this.metrics.MOLECULAR_BARCODE_SEQUENCE_1 = barcode; this.metrics.MOLECULAR_BARCODE_NAME = barcodeName; this.metrics.LANE = Integer.toString(laneNumber); }
private Histogram<Integer> getDepthHistogramNonZero() { final Histogram<Integer> depthHistogram = new Histogram<>("coverage", "count_NON_ZERO_REGIONS"); // do not include the zero-coverage bin for (int i = 1; i < highQualityDepthHistogramArray.length; ++i) { depthHistogram.increment(i, highQualityDepthHistogramArray[i]); } return depthHistogram; }
protected Histogram<Integer> getHistogram(final long[] array, final String binLabel, final String valueLabel) { final Histogram<Integer> histogram = new Histogram<>(binLabel, valueLabel); for (int i = 0; i < array.length; ++i) { histogram.increment(i, array[i]); } return histogram; }
private Histogram<Integer> getDepthHistogramNonZero() { final Histogram<Integer> depthHistogram = new Histogram<>("coverage", "count_NON_ZERO_REGIONS"); // do not include the zero-coverage bin for (int i = 1; i < highQualityDepthHistogramArray.length; ++i) { depthHistogram.increment(i, highQualityDepthHistogramArray[i]); } return depthHistogram; }
private Histogram<Integer> singleDepthHistogram(final int depth, final int count) { final Histogram<Integer> histogram = new Histogram<>(); histogram.increment(depth, count); return histogram; } private Histogram<Integer> twoSiteDepthHistogram(final int depth1, final int count1, final int depth2, final int count2) {
@Test public void testGeometricMean() { final int[] is = {4,4,4,4,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8}; final Histogram<Integer> histo = new Histogram<>(); for (final int i : is) histo.increment(i); Assert.assertTrue(abs(histo.getGeometricMean() - 6.216797) < 0.00001); }
@Test public void testGetSum() { final int[] is = {4,4,5,5,5}; final Histogram<Integer> histo = new Histogram<>(); for (final int i : is) histo.increment(i); Assert.assertEquals(histo.getSum(), (double)(2*4+3*5), 0.000001); }
@Test(dataProvider = "histogramData") //this data provider has several extra variables that we don't make use of here public void testSerializeHistogram(final int[] values, final double mean, final double stdev, final Integer trimByWidth) throws IOException, ClassNotFoundException { final Histogram<Integer> histo = new Histogram<>(); for (int value : values) { histo.increment(value); } Histogram<Integer> deserializedHistogram = TestUtil.serializeAndDeserialize(histo); Assert.assertEquals(deserializedHistogram, histo); }
/** Gets the median absolute deviation of the distribution. */ public double getMedianAbsoluteDeviation() { final double median = getMedian(); final Histogram<Double> deviations = new Histogram<>(); for (final Bin<K> bin : values()) { final double dev = abs(bin.getIdValue() - median); deviations.increment(dev, bin.getValue()); } return deviations.getMedian(); }
/** Gets the median absolute deviation of the distribution. */ public double getMedianAbsoluteDeviation() { final double median = getMedian(); final Histogram<Double> deviations = new Histogram<>(); for (final Bin<K> bin : values()) { final double dev = abs(bin.getIdValue() - median); deviations.increment(dev, bin.getValue()); } return deviations.getMedian(); }
/** Gets the median absolute deviation of the distribution. */ public double getMedianAbsoluteDeviation() { final double median = getMedian(); final Histogram<Double> deviations = new Histogram<Double>(); for (final Bin bin : values()) { final double dev = abs(bin.getIdValue() - median); deviations.increment(dev, bin.getValue()); } return deviations.getMedian(); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testGetSumBlowup() { final String[] is = {"foo", "foo", "bar"}; final Histogram<String> histo = new Histogram<>(); for (final String i : is) histo.increment(i); histo.getSum();//blow up }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testGetMaxBlowup() { final String[] is = {"foo", "bar", "bar"}; final Histogram<String> histo = new Histogram<>(); for (final String i : is) histo.increment(i); histo.getMax();//blow up }
@Test public void testGetMedianBinSize() { final int[] is = {4,4,5,5,5,6,6,6,6}; final Histogram<Integer> histo = new Histogram<>(); Assert.assertEquals(histo.getMedianBinSize(), 0, 0.000001); //empty for (final int i : is) histo.increment(i); Assert.assertEquals(histo.getMedianBinSize(), 3, 0.000001); //three fives }
@Test public void testGetMedianBinSize_Even() { final int[] is = {4,4,5,5,5}; final Histogram<Integer> histo = new Histogram<>(); Assert.assertEquals(histo.getMedianBinSize(), 0, 0.000001); //empty for (final int i : is) histo.increment(i); Assert.assertEquals(histo.getMedianBinSize(), (2+3)/2.0, 0.000001); //even split }
@Test public void testLabels() { final int[] is = {4,4,5,5,5}; final Histogram<Integer> histo = new Histogram<>("FOO", "BAR"); for (final int i : is) histo.increment(i); Assert.assertEquals(histo.getBinLabel(),"FOO"); Assert.assertEquals(histo.getValueLabel(),"BAR"); }
@Test public void testGetMinMax() { final int[] is = {4,4,5,5,5,6,6,6,6}; final Histogram<Integer> histo = new Histogram<>(); for (final int i : is) histo.increment(i); Assert.assertEquals(histo.getMin(), 4.0); Assert.assertEquals(histo.getMax(), 6.0); }
@Test public void testMad() { final int[] is = {4,4,4,4,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8}; final Histogram<Integer> histo = new Histogram<>(); for (final int i : is) histo.increment(i); Assert.assertEquals(7d, histo.getMedian()); Assert.assertEquals(1d, histo.getMedianAbsoluteDeviation()); Assert.assertTrue(abs(histo.estimateSdViaMad() - 1.4826) < 0.0001); }
private Histogram<Integer> twoSiteDepthHistogram(final int depth1, final int count1, final int depth2, final int count2) { final Histogram<Integer> histogram = new Histogram<>(); if (0 < depth1) histogram.increment(depth1, count1); if (0 < depth2) histogram.increment(depth2, count2); return histogram; }