Skip to content

Skip gene_summary header in mageckGSEA (fixes phantom "id" gene) - #21

Merged
davidliwei merged 2 commits into
mainfrom
fix/gsea-skip-header
Jul 14, 2026
Merged

Skip gene_summary header in mageckGSEA (fixes phantom "id" gene)#21
davidliwei merged 2 commits into
mainfrom
fix/gsea-skip-header

Conversation

@davidliwei

Copy link
Copy Markdown
Owner

Why

Addresses the P2 Codex review comment on #18: "Skip the gene_summary header before ranking."

mageck2 pathway --method gsea (the default) passes a *.gene_summary.txt whose first row is a header (id, num, neg|score, …). mageckGSEA's parserankfile() read every line, so the header became a phantom gene named id with score atof("neg|score") == 0. That inflated the total gene count by one and shifted the rank transform, percentile, and permutation calculations for every pathway on the default workflow — a small but systematic bias.

The RRA path is unaffected: its Python reader (mageck_readgeneranking) already skips line 1. Only the C++ GSEA path had the bug.

What

  • Add a -H / --skip-header switch to mageckGSEA; parserankfile() drops the first line when set.
  • Pass -H from all three gseacommand builders in pathwayFunc.py. The gene-ranking input always carries a header (consistent with the RRA reader), so it's passed unconditionally.
  • Regression test: a headered rank file read with -H scores identically to the same data with no header line.
  • CHANGELOG entry.

Verification

Clean-venv source install compiles RRA + mageckGSEA onto PATH; with -H, a headered 4-gene file reports rank size:4 (header dropped, previously 5). Full smoke suite 14/14 passes.

Note on the other Codex comment

The P1 comment on #18 (operator[] mapping off-list genes to rank 0) was already fixed in #19 and is on main via #20 — Codex reviewed the pre-#19 commit. No action needed there.

🤖 Generated with Claude Code

davidliwei and others added 2 commits July 14, 2026 14:09
… gene

mageck2 pathway --method gsea passes a *.gene_summary.txt whose first row is a
header, but mageckGSEA's parserankfile read every line, so the header became a
phantom gene named "id" (score atof("neg|score") == 0). That inflated the gene
count by one and shifted the rank transform, percentile, and permutation math
for every pathway on the default workflow. The RRA path already skips the header
(mageck_readgeneranking), so only the C++ GSEA path was affected.

Add a -H / --skip-header switch to mageckGSEA that drops the first line, and pass
it from all three gseacommand builders in pathwayFunc.py (the gene-ranking input
always carries a header, matching the RRA reader's assumption).

Adds a regression test asserting a headered file read with -H scores identically
to the same data with no header line, plus a CHANGELOG entry. Addresses the P2
Codex review comment on PR #18.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZcdrQdWJfczuqaMeZ3DBD
The prior assertion checked ES != 0.0 on a top-3-genes pathway whose enrichment
score is ~1.4e-17 (floating-point zero). macOS prints it as 1.38778e-17 while
Linux prints 0.0, so the sanity check failed on Ubuntu CI even though the real
assertion (headered + -H == headerless) passed on every platform.

Use a pathway (G14..G18, the lowest-scored genes, which cluster at one end of
the ranking) that yields a robustly non-zero ES (~0.87), and assert ES > 0.5.
The core regression -- -H makes a headered file score identically to the same
data headerless -- is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZcdrQdWJfczuqaMeZ3DBD
@davidliwei
davidliwei marked this pull request as ready for review July 14, 2026 22:36
@davidliwei
davidliwei merged commit a945a87 into main Jul 14, 2026
6 checks passed
@davidliwei
davidliwei deleted the fix/gsea-skip-header branch July 14, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant