Genes that are all zero after outlier replacement get p-value NaN instead of 1
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- bioinformatics
Hướng nghiên cứu
Bắt đầu từ _cooks_filtering trong pydeseq2/ds.py (khoảng dòng 515), nơi p-value của một gene bị gắn cờ bị ghi đè bằng NaN, và so sánh với cooks_outlier trong pydeseq2/dds.py (dòng 1043-1050), đoạn này đọc replace_cooks; lưu ý rằng chỉ các gene được fit lại mới có khoảng cách bị đặt về 0 (dds.py:1413-1414), nên new_all_zeroes_genes vẫn bị gắn cờ. Đọc run_wald_test (ds.py:322-325) để xem cách xử lý p-value bằng 1 hiện có từ #239, sau đó chạy script tái hiện để xác nhận NaN và thêm một kiểm thử hồi quy khẳng định pvalue là 1.0 đối với single sau summary().
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A gene whose only positive count is replaced as a Cook's outlier becomes all zero.
run_wald_test gives it p-value 1 (ds.py:322-325), and Cook's filtering in summary() then sets that p-value to NaN; DESeq2 1.50.2 reports 1 for the same gene, since results() sets the p-value of genes that are zero after replacement (nowZero) to 1 after its Cook's filtering.
cooks_outlier reads replace_cooks (dds.py:1043-1050), where only refitted genes have their distances zeroed (dds.py:1413-1414), so a gene that is replaced but not refitted stays flagged and _cooks_filtering (ds.py:515) overwrites its p-value.
Leaving new_all_zeroes_genes out of cooks_outlier, or setting their p-values to 1 after Cook's filtering, would fix it.
Related: #239, which set these genes' p-values to 1 in run_wald_test.
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)
from pydeseq2.ds import DeseqStats
counts, metadata = simulate(n_genes=60, groups=(8, 8), seed=4)
counts["single"] = [0] * 15 + [100]
counts.to_csv("counts.csv")
metadata.to_csv("metadata.csv")
dds = dataset(counts, metadata)
dds.deseq2()
print("new all-zero genes:", list(dds.new_all_zeroes_genes))
ds = DeseqStats(dds, contrast=["condition", "B", "A"], n_cpus=1, quiet=True)
ds.run_wald_test()
print("pvalue after run_wald_test:", ds.p_values["single"])
ds.summary()
print("pvalue after summary:", ds.results_df.loc["single", "pvalue"])
Expected: pvalue after summary: 1.0, as in DESeq2.
Actual, with PyDESeq2 0.6.0:
new all-zero genes: ['single']
pvalue after run_wald_test: 1.0
pvalue after summary: nan
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)
results(dds, contrast = c("condition", "B", "A"))["single", "pvalue"]
# [1] 1
Split out from #491.
- Ngôn ngữ chính
- Python
- Star
- 770
- Fork
- 98
- Merge trung bình
- 19 giờ 55 phút
- Pull request đã merge (30 ngày)
- 45
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của scverse/PyDESeq2
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`lowess` returns 0 for points of an exact fit after robustness iterationsCó thể làm lại được @aviralgarg05 đã nhận 15 ngày trước và không có pull request nào đang mở. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
scverse/PyDESeq2#520 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`irls_solver` does not enforce `min_beta` when IRLS converges, and documents `max_beta`'s default as -30Có thể làm lại được @aviralgarg05 đã nhận 15 ngày trước và không có pull request nào đang mở. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
scverse/PyDESeq2#521 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`MAP_dispersions` of refitted genes keep the value from before outlier replacementCó thể làm lại được @aviralgarg05 đã nhận 15 ngày trước và không có pull request nào đang mở. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
scverse/PyDESeq2#519 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của scverse/PyDESeq2
Issue tương tự
-
[Doc]: Feedback for `/zh-cn/v0.30.0/tutorials/models/Qwen3.6-35B-A3B.html`A3社区配置和基线不一致,社区配置也达不到基线Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
vllm-project/vllm-ascend#24429 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
simnJS/AnyPS5#735 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sqlreview.sh: `remap` with no review draft seeds one, and `delta` prints the diff then exits 2Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
nq-rdl/agent-extensions#623 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
vortex-data/vortex#12633 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
gke-labs/kube-agents#7955 ·
Maintainer thường phản hồi trong vòng 1 ngày