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

Aperta Adatta ai principianti
#520 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@aviralgarg05 ci sta già lavorando.

Dal 17/11/2026.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
numpy, python
Ambito
data

Direzione di ricerca

Inizia da stats.py righe 116-121, dove l'iterazione di robustezza decide se un residuo assoluto mediano esattamente 0 significhi un fit esatto; quella soglia è la correzione. Esegui lo snippet di riproduzione per confermare che iter=1 passa mentre iter=5 restituisce 0 ai punti 44-49, poi varia pendenza e intercetta per verificare che la tolleranza non sia troppo ampia. ds.py:480 mostra il chiamante nel filtraggio indipendente, ma l'issue dice che l'effetto di padj non è verificato, quindi punta ai test lowess. Fatto significa che entrambi i conteggi di iterazioni restano entro 1e-6 dalla linea e i test stats esistenti passano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
770
Fork
98
Merge medio
19h 55m
PR unite (30g)
45

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di scverse/PyDESeq2

Tutte le issue di scverse/PyDESeq2

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.