`MAP_dispersions` of refitted genes keep the value from before outlier replacement
维护者通常 1 天内回复
@aviralgarg05 已经在做这个了。
开始于 2026年11月17日。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 75/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 pydeseq2/dds.py 中的 _refit_without_outliers(大约第 1398-1409 行)开始,这里是 refit 列被复制回去的地方,并将其与 DESeq2 的 refitWithoutOutliers 比较,后者会复制每一列。将复制扩展到 MAP_dispersions、_genewise_converged、_MAP_converged、_LFC_converged 和 _outlier_genes,然后重新运行复现以确认 g1/g2 的 MAP_dispersions 与 dispersions 一致,并运行 dispersion/refit 测试。
由索引模型根据 Issue 内容生成。
描述
After deseq2() with refit_cooks=True, a refitted gene's MAP_dispersions is still the value from before outlier replacement, while dispersions comes from the refit: g1 has MAP_dispersions 0.59995 with and without the refit, and dispersions 0.11337 after it; DESeq2 1.50.2 reports dispMAP and dispersion of 0.11336 for g1, because refitWithoutOutliers copies every column of the refit back (mcols(object)[refitReplace, idx] <- mcols(objectSub)).
_refit_without_outliers (dds.py:1398-1409) copies _normed_means, LFC, genewise_dispersions, fitted_dispersions and dispersions, but not MAP_dispersions or the _genewise_converged, _MAP_converged, _LFC_converged and _outlier_genes columns; copying those too would fix it.
Source line numbers refer to commit 2ca3b74.
Reproduction
import numpy as np
import pandas as pd
from pydeseq2.dds import DeseqDataSet
def simulate(n_genes=200, groups=(4, 4), seed=0):
"""Counts (samples x genes) and metadata; dispersion 0.05 + 1 / mean."""
rng = np.random.default_rng(seed)
group = np.repeat(np.arange(len(groups)), groups)
base = rng.lognormal(4, 1.5, n_genes)
lfc = rng.normal(0, 0.5, (len(groups), n_genes))
lfc[0] = 0
mu = base * np.exp(lfc[group])
disp = 0.05 + 1 / base
counts = rng.negative_binomial(1 / disp, 1 / (1 + disp * mu))
samples = [f"s{i}" for i in range(len(group))]
counts = pd.DataFrame(counts, index=samples, columns=[f"g{j}" for j in range(n_genes)])
metadata = pd.DataFrame({"condition": np.array(list("ABCDEF"))[group]}, index=samples)
return counts, metadata
def dataset(counts, metadata, **kwargs):
return DeseqDataSet(counts=counts, metadata=metadata, n_cpus=1, quiet=True, **kwargs)
counts, metadata = simulate(n_genes=100, groups=(7, 7), seed=2)
counts.loc["s0", ["g1", "g2"]] *= 20
counts.to_csv("counts.csv")
metadata.to_csv("metadata.csv")
for refit in [True, False]:
dds = dataset(counts, metadata, refit_cooks=refit)
dds.deseq2()
columns = ["MAP_dispersions", "dispersions"] if refit else ["MAP_dispersions"]
print(f"refit_cooks={refit}:", dds.var.loc[["g1", "g2", "g4"], columns].round(5).to_dict())
Expected: after the refit, MAP_dispersions equal to dispersions for g1 and g2, as in DESeq2.
Actual, with PyDESeq2 0.6.0:
refit_cooks=True: {'MAP_dispersions': {'g1': 0.59995, 'g2': 0.41028, 'g4': 0.06673}, 'dispersions': {'g1': 0.11337, 'g2': 0.07503, 'g4': 0.06673}}
refit_cooks=False: {'MAP_dispersions': {'g1': 0.59995, 'g2': 0.41028, 'g4': 0.06673}}
DESeq2 1.50.2 on the counts that the reproduction writes:
suppressMessages(library(DESeq2))
counts <- t(as.matrix(read.csv("counts.csv", row.names = 1, check.names = FALSE)))
coldata <- read.csv("metadata.csv", row.names = 1, stringsAsFactors = TRUE)
dds <- DESeq(DESeqDataSetFromMatrix(counts, coldata, ~condition), quiet = TRUE)
round(as.data.frame(mcols(dds)[c("g1", "g2", "g4"), c("dispMAP", "dispersion")]), 5)
# dispMAP dispersion
# g1 0.11336 0.11336
# g2 0.07500 0.07500
# g4 0.06669 0.06669
Split out from #491.
- 主要语言
- 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 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/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 天内回复
-
`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 天内回复