INNER CODE UNIT · Python
disp_function
scverse/PyDESeq2 · src/pydeseq2/dds.py:796
def disp_function(self, x):
"""Return the dispersion trend function at x."""
if self.uns["disp_function_type"] == "parametric":
return dispersion_trend(x, self.uns["trend_coeffs"])
elif self.uns["disp_function_type"] == "mean":
return np.full_like(x, self.uns["mean_disp"])
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()