Repository navigation
fix(parser): prefer the read orientation with an exact barcode hit - #16
Merged
Merged
Conversation
parse_barcodes took the first orientation (forward, then reverse complement) whose barcode corrected to the whitelist, even when that was a Hamming-1 correction and the other orientation was an exact hit. Now an exact hit in either orientation wins; corrections are used only when neither is exact. Ties (both exact / both corrected) keep the forward orientation and are counted. Orientation counts go to the run log (stats.barcode_orientation). New run() options barcode_prefer_exact (CLI --barcode_prefer_exact/--no-barcode_prefer_exact) and legacy (CLI --legacy); legacy=True restores the v2-base choice exactly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alongside barcode_prefer_exact/legacy) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- legacy=True now forces both tso_g_max=None and barcode_prefer_exact=False
- parse_barcodes takes tso_g_max, prefer_exact and return_counts together
- fix a silent semantic conflict: the new exact-hit orientation path still used
s[36:].lstrip("G"), which would have bypassed #15 for nearly every read; it now uses
strip_tso_g(s[36:], tso_g_max). Added tests covering both orientation paths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Updated after #15 merged: merged |
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.
Problem
parse_barcodestries the forward read first, then its reverse complement, and keeps the first orientation whose 16-nt barcode corrects to the whitelist. A forward barcode that only matches after a Hamming-1 correction therefore wins over a reverse complement that is an exact whitelist hit. That assigns the read to the wrong droplet barcode and the wrong UMI, and it uses the wrong strand as the insert.Fix
New orientation choice in
parse_barcodes(prefer_exact=True)(helper_choose_orientation):Counts per run are written to the run log under
stats.barcode_orientation:exact_fwd,exact_rc,corrected_fwd,corrected_rc;both_exactandboth_corrected(ties, forward kept);switched: reads where an exact reverse-complement hit replaced the corrected forward barcode thatv2-baseused.parse_barcodes(return_counts=True)returns(path, counts); by default it still returns only the path. Offsets, UMI and insert extraction are unchanged.New
run()arguments, documented in the docstring:barcode_prefer_exact: bool = True(CLI--barcode_prefer_exact/--no-barcode_prefer_exact);legacy: bool = False(CLI--legacy).legacy=Trueforces thev2-basechoice.pairplex correct-barcodesalso callsparse_barcodesand gets the new default (no legacy flag there).Tests
New file
pairplex/tests/test_barcode_orientation.py, built on constructed reads and a 3-barcode whitelist:switchedis counted);prefer_exact=Falsereproduces the old choice;check_rc=Falseignores the reverse complement;run()default vslegacy=Truevsbarcode_prefer_exact=False.Full suite: 28 passed.
Smoke run on 2 SimPlex wells with 2 workers: default and
legacy=Trueboth matchv2-baseexactly (metadata, annotated tables, consensus set). The run log showsexact_fwd=12580,both_exact=1and no corrections. SimPlex barcodes in these wells contain no errors, so orientation conflicts cannot occur there. Expect SimPlex benchmark rows to be the same as baseline; real data is where this fix can matter.Benchmark
Pending:
D4-orient-exact-v1(default) vsv2-base. Results will be added here.🤖 Generated with Claude Code