`prior_LFC_var` is squared in the Wald test's ridge
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #537 của @VamikaSinghal — đã đóng, không merge
Đá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ệ
- numpy, python
- Lĩnh vực
- bioinformatics
Hướng nghiên cứu
Ridge được xây dựng tại ds.py:293 trong DeseqStats dưới dạng np.diag(1 / self.prior_LFC_var**2); hãy đọc constructor đó và docstring của prior_LFC_var trước. Chạy bản tái hiện từ issue để xác nhận rằng DeseqStats.SE hiện khớp với Wald SE I / 16 (1.098596) thay vì 0.841471 cho prior_LFC_var=[4, 4]. Bỏ bình phương là bản sửa tối thiểu; cũng cân nhắc xem có cần hiệu chỉnh thang đo log(2)^2 hay không, sau đó chạy các kiểm thử Wald dưới tests/ để kiểm tra rằng không có gì khác thay đổi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
DeseqStats(prior_LFC_var=...) uses the reciprocal of the square of each value as the Wald test's ridge: with prior_LFC_var=[4, 4] the lowest-count gene's standard error is 1.098596, the one with ridge I / 16, not 0.841471, the one with ridge I / 4; the docstring calls it the "Prior variance for LFCs, used for ridge regularization", and a normal prior with variance v has penalty 1 / v, as in DESeq2's fitGLMsWithPrior (lambda <- 1/betaPriorVar). ds.py:293 sets ridge_factor = np.diag(1 / self.prior_LFC_var**2); np.diag(1 / self.prior_LFC_var) would match the docstring, which could also give the scale (DESeq2's prior variance is on the log2 scale and fitNbinomGLMs divides lambda by log(2)^2, while this ridge applies to natural-log coefficients).
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)
import numpy as np
from pydeseq2.ds import DeseqStats
from pydeseq2.glm import wald_test
dds = dataset(*simulate(n_genes=50, groups=(4, 4), seed=6))
dds.deseq2()
ds = DeseqStats(dds, contrast=["condition", "B", "A"], prior_LFC_var=np.array([4.0, 4.0]), n_cpus=1, quiet=True)
ds.run_wald_test()
gene = dds.var["_normed_means"].idxmin()
X = dds.obsm["design_matrix"].to_numpy()
lfc = dds.varm["LFC"].loc[gene].to_numpy()
mu = dds.obs["size_factors"].to_numpy() * np.exp(X @ lfc)
for v in [4.0, 16.0]:
se = wald_test(X, dds.var.loc[gene, "dispersions"], lfc, mu, np.eye(2) / v, np.array([0.0, 1.0]), 0.0, None)[2]
print(f"Wald SE with ridge I / {v:g}: {se:.6f}")
print(f"DeseqStats.SE with prior_LFC_var=[4, 4]: {ds.SE[gene]:.6f}")
Expected: DeseqStats.SE equal to the standard error with ridge I / 4.
Actual, with PyDESeq2 0.6.0:
Wald SE with ridge I / 4: 0.841471
Wald SE with ridge I / 16: 1.098596
DeseqStats.SE with prior_LFC_var=[4, 4]: 1.098596
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ự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
nael5x/creative-ai#130 ·
-
Make the "%" unit spacing the same in the web and in A10Có thể đã có người làm @kragent66-glitch đã nhận hôm nay. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 bình luận ·
-
ci severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TMHSDigital/Spackle#205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pkg:lgm type:chore upstream-gaussx
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jejjohnson/pyrox#610 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug Report] J'ai passé l'imprimante sur un nouveau réseau wifi sur laquelle elle a récupéréĐang mởbug user-report
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày