Skip to content

2.19.0 — correct --flag-chimeras - #101

Merged
mikessh merged 2 commits into
masterfrom
feat/chimera-flag
Aug 11, 2026
Merged

2.19.0 — correct --flag-chimeras#101
mikessh merged 2 commits into
masterfrom
feat/chimera-flag

Conversation

@mikessh

@mikessh mikessh commented Aug 11, 2026

Copy link
Copy Markdown
Member

A template-switch chimera is a query junction explained by two more abundant parents as prefix + suffix across one breakpoint. chimera_parents names them and the breakpoint. Off by default; it never drops a row.

⛔ The germline trap, measured — it is the whole filter

A junction is V 3' tail + N/P/D + J 5' head, and both tails are germline: every clonotype on a V starts with the same bases, every one on a J ends with them. On a TRA amplicon the median V-templated prefix is 10 nt and the median J-templated suffix 25 nt, against a median clone-specific core of 5 nt.

So the same prefix/suffix test run on the raw junction rediscovers the germline and calls 52.20 % of clonotypes chimeric (35.50 % of reads). With the templated tails excluded and 6 non-templated nt required each side: 0.02 %.

⛔ Cell Ranger's rule does not port to bulk, and not because of the constant

Contigs sharing a V prefix ≥ 25 nt with differing CDR3s is a chimera signature within a barcode, where there is ~1 clone per chain. A polyclonal bulk repertoire has thousands of real clones per V gene — there, that rule describes almost every pair. What ports is UCHIME's shape, two more abundant parents, because the abundance ordering rather than the partition is what makes it a claim.

Measured rate

library clonotypes flagged reads
Bulk RNA-seq (IG) 1,741 7 (0.40 %) 13 (0.18 %)
TRA amplicon 19,844 1 (0.01 %) 1

A 20× bulk-vs-amplicon enrichment, in the direction template-switch chemistry predicts — but far too small to justify deleting clonotypes, and the signature cannot separate a true chimera from two real clones that happen to share a prefix and a suffix. Hence a flag.

Requires the reference: with no anchors the germline cannot be excluded, so it emits nothing rather than a germline-driven guess.

Tests

⚠ Every guard is mutation-tested, and three of the first five tests passed with the bug in:

  • the germline test needed a query sharing only germline with each parent (the first version had no suffix parent, so nothing fired however wrong the code was);
  • the abundance test needed the query to sort lastsetdefault on a descending list otherwise makes it claim its own prefix and the check is never consulted;
  • the SHM test needed both parents to genuinely match.

A fifth guard proved unreachable — an identical twin has Hamming 0, already caught by the ≤ 2 SHM check — and was deleted rather than left looking load-bearing.

858 pass across three tiers. Default output byte-identical; the column appears only with the flag.

🤖 Generated with Claude Code

mikessh and others added 2 commits August 11, 2026 19:31
A template-switch chimera is a query junction explained by two MORE ABUNDANT
parents as prefix + suffix across one breakpoint. `chimera_parents` names them;
off by default and NEVER used to drop a row.

⛔ THE TRAP, measured. A junction is `V 3' tail` + `N/P/D` + `J 5' head`, and
both tails are GERMLINE -- every clonotype on a V starts with the same bases,
every one on a J ends with them. On a TRA amplicon the median V-templated prefix
is 10 nt and the median J-templated suffix 25 nt against a median clone-specific
core of 5 nt. So the test run on the raw junction rediscovers the germline and
calls 52.20 % of clonotypes chimeric (35.50 % of reads). With the templated
tails excluded and 6 non-templated nt required each side: 0.02 %.

⛔ Cell Ranger's rule (contigs sharing a V prefix >= 25 nt with different CDR3s)
does NOT port to bulk, and not because of the constant -- it relies on the
BARCODE PARTITION, where ~1 clone per chain makes a second V-sharing contig an
artifact. A polyclonal bulk repertoire has thousands of real clones per V gene.
What ports is UCHIME's shape, because abundance ordering rather than the
partition is what makes it a claim.

Measured rate: 0.40 % of clonotypes / 0.18 % of reads on bulk RNA-seq (IG)
against 0.01 % on a TRA amplicon -- a 20x enrichment in the direction
template-switch chemistry predicts, but far too small to justify deleting
clonotypes, and the signature cannot separate a true chimera from two real
clones sharing a prefix and a suffix. Hence a flag.

⚠ Every guard was mutation-tested, and THREE of the first five tests passed with
the bug in -- the discipline this repo already records. The germline test needed
a query sharing only germline with each parent (the first version had no suffix
parent, so nothing fired however wrong the code was); the abundance test needed
the query to sort LAST, since `setdefault` on a descending list otherwise makes
it claim its own prefix; the SHM test needed both parents to genuinely match.
A fifth guard (identical parent) proved unreachable -- Hamming 0 is already
caught by the <= 2 SHM check -- and was removed rather than left looking
load-bearing.

Default output byte-identical; the column appears only with --flag-chimeras.
858 tests pass across three tiers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Off by default; flags, never filters. Default output byte-identical.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mikessh
mikessh merged commit b4089a8 into master Aug 11, 2026
1 check passed
@mikessh
mikessh deleted the feat/chimera-flag branch August 11, 2026 18:14
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