/** * Calculates the mean bin size */ public double getMeanBinSize() { return (getSumOfValues() / size()); }
/** * Calculates the mean bin size */ public double getMeanBinSize() { return (getSumOfValues() / size()); }
/** * Calculates the mean bin size */ public double getMeanBinSize() { return (getSumOfValues() / size()); }
public void calculateDerivedFields() { OBSERVED_UNIQUE_UMIS = observedUmis.size(); INFERRED_UNIQUE_UMIS = inferredUmis.size(); // Percent of UMIs that contain at least one N of total number of UMIs observed (observed UMIs is a count of UMIs without N) PCT_UMI_WITH_N = (double) observedUmiWithNs/ ((double) observedUmiWithNs + (double) totalObservedUmisWithoutNs); OBSERVED_UMI_ENTROPY = effectiveNumberOfBases(observedUmis); INFERRED_UMI_ENTROPY = effectiveNumberOfBases(inferredUmis); UMI_BASE_QUALITIES = QualityUtil.getPhredScoreFromErrorProbability((double) OBSERVED_BASE_ERRORS / (double) observedUmiBases); }
public void calculateDerivedFields() { OBSERVED_UNIQUE_UMIS = observedUmis.size(); INFERRED_UNIQUE_UMIS = inferredUmis.size(); // Percent of UMIs that contain at least one N of total number of UMIs observed (observed UMIs is a count of UMIs without N) PCT_UMI_WITH_N = (double) observedUmiWithNs/ ((double) observedUmiWithNs + (double) totalObservedUmisWithoutNs); OBSERVED_UMI_ENTROPY = effectiveNumberOfBases(observedUmis); INFERRED_UMI_ENTROPY = effectiveNumberOfBases(inferredUmis); UMI_BASE_QUALITIES = QualityUtil.getPhredScoreFromErrorProbability((double) OBSERVED_BASE_ERRORS / (double) observedUmiBases); }
/** * Calculates the median bin size */ public double getMedianBinSize() { if (size() == 0) { return 0; } final List<Double> binValues = new ArrayList<>(); for (final Bin<K> bin : values()) { binValues.add(bin.getValue()); } Collections.sort(binValues); final int midPoint = binValues.size() / 2; double median = binValues.get(midPoint); if (binValues.size() % 2 == 0) { median = (median + binValues.get(midPoint - 1)) / 2; } return median; }
/** * Calculates the median bin size */ public double getMedianBinSize() { if (size() == 0) { return 0; } final List<Double> binValues = new ArrayList<Double>(); for (final Bin bin : values()) { binValues.add(bin.getValue()); } Collections.sort(binValues); final int midPoint = binValues.size() / 2; double median = binValues.get(midPoint); if (binValues.size() % 2 == 0) { median = (median + binValues.get(midPoint-1)) / 2; } return median; }
/** * Calculates the median bin size */ public double getMedianBinSize() { if (size() == 0) { return 0; } final List<Double> binValues = new ArrayList<>(); for (final Bin<K> bin : values()) { binValues.add(bin.getValue()); } Collections.sort(binValues); final int midPoint = binValues.size() / 2; double median = binValues.get(midPoint); if (binValues.size() % 2 == 0) { median = (median + binValues.get(midPoint - 1)) / 2; } return median; }
public static double[] normalizeHistogram(final Histogram<Integer> histogram) { if (histogram == null) throw new PicardException("Histogram is null and cannot be normalized"); final double histogramSumOfValues = histogram.getSumOfValues(); final double[] normalizedHistogram = new double[histogram.size()]; for (int i = 0; i < histogram.size(); i++) { if (histogram.get(i) != null) { normalizedHistogram[i] = histogram.get(i).getValue() / histogramSumOfValues; } } return normalizedHistogram; }
public static double[] normalizeHistogram(final Histogram<Integer> histogram) { if (histogram == null) throw new PicardException("Histogram is null and cannot be normalized"); final double histogramSumOfValues = histogram.getSumOfValues(); final double[] normalizedHistogram = new double[histogram.size()]; for (int i = 0; i < histogram.size(); i++) { if (histogram.get(i) != null) { normalizedHistogram[i] = histogram.get(i).getValue() / histogramSumOfValues; } } return normalizedHistogram; }
public static InsertSizeDistribution create(Histogram<Integer> insertSizeHistogram) { if (insertSizeHistogram == null) return null; int[] insertSize = new int[insertSizeHistogram.size()]; double[] count = new double[insertSizeHistogram.size()]; double total = insertSizeHistogram.getSumOfValues(); int i = 0; Set<Integer> keys = insertSizeHistogram.keySet(); for (Integer key : keys) { insertSize[i] = key; count[i] = insertSizeHistogram.get(key).getValue(); i++; } return new InsertSizeDistribution(insertSize, count, (long)total); } public InsertSizeDistribution(int[] singletons, double[] readCounts) {
@Test public void testSize() { 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.size(), 2); //2 unique values }
return histo.size() > 0 ? histo.getMode() : 0;
return histo.size() > 0 ? histo.getMode() : 0;