hic3defdr.util.dispersion module

hic3defdr.util.dispersion.cml(data, f=None)[source]

Estimates the dispersion parameter of a NB distribution given the data via conditional maximum likelihood.

One common dispersion will be estimated across all pixels in the data, though the individual pixels in the data may have distinct means.

Parameters:
  • data (np.ndarray) – Rows should correspond to pixels, columns to replicates.
  • f (np.ndarray) – Matrix of scaling factors parallel to data. Pass None to skip scaling.
Returns:

The estimated dispersion.

Return type:

float

hic3defdr.util.dispersion.estimate_dispersion(data, cov, estimator='qcml', n_bins=100, logx=False)[source]

Estimates trended dispersion for each point in data with respect to a covariate cov, using estimator to estimate the dispersion within each of n_bins equal-number bins and fitting a curve through the per-bin dispersion estimates using lowess smoothing.

This function is deprecated and has no callers.

Parameters:
  • data (np.ndarray) – Rows should correspond to pixels, columns to replicates.
  • cov (np.ndarray) – A vector of covariate values per pixel.
  • estimator ('cml', 'qcml', 'mme', or a function) – Pass ‘cml’, ‘qcml’, ‘mme’ to use conditional maximum likelihood (CML), qnorm-CML (qCML), or method of moments estimation (MME) to estimate the dispersion within each bin. Pass a function that takes in a (pixels, replicates) shaped array of data and returns a dispersion value to use that instead.
  • n_bins (int) – The number of bins to use when binning the pixels according to cov.
  • logx (bool) – Whether or not to perform the lowess fit in log x space.
Returns:

  • smoothed_disp (np.ndarray) – Vector of smoothed dispersion estimates for each pixel.
  • cov_per_bin, disp_per_bin (np.ndarray) – Average covariate value and estimated dispersion value, respectively, per bin.
  • disp_smooth_func (function) – Vectorized function that returns a smoothed dispersion given the value of the covariate.

hic3defdr.util.dispersion.mme(data, f=None)[source]

Estimates the dispersion parameter of a NB distribution given the data using a method of moments approach.

One common dispersion will be estimated across all pixels in the data, though the individual pixels in the data may have distinct means.

Parameters:
  • data (np.ndarray) – Rows should correspond to pixels, columns to replicates.
  • f (np.ndarray) – Matrix of scaling factors parallel to data. Pass None to skip scaling.
Returns:

The estimated dispersion.

Return type:

float

hic3defdr.util.dispersion.mme_per_pixel(data, f=None)[source]

Estimates the dispersion parameter of a separate NB distribution for each pixel given the data using a method of moments approach.

Parameters:
  • data (np.ndarray) – Rows should correspond to pixels, columns to replicates.
  • f (np.ndarray) – Matrix of scaling factors parallel to data. Pass None to skip scaling.
Returns:

The estimated dispersion for each pixel.

Return type:

np.ndarray

hic3defdr.util.dispersion.qcml(data, f=None, max_iter=10, tol=0.0001)[source]

Estimates the dispersion parameter of a NB distribution given the data via quantile-adjusted conditional maximum likelihood.

One common dispersion will be estimated across all pixels in the data, though the individual pixels in the data may have distinct means.

Parameters:
  • data (np.ndarray) – Rows should correspond to pixels, columns to replicates.
  • f (np.ndarray) – Matrix of scaling factors parallel to data. Pass None to skip scaling.
Returns:

The estimated dispersion.

Return type:

float