scverse / scverse/PyDESeq2

[BUG] Dispersion estimation fails after 0.4.8

Open
#391 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
761
Forks
90
Avg merge
25m
Merged PRs (30d)
10

Description

Describe the bug
This bug came up in the process of generating this notebook for our recent preprint. As part of the workflow, we fit a simple model with two design factors. One design factor has two levels; the other has seventy.

In 0.4.8, the procedure takes about four minutes, the vast majority of it spent on fitting dispersions. The mean/dispersion curve looks OK.

Image

In 0.5.1, the dispersion fitting fails.

Image

To Reproduce

Notebook here. Test data here.

New version:

anndata==0.11.4
matplotlib==3.10.3
numpy==2.2.6
pandas==2.2.3
pydeseq2==0.5.1
scanpy==1.11.1
scipy==1.15.3
tqdm==4.67.1
python==3.13.2

Old version:

tqdm==4.67.1
scipy==1.11.4
scanpy==1.9.6
pydeseq2==0.4.8
pandas==2.2.3
numpy==1.26.2
matplotlib==3.8.2
anndata==0.10.3
python==3.9.7

Expected behavior

  1. Most immediately, the dispersion estimation should probably not fail, given that it works in an older version.
  2. If the dispersion fitting procedure changed at some point between 0.4.8 and 0.5.1, it would be good if this were documented. But the only entries I see relate to vst (unrelated) and refitting (also unrelated).
  3. I do not expect the dispersion computation to scale so unfavorably with the number of levels. The example shown here takes a few minutes for dds_f, which has 70 levels, but over an hour for dds_m, which has a little over 200 levels. This is about a 20x increase in runtime for a 2.8x increase in the size of the design matrix.

Screenshots
See above.

Desktop (please complete the following information):

  • OS: Linux-5.10.93-87.444.amzn2.x86_64-x86_64-with-glibc2.26

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked 5_differential_expression_xistposneg_new_pydeseq.ipynb and ad_f.h5ad.gz reproduction, comparing pydeseq2 0.4.8 with 0.5.1. Trace the dispersion-fitting path and any changes between those versions, including scaling with design-factor levels. Done means the reported dispersion estimation no longer fails, and any intentional behavior change is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.