Repository navigation
Warn when read bases contradict the aligner's strand tag - #98
Merged
Merged
Conversation
Biscuit, bwameth and gem3 reads are decoded on the strength of the aligner's strand tag. bwa-meth assumes a directional library: for a non-directional one it gives most complementary-strand pairs a tag that contradicts their bases, and every CpG in such a read is then called methylated whatever its true state. Until now that was silent. The check: a read reports on one strand, so only one base of each CpG can show a conversion. The other base (G for a top-strand read, C for a bottom-strand read) is never converted. Wherever a read covers that other base, the extractor now looks at it and counts the CpGs where it shows the other strand's conversion product (A at the G, T at the C). - A RuntimeWarning is raised for a BAM when more than 2% of at least 1,000 checked CpGs contradict their read's tag. The CLI prints it in that BAM's report; the output file is still written. - With verbose=True / --verbose the counts are printed for every BAM. - Bismark reads are not checked: Bismark resolves the strand itself. - It warns only. Repairing the calls would need the reference sequence to infer each read's strand. On real data: 0 of 1,617 CpGs contradict in the bundled directional bwa-meth fixture, and 245 of 1,542 (15.9%) in real bwa-meth alignments of complementary-strand pairs, now bundled as bwameth_nondirectional.bam. Sequencing errors in real directional EM-seq data account for about 0.05%. Cost: about 6% more time on the base-decoding path; output is unchanged. Tests: hand-built cases for what is and is not counted and for the thresholds; simulated reads with deliberately wrong tags, with the counts checked against an independent count in serial and parallel runs; the real mis-tagged fixture; the CLI report.
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Summary
Adds a per-BAM check that catches wrongly strand-tagged reads, the situation found in #97: a non-directional library aligned with bwa-meth, where most complementary-strand pairs get a
YDtag that contradicts their bases and every CpG in them is then called methylated. Until now that was silent.How it works
A read reports on one strand, so only one base of each CpG can show a conversion. The other base never does: the
Gfor a top-strand read, theCfor a bottom-strand read. Wherever a read covers that other base, the extractor now looks at it and counts the CpGs where it shows the other strand's conversion product (Aat the G,Tat the C).RuntimeWarningis raised. The CLI prints it in that BAM's report. The output file is still written.--verbosethe counts are printed for every BAM, warning or not.Does it separate the cases?
bwameth.bam)bwameth_nondirectional.bam, new)tests/test.bam), sequencing errors onlyThe 2% limit sits well above the error rate and well below the mis-tagged case.
Limits
--verboseon a real BAM with its reference will show the actual figure.Tests
378 pass.
nox: all 12 sessions pass locally.