Repository navigation
Port STAR's WithinBAM output (supersedes #282); PE nM is the pair's - #307
Merged
Merged
Conversation
count chimericBAMoutput/alignBAM ported over the detector's two-mate transcripts: the chimera replaces the read's normal output, STAR's representative / supplementary choice, hard/soft clipping, flags, mate fields, attributes and SA tags. --chimOutType: BAM required, NM added, up to 3 values, unknown values rejected. Paired-end nM is now the pair's mismatch count on both mates (was per mate; differed from STAR on 42% of yeast PE pairs).
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.
--chimOutType WithinBAMported from STAR; paired-endnMfix (supersedes #282)WithinBAM output didn't match STAR for a single chimeric read: 0/20 SE and 0/12 PE on yeast 10k, compared record by record. The problems were structural:
NH/HI/nM, wrongASand no mate fields.#282 patched three of these on the old per-mate builder. This PR replaces that builder with a port of STAR's own code instead.
What changed
New
src/chimeric/bam.rs. PortsChimericAlign::chimericBAMoutputand the mapped branch ofReadAlign::alignBAM. It works from the same STAR-shaped window transcripts the detector (#284) uses, so a paired segment covering both mates becomes two records, as in STAR.chimRepresent/chimType):0x800): hard-clipped on the junction side (-11/-12, with SEQ/QUAL trimmed), or soft-clipped with--chimOutType ... SoftClip(-13).0x100for non-best chimeras), MAPQ from the number of chimeras, mate fields perchimericBAMoutput, TLEN for two-mate records, andNH/HI/AS/nM/NM/XS/jM/jI/MD.ASandnMcome from STAR's re-scoring of the placed transcripts.NM.The read's normal output is replaced, not supplemented. STAR returns before
outputAlignmentswhen it writes a chimera into the BAM (ReadAlign_oneRead.cpp:99), and so do we now:Log.final.out, but still counted as input. Unmapped reasons still count, sincemappedFilterruns first;SJ.out.tab, gene counts, transcriptome BAM or unmapped FASTQ for the read.The four writer-thread loops that appended chimeric records after each batch are removed. Records are now emitted in read order from the alignment workers.
--chimOutType(ParametersChimeric_initialize.cpp):WithinBAMrequires--outSAMtype BAM; with SAM output it is now an error, as in STAR.WithinBAMaddsNMto the output attributes, as STAR does. The SA tag's last field reads it.Junctions WithinBAM HardClip. The last ofHardClip/SoftClipwins, and hard clipping is the default.SeparateSAMoldis refused rather than accepted and silently ignored; it is not implemented.Paired-end
nM(normal output too). STAR writes the pair's mismatch count (trOut.nMM) on both mates, the same way it writesAS. We wrote each mate's own count. That differed from STAR on 3,444 of 8,280 yeast PE pairs whose alignments otherwise match, and went unnoticed becausecompare_pe.pychecks positions and CIGARs, not tags. After the fix, all 8,280 match STAR including every tag. The two unit tests that asserted the per-mate value were updated.Results vs STAR 2.7.11b
Yeast 10k (
$DATA),--chimSegmentMin 12 --outSAMtype BAM .... Every record of every chimeric read was compared on fields 2–11 plus all tags.WithinBAM(HardClip / SoftClip / sorted)Junctions WithinBAM --chimMultimapNmax 10WithinBAM(HardClip / SoftClip / sorted)The remaining differences are known and outside this PR:
Log.final.out: SE now matches STAR's WithinBAM run exactly, including uniquely mapped (8249 vs 8265 without WithinBAM) and average mapped length. The only difference is the chimeric count, 19 vs 20, from the same SE miss. PE differs only in "splices: Total / Non-canonical" (273/22 vs 271/20), which is pre-existing: the same difference appears with no chimeric options at all.Other modes:
--outStd BAM_Unsortedgives the same records.nM.Tests
bam.rs:NMpresent;SoftClipmode.params:chim_out_type_follows_star, covering the BAM requirement,NMadded, three values, last clip mode winning, and unknown /SeparateSAMoldrejected.cargo fmt --check,cargo clippy --all-targets -- -D warnings(clippy 1.99) andcargo test(638 tests) all pass.Docs
guides/chimeric.mdstill described the five detection tiers #284 removed, and two of its column descriptions were wrong (columns 11 and 13 are genomic start positions). It now describes STAR's two detectors, WithinBAM's real behaviour, and thepCIGAR.cli-parameters.mdandoutput-files.mdare updated to match.Supersedes #282.