wald_test() with greater/less/lessAbs turns NaN LFCs into stat=0.0, pvalue=0.5
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- numpy, python
- Domain
- bioinformatics, data
Research direction
Start with wald_test() in glm.py around lines 242–259 and inspect the greater, less, and lessAbs branches. Reproduce with the all-zero gene example in the issue, then add or run a focused test confirming its statistic and p-value are NaN for those alternatives. Done when the regression is covered and the expected NaN values are returned.
Written by the indexing model from the issue text.
Description
In glm.py:242-259, wald_test() uses np.fmax/np.fmin (which ignore NaNs) instead of np.maximum/np.minimum. For any gene with LFC = NaN (e.g., an all-zero gene), alt_hypothesis in {"greater", "less", "lessAbs"} returns stat = 0.0 and pvalue = 0.5 instead of NaN (greaterAbs returns NaN via np.sign).
Related: #572, #515.
Source line numbers refer to commit e1eefef.
Reproduction
import numpy as np
import pandas as pd
from pydeseq2.dds import DeseqDataSet
from pydeseq2.ds import DeseqStats
rng = np.random.default_rng(0)
counts = pd.DataFrame(
rng.negative_binomial(5, 0.05, (6, 20)),
index=[f"s{i}" for i in range(6)],
columns=[f"g{i}" for i in range(20)],
)
counts["g1"] = 0 # all-zero gene -> LFC=NaN
meta = pd.DataFrame({"condition": ["KO"] * 3 + ["WT"] * 3}, index=counts.index)
dds = DeseqDataSet(counts=counts, metadata=meta, design="~condition",
fit_type="mean", n_cpus=1, quiet=True)
dds.deseq2()
ds = DeseqStats(dds, contrast=["condition", "WT", "KO"],
alt_hypothesis="greater", lfc_null=1.0, n_cpus=1, quiet=True)
ds.summary()
print(ds.results_df.loc["g1", ["log2FoldChange", "lfcSE", "stat", "pvalue"]])
Expected: stat = NaN and pvalue = NaN (using np.maximum/np.minimum).
Actual, with PyDESeq2 main@e1eefef (also reproduces on v0.7.0, and identically for less and lessAbs):
log2FoldChange NaN
lfcSE NaN
stat 0.0
pvalue 0.5
Name: g1, dtype: float64
Versions
pydeseq2: 0.7.0 (main@e1eefef)
python: 3.12.14
numpy: 2.5.5
pandas: 3.1.2
scipy: 1.18.1
- Dominant language
- Python
- Stars
- 770
- Forks
- 98
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 45
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from scverse/PyDESeq2
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
`lowess` returns 0 for points of an exact fit after robustness iterationsMay be free again @aviralgarg05 claimed this 15 days ago, and no pull request is open. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
scverse/PyDESeq2#520 · 1 comment ·
Maintainers usually reply within 1 day
-
`irls_solver` does not enforce `min_beta` when IRLS converges, and documents `max_beta`'s default as -30May be free again @aviralgarg05 claimed this 15 days ago, and no pull request is open. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
scverse/PyDESeq2#521 · 1 comment ·
Maintainers usually reply within 1 day
-
`MAP_dispersions` of refitted genes keep the value from before outlier replacementMay be free again @aviralgarg05 claimed this 15 days ago, and no pull request is open. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
scverse/PyDESeq2#519 · 1 comment ·
Maintainers usually reply within 1 day
-
`prior_LFC_var` is squared in the Wald test's ridgeMay be free again A pull request for this issue was closed without being merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
All issues in scverse/PyDESeq2
Similar issues
-
Make the "%" unit spacing the same in the web and in A10Possibly taken @kragent66-glitch claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 comment ·
-
ci severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TMHSDigital/Spackle#205 ·
Maintainers usually reply within 1 day
-
pkg:lgm type:chore upstream-gaussx
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
jejjohnson/pyrox#610 ·
Maintainers usually reply within 1 day
-
changelog investigate
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ramnes/notion-sdk-py#523 ·
-
feature-request
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-telemetry/opentelemetry-python#5994 ·
Maintainers usually reply within 2 days