feat: BED-interval rRNA quantification (split_bam) and featureCounts -M/-O - #133
Open
BenjaminDEMAILLE wants to merge 1 commit into
Open
feat: BED-interval rRNA quantification (split_bam) and featureCounts -M/-O#133BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
Biotype counting structurally under-reports rRNA on stock GRCh38/GENCODE builds: the 45S rDNA repeat is not annotated there (uniquely-mapped rRNA reads land in Unassigned_NoFeatures) and rDNA is a high-copy repeat, so most rRNA reads multi-map and are dropped as Unassigned_MultiMapping. The result is a %rRNA near zero even when true residual rRNA is several percent. Three changes address that: - New split_bam module (src/rna/rseqc/split_bam.rs), the counting side of RSeQC's split_bam.py. Given a BED file (--rrna-bed or rna.split_bam.bed) it classifies every alignment as in / ex / junk and writes a TSV of counts and percentages. It runs inside the existing single pass, is disabled unless a BED file is supplied, and deliberately does not filter secondary or supplementary alignments, which is what lets it see the rDNA multi-mappers featureCounts discards. No split BAM files are written. - featureCounts -M / -O equivalents: --count-multi-mapping and --count-multi-overlapping (plus config toggles). They affect the featureCounts gene-level and biotype-level counts only; dupRadar's matrix keeps its existing multi-mapper semantics. - Docs: a caution on the featureCounts page explaining why biotype %rRNA under-reports and what to use instead, a split_bam section on the RSeQC page, and CLI/config reference entries. Closes seqeralabs#111 Co-Authored-By: Claude Opus 5 (1M context) <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.
Closes #111.
Addresses all three asks in the issue.
1.
split_bam: BED-interval classificationNew module
src/rna/rseqc/split_bam.rs, the counting side of RSeQC'ssplit_bam.py. Runs inside the existing single pass, disabled unless a BED file is supplied:Output
rseqc/split_bam/{sample}.split_bam.tsv:Classification follows
split_bam.py: unmapped/QC-failed records arejunk; otherwise the read's own start, and the mate's start when the mate is mapped, are tested against the intervals. Secondary and supplementary alignments are deliberately not filtered — that is exactly what lets this route see the rDNA multi-mappers that featureCounts' default single-hit rule discards.Not implemented: the three output BAM files (
.in.bam/.ex.bam/.junk.bam) thatsplit_bam.pywrites. Writing three extra BAM copies would defeat the single-pass design; the docs point atsamtools view -Lfor that. Happy to add them behind a flag if you'd rather have full parity.2. featureCounts
-M/-O-M, --count-multi-mappingand-O, --count-multi-overlapping(plusrna.featurecounts.count_multi_mapping/count_multi_overlapping), applied to the gene-level and biotype-level featureCounts classification. dupRadar's duplicate-rate matrix is untouched — it tracks multi-mappers separately by design.On
tests/data/test.bam,-M -Omoves the 10 multi-mapping reads fromUnassigned_MultiMappingintoAssigned(473 → 483).3. Docs note
A caution box on the featureCounts page spelling out why biotype %rRNA reads near zero on stock GRCh38/GENCODE (45S rDNA unannotated + multi-mapper drop), pointing to
-M/-Oand tosplit_bam. Plus asplit_bamsection on the RSeQC page and CLI/config reference entries.Verification
samtools view -c tests/data/test.bam chr1:1001-3000= 107, matching theincount for achr1 1000 3000BED-M/-Obehaviour at gene and biotype levelcargo test— 207 lib + 18 integration tests passcargo fmt --check,cargo clippy -- -D warningsclean🤖 Generated with Claude Code