The parametric dispersion trend is fitted on genes that DESeq2 leaves out, and a gene dropped from it never returns
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Reproduce first with the script in the issue (counts.csv/metadata.csv), then read _fit_parametric_dispersion_trend in pydeseq2/dds.py (lines 1170-1219 at commit 2ca3b74) alongside DESeq2's estimateDispersionsFit/parametricDispersionFit logic described here. The change is to re-select genes above 100 * min_disp from the starting curve (0.1, 1) before each fit instead of dropping them permanently, using dispersion_trend_gamma_glm. Done when the reported coefficients match with and without the single-sample gene, and the existing dispersion tests still pass.
索引モデルが issue の本文から書いたものです。
説明
One gene with a single positive count changes the parametric dispersion trend (the default fit_type), and with it the prior centre of every gene's MAP dispersion: 100 simulated genes in two groups of six give coefficients (a0, a1) of (0.0507, 1.7973), and adding a gene whose only positive count is 30 gives (0.0389, 3.0042); DESeq2 1.50.2 gives (0.0505, 1.8002) with or without that gene, because estimateDispersionsFit keeps only genes with dispGeneEst > 100 * minDisp and parametricDispersionFit starts from the curve (0.1, 1) and, before every fit, selects from all of them the genes whose ratio to the current curve lies between 1e-4 and 15; the single-sample gene is 23.7 times the starting curve and never enters.
_fit_parametric_dispersion_trend (dds.py:1170-1219, which also fits vst_trend_coeffs) fits first on every non-zero gene and then drops genes outside the window without reconsidering them, so a gene that bent the first fit toward itself can stay (9.5 times the final curve here).
Selecting from the genes above 100 * min_disp before each fit, from the starting curve (0.1, 1), would fix it; that loop with PyDESeq2's own dispersion_trend_gamma_glm gives (0.0507, 1.7973) on these 101 genes.
Related: #482, which reported the same difference on public data and was closed by its author before review.
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=(6, 6), seed=1)
counts["single"] = [0] * 11 + [30]
counts.to_csv("counts.csv")
metadata.to_csv("metadata.csv")
for genes in [counts.columns[:-1], counts.columns]:
dds = dataset(counts[genes], metadata)
dds.fit_size_factors()
dds.fit_genewise_dispersions()
dds.fit_dispersion_trend()
print(len(genes), "genes, trend a0, a1:", [round(float(v), 4) for v in dds.uns["trend_coeffs"].values()])
Expected: the same coefficients with and without the single-sample gene, as in DESeq2.
Actual, with PyDESeq2 0.6.0:
100 genes, trend a0, a1: [0.0507, 1.7973]
101 genes, trend a0, a1: [0.0389, 3.0042]
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)
for (genes in list(setdiff(rownames(counts), "single"), rownames(counts))) {
dds <- estimateSizeFactors(DESeqDataSetFromMatrix(counts[genes, ], coldata, ~condition))
dds <- estimateDispersionsFit(estimateDispersionsGeneEst(dds, quiet = TRUE), quiet = TRUE)
print(round(attr(dispersionFunction(dds), "coefficients"), 4))
}
# asymptDisp extraPois
# 0.0505 1.8002 (both times)
Split out from #491.
- 主要言語
- Python
- スター
- 770
- フォーク
- 98
- 平均マージ
- 19時間 55分
- マージ済み PR(30日)
- 45
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン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 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン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 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
scverse/PyDESeq2#519 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
scverse/PyDESeq2 の issue をすべて見る
似ている issue
-
[Doc]: Feedback for `/zh-cn/v0.30.0/tutorials/models/Qwen3.6-35B-A3B.html`A3社区配置和基线不一致,社区配置也达不到基线オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
vllm-project/vllm-ascend#24429 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
simnJS/AnyPS5#735 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
nq-rdl/agent-extensions#623 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
vortex-data/vortex#12633 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
gke-labs/kube-agents#7955 ·
メンテナーはふだん 1 日以内に返信