lfc_shrink(coeff=...) bypasses contrast validation and silently flips LFC signs
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- bioinformatics, data
调研方向
阅读 ds.py:393-408 和 ds.py:465-468,追踪 lfc_shrink() 如何验证对比并更新 results_df。首先检查显式指定的 coeff 与 contrast_vector 的关系,然后添加一个使用 issue 中所述反向对比的回归测试。当不兼容的系数会引发 ValueError,且兼容的对比仍受支持时,任务即完成。
由索引模型根据 Issue 内容生成。
描述
In ds.py:393-408, contrast validation in lfc_shrink() only runs when coeff is None, and its error message prompts "please provide coeff". Passing an explicit coeff for a reversed contrast (contrast_vector = [0, -1]) skips validation and overwrites results_df["log2FoldChange"] (ds.py:465-468) with the opposite-sign coefficient while leaving stat, pvalue, and padj unchanged.
Related: #544.
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.iloc[:3, 0] = [400, 420, 450] # KO high
counts.iloc[3:, 0] = [30, 35, 25] # WT low
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", "KO", "WT"], n_cpus=1, quiet=True)
ds.summary()
print("Before:", round(ds.results_df.loc["g0", "log2FoldChange"], 3),
round(ds.results_df.loc["g0", "stat"], 3))
ds.lfc_shrink(coeff="condition[T.WT]")
print("After: ", round(ds.results_df.loc["g0", "log2FoldChange"], 3),
round(ds.results_df.loc["g0", "stat"], 3))
Expected: Raise ValueError unless contrast_vector selects the single +1 column matching coeff (and guide callers to reparameterize the design so the target effect is one column rather than passing an incompatible coeff).
Actual, with PyDESeq2 main@e1eefef (also reproduces on v0.7.0):
Before: 3.486 7.56
After: -3.366 7.56
Versions
pydeseq2: 0.7.0 (main@e1eefef)
python: 3.12.14
numpy: 2.5.5
pandas: 3.1.2
scipy: 1.18.1
- 主要语言
- Python
- 星标
- 770
- 派生
- 98
- 平均合并
- 19 小时 55 分钟
- 30 天内合并 PR
- 45
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
scverse/PyDESeq2 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
`lowess` returns 0 for points of an exact fit after robustness iterations可能重新可做 @aviralgarg05 于 15 天前认领,目前没有进行中的 PR。 未关闭bug
难度 2/5 1-3 小时 新手友好度 74/100
scverse/PyDESeq2#520 · 1 条评论 ·
维护者通常 1 天内回复
-
`irls_solver` does not enforce `min_beta` when IRLS converges, and documents `max_beta`'s default as -30可能重新可做 @aviralgarg05 于 15 天前认领,目前没有进行中的 PR。 未关闭bug
难度 2/5 1-3 小时 新手友好度 85/100
scverse/PyDESeq2#521 · 1 条评论 ·
维护者通常 1 天内回复
-
`MAP_dispersions` of refitted genes keep the value from before outlier replacement可能重新可做 @aviralgarg05 于 15 天前认领,目前没有进行中的 PR。 未关闭bug
难度 2/5 1-3 小时 新手友好度 75/100
scverse/PyDESeq2#519 · 1 条评论 ·
维护者通常 1 天内回复
-
`prior_LFC_var` is squared in the Wald test's ridge可能重新可做 关联的 PR 已关闭且未合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 78/100
nael5x/creative-ai#130 ·
-
Make the "%" unit spacing the same in the web and in A10可能已有人在做 @kragent66-glitch 今天认领。 未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 条评论 ·
-
ci severity: low
难度 2/5 1-3 小时 新手友好度 78/100
TMHSDigital/Spackle#205 ·
维护者通常 1 天内回复
-
pkg:lgm type:chore upstream-gaussx
难度 2/5 1-3 小时 新手友好度 76/100
jejjohnson/pyrox#610 ·
维护者通常 1 天内回复
-
bug user-report
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复