2.19.0 — correct --flag-chimeras - #101
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A template-switch chimera is a query junction explained by two more abundant parents as prefix + suffix across one breakpoint.
chimera_parentsnames 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
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:
setdefaulton a descending list otherwise makes it claim its own prefix and the check is never consulted;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