INNER CODE UNIT · Python
fit_dispersion_prior
scverse/PyDESeq2 · src/pydeseq2/dds.py:803
def fit_dispersion_prior(self) -> None:
"""Fit dispersion variance priors and standard deviation of log-residuals.
The computation is based on genes whose dispersions are above 100 * min_disp.
Note: when the design matrix has fewer than 3 degrees of freedom, the estimate of log dispersions is likely to be imprecise.
"""
# Check that the dispersion trend curve was fitted. If not, fit it.
if "fitted_dispersions" not in self.var:
self.fit_dispersion_trend()
# Exclude genes with all zeroes
num_samples = self.n_obs
num_vars = self.obsm["design_matrix"].shape[-1]
# Check the degrees of freedom
if (num_samples - num_vars) <= 3:
warnings.warn(