Skip to content

Record the DESeq2 length model, guard --tag_seq, and document its measured effect - #43

Merged
sr320 merged 2 commits into
mainfrom
workflow/three-prime-tag
Oct 13, 2026
Merged

sr320 merged 2 commits into
mainfrom
workflow/three-prime-tag

Conversation

@sr320

@sr320 sr320 commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Shrunk on 2026-10-12. This PR first added a 3′ Tag-seq mode as --library_protocol three_prime_tag. Meanwhile #24 merged an equivalent switch, --tag_seq, which does the same three things: Salmon --noLengthCorrection, DESeq2 without length offsets, and fastp poly-X trimming. It also drops --gcBias for paired-end Tag-seq. main was merged in and #24's implementation kept everywhere, so --library_protocol is gone.

What remains is what #24 lacks:

  1. The length model is recorded. The DESeq2 design JSON, and so the manifest's deseq2_design, now carries tag_seq and a length_model string:

    • none: counts without length offsets (tag_seq);
    • tximport average transcript length offsets;
    • lengthScaledTPM counts summed per replicate unit (pseudo-bulk).

    It says whether a study's fold changes carry length offsets, which decides whether they can be compared with other studies'.

  2. Guard tests. tests/test_rnaseq_tag_seq.py checks the --tag_seq wiring in fastp, Salmon, DESeq2 and the manifest. It reads the workflow source, because CI's Python job has no Nextflow, Salmon or R. CI's Nextflow job already stub-runs the --tag_seq DAG (from Support single-end and 3' Tag-seq RNA-seq, and designs from authors' tables #24).

  3. Evidence in the README. The README said length correction makes long genes look less expressed. The measured consequence is worse: it can create fold changes.

  4. The oyster backlog's Tag-seq caveat for PRJNA913164 now points to --tag_seq.

The evidence

This was re-measured with #24's code. Both modes ran natively against six simulated QuantSeq-like single-end libraries (3 vs 3) and the full M. galloprovincialis RefSeq transcriptome. 60 genes were given a 4-fold change. Another 40 genes switch to an isoform about 2.7 times longer with no change in 3′ reads, so their true log2 fold change is 0.

Mode 4-fold changes recovered Isoform-switch genes called Median |log2FC| on those genes length_model in manifest
--tag_seq 59 / 60 0 / 40 0.09 none: counts without length offsets (tag_seq)
standard 59 / 60 26 / 40 0.84, up to 3.0 tximport average transcript length offsets

The --tag_seq run passed --noLengthCorrection to all 6 Salmon tasks and --trim_poly_x to all 6 fastp tasks. The standard run used neither.

Verification

  • 433 tests pass and ruff is clean.
  • The design-record fields were read back from real runs in both modes.

For the clam study (#41)

Set tag_seq = true in config/TUCCI2025_HEAT_PRIMING.config. The study's registration still says the mode is unbuilt and needs updating.

🤖 Generated with Claude Code

sr320 and others added 2 commits October 12, 2026 16:42
…ee_prime_tag)

3' Tag-Seq libraries (Lexogen QuantSeq and similar) yield reads in
proportion to a transcript's abundance, not its length, so length
correction is wrong for them. The new --library_protocol parameter
(default full_length, so existing runs are unchanged) selects:

- Salmon --noLengthCorrection, the option Salmon documents for QuantSeq;
- DESeq2 on raw counts (tximport countsFromAbundance "no" into
  DESeqDataSetFromMatrix), with no average-transcript-length offsets;
  with --replicate_unit, raw counts are summed per unit;
- fastp --trim_poly_x for reads that run into the poly(A) tail.

The protocol and the length model used are recorded in the manifest and
the DESeq2 design JSON; an unknown protocol stops the run.

Verified natively on simulated QuantSeq-like reads from the full
M. galloprovincialis transcriptome: both modes recover 59/60 simulated
4-fold changes, but for 40 genes whose expressed isoform switched to a
~2.7x longer one with no change in 3' reads, full_length calls 26
differentially expressed (|log2FC| up to 3.0) and three_prime_tag calls
none. Rerunning an earlier full_length smoke run with this code gives
byte-identical DESeq2 results. CI stub-runs the three_prime_tag DAG and
rejects an unknown protocol; tests/test_rnaseq_protocols.py guards the
wiring.

Needed by TUCCI2025_HEAT_PRIMING (PRJNA1132140, draft PR #41).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hat it lacks

main (#24) added a 3' Tag-seq path, --tag_seq, doing what this branch's
--library_protocol three_prime_tag did (Salmon --noLengthCorrection,
DESeq2 without length offsets, fastp poly-X trimming), plus dropping
--gcBias for paired-end Tag-seq. #24's implementation is kept everywhere
and --library_protocol is removed. What remains:

- the DESeq2 design JSON records tag_seq and the length model actually
  fitted, so the manifest says whether fold changes carry length offsets;
- tests/test_rnaseq_tag_seq.py guards the --tag_seq wiring (CI's Python
  job has no Nextflow, Salmon or R);
- the README gains the measured consequence: on simulated QuantSeq-like
  reads, the standard path called 26 of 40 isoform-switch genes (no
  change in 3' reads) differentially expressed and --tag_seq none,
  re-measured with #24's code on 2026-10-12;
- the oyster backlog's Tag-seq caveat points to --tag_seq.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sr320 sr320 changed the title Add a 3' Tag-seq mode to the RNA-seq workflow (--library_protocol three_prime_tag) Record the DESeq2 length model, guard --tag_seq, and document its measured effect Oct 13, 2026
@sr320 sr320 mentioned this pull request Oct 13, 2026
9 tasks done
@sr320
sr320 merged commit 5afa043 into main Oct 13, 2026
6 checks passed
@sr320
sr320 deleted the workflow/three-prime-tag branch October 13, 2026 00:24
sr320 added a commit that referenced this pull request Oct 13, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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