Package htsjdk.samtools.util
Class Histogram<K extends Comparable>
java.lang.Object
htsjdk.samtools.util.Histogram<K>
- All Implemented Interfaces:
Serializable
Class for computing and accessing histogram type data. Stored internally in
a sorted Map so that keys can be iterated in order.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHistogram.Bin<K extends Comparable>Represents a bin in the Histogram. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new Histogram with default bin and value labels.Copy constructor for a histogram.Constructs a new Histogram with supplied bin and value labels.Histogram(String binLabel, String valueLabel, Comparator<? super K> comparator) Constructor that takes labels for the bin and values and a comparator to sort the bins.Histogram(Comparator<? super K> comparator) Constructs a new Histogram that'll use the supplied comparator to sort keys. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHistogram(Histogram<K> addHistogram) Mutable method that allows the addition of a Histogram into the current one.Comparator<? super K>Returns the comparator used to order the keys in this histogram, ornullif this histogram uses the natural ordering of its keys.booleancontainsKey(K key) Return whether this histogram contains the given key.divideByHistogram(Histogram<K> divisorHistogram) Immutable method that divides the current Histogram by an input Histogram and generates a new one Throws an exception if the bins don't match up exactlybooleanChecks that the labels and values in the two histograms are identical.doubleReturns a value that is intended to estimate the mean of the distribution, if the distribution is essentially normal, by using the median absolute deviation to remove the effect of erroneous massive outliers.Retrieves the bin associated with the given key.doublegetCount()doublegetCumulativeProbability(double v) Returns the cumulative probability of observing a value <= v when sampling the distribution represented by this histogram.doubleGets the geometric mean of the distribution.doublegetMax()Returns the key with the highest count.doublegetMean()Assuming that the key type for the histogram is a Number type, returns the mean of all the items added to the histogram.doubleCalculates the mean bin sizedoubledoubleGets the median absolute deviation of the distribution.doubleCalculates the median bin sizedoublegetMin()Returns the key with the lowest count.doublegetMode()Returns id of the Bin that's the mode of the distribution (i.e.doublegetPercentile(double percentile) Gets the bin in which the given percentile falls.doubledoublegetStandardDeviationBinSize(double mean) Calculates the standard deviation of the bin sizedoublegetSum()Returns the sum of the products of the histgram bin ids and the number of entries in each bin.doubleReturns the sum of the number of entries in each bin.inthashCode()voidIncrements the value in the designated bin by 1.voidIncrements the value in the designated bin by the supplied increment.booleanisEmpty()Returns true if this histogram has no data in in, false otherwise.keySet()Returns the set of keys for this histogram.voidprefillBins(K... ids) Prefill the histogram with the supplied set of bins.voidsetBinLabel(String binLabel) voidsetValueLabel(String valueLabel) intsize()Returns the size of this histogram.toString()voidtrimByTailLimit(int tailLimit) Trims the histogram when the bins in the tail of the distribution contain fewer than mode/tailLimit itemsvoidtrimByWidth(int width) Trims the histogram so that only bins <= width are kept.values()Returns aCollectionview of the values contained in this histogram.
-
Constructor Details
-
Histogram
public Histogram()Constructs a new Histogram with default bin and value labels. -
Histogram
Constructs a new Histogram with supplied bin and value labels. -
Histogram
Constructs a new Histogram that'll use the supplied comparator to sort keys. -
Histogram
Constructor that takes labels for the bin and values and a comparator to sort the bins. -
Histogram
Copy constructor for a histogram.
-
-
Method Details
-
prefillBins
Prefill the histogram with the supplied set of bins. -
increment
Increments the value in the designated bin by 1. -
increment
Increments the value in the designated bin by the supplied increment. -
getBinLabel
-
setBinLabel
-
getValueLabel
-
setValueLabel
-
equals
Checks that the labels and values in the two histograms are identical. -
toString
-
hashCode
public int hashCode() -
getMean
public double getMean()Assuming that the key type for the histogram is a Number type, returns the mean of all the items added to the histogram. -
getSum
public double getSum()Returns the sum of the products of the histgram bin ids and the number of entries in each bin. Note: This is only supported if this histogram stores instances of Number. -
getSumOfValues
public double getSumOfValues()Returns the sum of the number of entries in each bin. -
getStandardDeviation
public double getStandardDeviation() -
getMeanBinSize
public double getMeanBinSize()Calculates the mean bin size -
size
public int size()Returns the size of this histogram. -
comparator
Returns the comparator used to order the keys in this histogram, ornullif this histogram uses the natural ordering of its keys.- Returns:
- the comparator used to order the keys in this histogram,
or
nullif this histogram uses the natural ordering of its keys
-
getMedianBinSize
public double getMedianBinSize()Calculates the median bin size -
values
Returns aCollectionview of the values contained in this histogram. The collection's iterator returns the values in ascending order of the corresponding keys. -
getStandardDeviationBinSize
public double getStandardDeviationBinSize(double mean) Calculates the standard deviation of the bin size -
getPercentile
public double getPercentile(double percentile) Gets the bin in which the given percentile falls. Should only be called on histograms with non-negative values and a positive sum of values.- Parameters:
percentile- a value between 0 and 1- Returns:
- the bin value in which the percentile falls
-
getCumulativeProbability
public double getCumulativeProbability(double v) Returns the cumulative probability of observing a value <= v when sampling the distribution represented by this histogram.- Throws:
UnsupportedOperationException- if this histogram does not store instances of Number
-
getMedian
public double getMedian() -
getMedianAbsoluteDeviation
public double getMedianAbsoluteDeviation()Gets the median absolute deviation of the distribution. -
estimateSdViaMad
public double estimateSdViaMad()Returns a value that is intended to estimate the mean of the distribution, if the distribution is essentially normal, by using the median absolute deviation to remove the effect of erroneous massive outliers. -
getMode
public double getMode()Returns id of the Bin that's the mode of the distribution (i.e. the largest bin).- Throws:
UnsupportedOperationException- if this histogram does not store instances of Number
-
getMin
public double getMin()Returns the key with the lowest count.- Throws:
UnsupportedOperationException- if this histogram does not store instances of Number
-
getMax
public double getMax()Returns the key with the highest count.- Throws:
UnsupportedOperationException- if this histogram does not store instances of Number
-
getCount
public double getCount() -
getGeometricMean
public double getGeometricMean()Gets the geometric mean of the distribution. -
trimByTailLimit
public void trimByTailLimit(int tailLimit) Trims the histogram when the bins in the tail of the distribution contain fewer than mode/tailLimit items -
isEmpty
public boolean isEmpty()Returns true if this histogram has no data in in, false otherwise. -
trimByWidth
public void trimByWidth(int width) Trims the histogram so that only bins <= width are kept. -
divideByHistogram
Immutable method that divides the current Histogram by an input Histogram and generates a new one Throws an exception if the bins don't match up exactly- Parameters:
divisorHistogram-- Returns:
- Throws:
IllegalArgumentException- if the keySet of this histogram is not equal to the keySet of the given divisorHistogram
-
addHistogram
Mutable method that allows the addition of a Histogram into the current one.- Parameters:
addHistogram-
-
get
Retrieves the bin associated with the given key. -
keySet
Returns the set of keys for this histogram. -
containsKey
Return whether this histogram contains the given key.
-