Skip to content

Commit

Permalink
BUG dispersion prior variance (#105)
Browse files Browse the repository at this point in the history
* fix: dispersion prior variance

* refactor: remove unused `num_genes` variable from `fit_dispersion_prior`

---------

Co-authored-by: Boris Muzellec <[email protected]>
  • Loading branch information
mikelove and BorisMuzellec authored Mar 28, 2023
1 parent b79ec93 commit 8cda857
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pydeseq2/dds.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def fit_dispersion_prior(self) -> None:
self.fit_dispersion_trend()

# Exclude genes with all zeroes
num_genes = len(self.non_zero_genes)
num_samples = self.n_obs
num_vars = self.obsm["design_matrix"].shape[-1]

# Fit dispersions to the curve, and compute log residuals
Expand All @@ -531,7 +531,7 @@ def fit_dispersion_prior(self) -> None:
mean_absolute_deviation(disp_residuals[above_min_disp]) ** 2
)
self.uns["prior_disp_var"] = np.maximum(
self.uns["_squared_logres"] - polygamma(1, (num_genes - num_vars) / 2),
self.uns["_squared_logres"] - polygamma(1, (num_samples - num_vars) / 2),
0.25,
)

Expand Down

0 comments on commit 8cda857

Please sign in to comment.