`lowess` returns 0 for points of an exact fit after robustness iterations

未关闭 适合新手
#520 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@aviralgarg05 已经在做这个了。

开始于 2026年11月17日。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
numpy, python
领域
data

调研方向

从 stats.py 第 116-121 行开始,这里的鲁棒性迭代决定绝对残差的中位数恰好为 0 是否意味着精确拟合;该阈值就是修复点。运行复现片段以确认 iter=1 通过,而 iter=5 在点 44-49 返回 0,然后改变斜率和截距以检查容差是否过宽。ds.py:480 显示了独立滤波中的调用方,但 issue 说 padj 的影响尚未验证,所以瞄准 lowess 测试。完成意味着两个迭代次数都保持在直线的 1e-6 范围内,并且现有的 stats 测试通过。

由索引模型根据 Issue 内容生成。

描述

bug

After a robustness iteration, stats.lowess weights points by their residual over six times the median absolute residual; on an exact fit the residuals are rounding noise, so some points get weight 0, and where a whole neighbourhood does, lstsq returns beta = 0 and the fitted value is 0, as at points 46 to 49 of the line y = 3 - 7.5x with frac=0.1, iter=5; a local linear regression of points on a line should return the line, as the same call does with iter=1. stats.py:116-121 treats only a median of exactly 0 as an exact fit; treating a median below a small multiple of the targets' scale as zero would fix it.
lowess smooths the rejection counts of independent filtering (ds.py:480), whose plateaus are locally exact fits; we have not looked for a dataset where this changes padj.

Source line numbers refer to commit 2ca3b74.

Reproduction
import numpy as np
from pydeseq2.stats import lowess
x = np.linspace(0.1, 0.95, 50)
y = 3 - 7.5 * x
for iterations in [1, 5]:
	fit = lowess(x, y, frac=0.1, iter=iterations)
	off = np.flatnonzero(np.abs(fit - y) > 1e-6)
	print(f"iter={iterations}: points off the line {off.tolist()}")
	if len(off):
		print("fitted:", fit[off].round(4).tolist())
		print("line:", y[off].round(4).tolist())

Expected: no points off the line for either number of iterations.

Actual, with PyDESeq2 0.6.0:

iter=1: points off the line []
iter=5: points off the line [44, 45, 46, 47, 48, 49]
fitted: [-3.373, -3.4016, 0.0, 0.0, 0.0, 0.0]
line: [-3.4745, -3.6046, -3.7347, -3.8648, -3.9949, -4.125]

Split out from #491.

主要语言
Python
星标
770
派生
98
平均合并
19 小时 55 分钟
30 天内合并 PR
45

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

scverse/PyDESeq2 的其他 Issue

查看 scverse/PyDESeq2 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。