Skip to content

RSeQC

RustQC reimplements nine tools from the RSeQC package (including TIN and split_bam). Each tool produces output files that match the format and content of the original Python implementation, plus native PNG and SVG plots generated directly – no R scripts required.

All RSeQC tools except split_bam (which needs a BED file) run automatically as part of the rustqc rna command and use the input filename stem as a prefix for output files. Output files are organized into per-tool subdirectories under rseqc/. For example, rustqc rna sample.bam --gtf genes.gtf -o results/ produces RSeQC output files like results/rseqc/bam_stat/sample.bam_stat.txt.

Use --flat-output to write all files directly to the output directory instead of the nested rseqc/<tool>/ subdirectories.

Basic alignment statistics from a single-pass BAM scan.

File Description
{stem}.bam_stat.txt Formatted text report with total records, QC failures, duplicates, mapping quality distribution, splice reads, proper pairs, and more

The output format matches bam_stat.py exactly, including the same section headings and number formatting. Key metrics include:

  • Total records, QC-failed, duplicates, non-primary, unmapped
  • Unique and multi-mapped read counts at the configured MAPQ cutoff
  • Read 1 / Read 2 counts, forward/reverse strand counts
  • Splice / non-splice read counts
  • Proper pair and paired-on-different-chromosome counts
  • MAPQ distribution histogram

All values are identical between RSeQC and RustQC on both datasets.

Small dataset
Metric RSeQC RustQC
Total records 52,839 52,839
QC failed 0 0
Duplicates 6,097 6,097
Non-primary 3,266 3,266
Unmapped 0 0
mapq < cutoff 1,742 1,742
Unique reads 41,734 41,734
Read 1 / Read 2 20,871 / 20,863 20,871 / 20,863
Sense / Antisense 20,869 / 20,865 20,869 / 20,865
Non-splice / Splice 22,214 / 19,520 22,214 / 19,520
Properly paired 41,722 41,722
Large dataset
Metric RSeQC RustQC
Total records 201,605,452 201,605,452
QC failed 0 0
Duplicates 132,703,364 132,703,364
Non-primary 15,316,166 15,316,166
Unmapped 12,490,977 12,490,977
mapq < cutoff 2,036,975 2,036,975
Unique reads 39,057,970 39,057,970
Read 1 / Read 2 19,525,894 / 19,532,076 19,525,894 / 19,532,076
Sense / Antisense 19,529,185 / 19,528,785 19,529,185 / 19,528,785
Non-splice / Splice 27,689,719 / 11,368,251 27,689,719 / 11,368,251
Properly paired 39,030,552 39,030,552

Library strandedness inference by sampling reads overlapping gene models.

File Description
{stem}.infer_experiment.txt Strandedness fractions: failed-to-determine, and the two strand protocols

The output reports the fraction of reads consistent with each strand protocol:

  • Fraction failed to determine – reads that could not be assigned to either protocol
  • Fraction “1++,1–,2+-,2-+” (forward stranded) – reads consistent with the same-strand protocol
  • Fraction “1+-,1-+,2++,2–” (reverse stranded) – reads consistent with the opposite-strand protocol

For paired-end data, the labels are PairEnd with 1++,1--,2+-,2-+ and 1+-,1-+,2++,2--. For single-end: SingleEnd with ++,-- and +-,-+.

Interpreting results:

  • Both fractions near 50% = unstranded library
  • First fraction near 100% = forward stranded (e.g., Ligation protocol)
  • Second fraction near 100% = reverse stranded (e.g., dUTP protocol, most common)

Strandedness mismatch warning: RustQC automatically compares the infer_experiment results against the --stranded flag you specified. If they disagree, a warning is printed at the end of the run suggesting the correct value:

RustQC strandedness mismatch warning
Small dataset - Identical
Metric RSeQC RustQC
Failed to determine 0.0775 0.0775
Fraction sense (1++,1–,2+-,2-+) 0.0051 0.0051
Fraction antisense (1+-,1-+,2++,2–) 0.9174 0.9174
Large dataset - Minor difference (sampling)
Metric RSeQC RustQC
Failed to determine 0.0670 0.1052
Fraction sense (1++,1–,2+-,2-+) 0.0117 0.0185
Fraction antisense (1+-,1-+,2++,2–) 0.9213 0.8763

The difference is caused by a read-sampling mismatch: the upstream infer_experiment.py defaults to sampling only 200,000 reads. On a 186M-read BAM, this early-file subsample draws predominantly from the first few chromosomes, which underrepresents loci where transcripts on both strands overlap, causing the “failed-to-determine” fraction to appear lower than it truly is. RustQC processes all reads, giving a more representative estimate.

Both tools correctly identify the library as strongly reverse-stranded (antisense ~88-92%), so the practical interpretation is identical.

Position-based and sequence-based duplication rate histograms.

File Description
{stem}.pos.DupRate.xls Position-based duplication histogram (TSV: Occurrence, UniqReadNumber, ReadNumber)
{stem}.seq.DupRate.xls Sequence-based duplication histogram (TSV: Occurrence, UniqReadNumber, ReadNumber)
{stem}.DupRate_plot.r R script for generating duplication rate plots (matching RSeQC format)
{stem}.DupRate_plot.png Duplication rate plot (PNG)
{stem}.DupRate_plot.svg Duplication rate plot (SVG)

Each TSV file is a tab-separated table where each row represents a duplication level (number of times a read was seen). The columns are:

  • Occurrence – the duplication count (1 = unique, 2 = seen twice, etc.)
  • UniqReadNumber – number of unique read groups at this duplication level
  • ReadNumber – total reads consumed (Occurrence x UniqReadNumber)

Position-based deduplication groups reads by alignment position (chromosome, start, CIGAR-derived exon blocks). Sequence-based deduplication groups reads by the actual read sequence.

The duplication rate plot shows two curves: mapping-based (blue, x markers) and sequence-based (red, dot markers) duplication. The x-axis shows the occurrence count (capped at 500) and the y-axis shows the number of reads at each duplication level. Most reads should appear at low occurrence counts; a long tail indicates high duplication.

RSeQC
RustQC
RSeQC read duplication plot
RustQC read duplication plot

All values are identical on both datasets.

Small dataset (first few duplication levels)
Level Seq-based (unique reads) Pos-based (unique reads)
1x 37,943 33,183
2x 1,844 2,984
3x 492 693
4x 200 289
Large dataset (first few duplication levels)
Level Seq-based (unique reads) Pos-based (unique reads)
1x 24,661,232 15,958,022
2x 5,199,146 4,781,421
3x 3,211,713 2,988,951

Classification of reads across genomic feature types.

File Description
{stem}.read_distribution.txt Tabular report with total reads, total tags, and per-region breakdown

The output includes:

  • Total Reads and Total Tags (CIGAR M-block midpoints)
  • A table of genomic regions with columns: Group, Total_bases, Tag_count, Tags/Kb
  • Regions: CDS_Exons, 5’UTR_Exons, 3’UTR_Exons, Introns, TSS_up_1kb, TSS_up_5kb, TSS_up_10kb, TES_down_1kb, TES_down_5kb, TES_down_10kb
  • Tags assigned to each region (with priority: CDS > UTR > Intron > Intergenic)

All values are identical on both datasets.

Small dataset
Feature Total tags Tags/Kb
CDS Exons 56,186 -
5’ UTR Exons 1,226 -
3’ UTR Exons 7,495 -
Introns 2,905 -
Other intergenic 526 -

Total reads: 43,476 | Total tags: 68,660 | Total assigned: 68,134

Large dataset
Feature Total tags Tags/Kb
CDS Exons 40,028,987 401.24
5’ UTR Exons 572,203 104.93
3’ UTR Exons 5,549,140 206.28
Introns 7,332,516 4.87

Total reads: 41,094,945 | Total tags: 55,001,331 | Total assigned: 54,113,746

Splice junction classification against a reference gene model.

File Description
{stem}.junction.xls TSV with all observed junctions: chrom, intron_start(0-based), intron_end(1-based), read_count, annotation_status
{stem}.junction.bed BED12 file with color-coded junctions (red = known, green = partial novel, blue = complete novel)
{stem}.junction_plot.r R script for generating splice event and junction pie charts
{stem}.splice_events.png Splice events pie chart (PNG)
{stem}.splice_events.svg Splice events pie chart (SVG)
{stem}.splice_junction.png Splice junctions pie chart (PNG)
{stem}.splice_junction.svg Splice junctions pie chart (SVG)
{stem}.junction_annotation.log Summary: total/known/partial novel/complete novel event and junction counts

Junctions are classified by comparing splice sites (CIGAR N-operations) against the reference gene model:

  • Known (Annotated) – both donor and acceptor sites match known introns
  • Partial novel – one splice site matches, the other is novel
  • Complete novel – neither splice site matches any known intron

Two pie charts are generated, one for splice events (reads) and one for splice junctions (unique splice sites). Each chart shows the proportion of known (blue), partial novel (red), and complete novel (green) splicing.

RSeQC
RustQC
RSeQC splice events plot
RustQC splice events plot
RSeQC
RustQC
RSeQC splice junction plot
RustQC splice junction plot

All values are identical on both datasets.

Small dataset
Metric RSeQC RustQC
Splice events
Total events 23,448 23,448
Known 22,625 (96.49%) 22,625 (96.49%)
Partial novel 166 (0.71%) 166 (0.71%)
Novel 654 (2.79%) 654 (2.79%)
Splice junctions
Total junctions 3,261 3,261
Known 2,982 (91.44%) 2,982 (91.44%)
Partial novel 88 (2.70%) 88 (2.70%)
Novel 191 (5.86%) 191 (5.86%)
Large dataset
Metric RSeQC RustQC
Splice events
Total events 12,294,654 12,294,654
Known 12,155,894 12,155,894
Partial novel 91,594 91,594
Novel 41,082 41,082
Splice junctions
Total junctions 239,792 239,792
Known 175,159 175,159
Partial novel 45,554 45,554
Novel 19,079 19,079

The data files and R plotting scripts match upstream RSeQC output.

Splice junction discovery rate at increasing sequencing depths.

File Description
{stem}.junctionSaturation_plot.r R script for saturation curve plots
{stem}.junctionSaturation_plot.png Junction saturation plot (PNG)
{stem}.junctionSaturation_plot.svg Junction saturation plot (SVG)
{stem}.junctionSaturation_summary.txt TSV: percent_of_reads, known_junctions, novel_junctions, all_junctions

The tool subsamples reads at configurable percentages (default: 5%, 10%, …, 100%) and counts how many unique known and novel junctions are detected at each level. This reveals whether sequencing depth is sufficient for full junction detection. A saturated library will show a plateau in the curve; an unsaturated library will show continuing growth.

The junction saturation plot shows three lines: all junctions (blue), known junctions (red), and novel junctions (green). The x-axis is the percentage of total reads used and the y-axis is the number of splice junctions detected (in thousands). A plateau in the curves indicates saturation.

RSeQC
RustQC
RSeQC junction saturation plot
RustQC junction saturation plot

Results are identical between RSeQC and RustQC at full sampling depth on both datasets.

At 100% sampling depth:

Small dataset
Metric RSeQC RustQC
All junctions 3,261 3,261
Known junctions 2,944 2,944
Novel junctions 317 317
Large dataset
Metric RSeQC RustQC
All junctions 239,792 239,792
Known junctions 160,896 160,896
Novel junctions 78,896 78,896

RustQC follows RSeQC’s sampling: the percentages are range(floor, ceiling, step) followed by 100, and the window for each percentage uses RSeQC’s floating-point index arithmetic, int(N * (p / 100.0)). The x-axis values are therefore identical to RSeQC’s, and so is the 100% point whenever the windows cover all observations (as with the default parameters). The intermediate points depend on how the splice-junction observations are shuffled. RSeQC does not seed Python’s random, so its intermediate points change from run to run. RustQC shuffles with its own seeded RNG (--junction-saturation-seed, default 42), so its intermediate points are reproducible and identical for any --threads value, but they do not match RSeQC’s random draws.

As in RSeQC, reads on chromosomes without any annotated transcript are ignored. The pdf() call in the R script names the PDF by sample name only, as RSeQC does when run with -o <sample name>, so the script does not depend on the output directory.

Fragment inner distance for paired-end RNA-seq libraries.

File Description
{stem}.inner_distance.txt Per-pair detail: readpair_name, inner_distance, classification
{stem}.inner_distance_freq.txt Histogram: lower_bound, upper_bound, count
{stem}.inner_distance_plot.r R script for histogram and density plot
{stem}.inner_distance_plot.png Inner distance histogram with density overlay (PNG)
{stem}.inner_distance_plot.svg Inner distance histogram with density overlay (SVG)
{stem}.inner_distance_summary.txt Summary counts by pair classification

The inner distance is defined as the gap between the end of read 1 and the start of read 2 on the mRNA transcript. Negative values indicate read overlap. Pairs are classified as:

  • sameTranscript=Yes, sameExon=Yes – both reads on the same exon
  • sameTranscript=Yes, sameExon=No – reads on the same transcript, different exons (distance calculated on mRNA)
  • sameTranscript=No – reads on different transcripts or no transcript overlap
  • readPairOverlap – reads overlap each other
  • nonExonic – one or both reads not on exons
  • sameChrom=No – reads on different chromosomes
  • unknownChromosome – chromosome not in the gene model

The histogram bins are configurable via --inner-distance-lower-bound, --inner-distance-upper-bound, and --inner-distance-step (defaults: -250 to 250, step 5).

The inner distance plot is a histogram showing the distribution of fragment inner distances, with a Gaussian density curve (red) overlaid. The title displays the mean and standard deviation. The distribution should be approximately normal for a well-prepared library.

RSeQC
RustQC
RSeQC inner distance plot
RustQC inner distance plot

All frequency values are identical on both datasets.

Large dataset summary: mean = 29.378, median = 27.5, std dev = 32.799

The R plotting script (inner_distance_plot.r) matches upstream format exactly.

TIN (Transcript Integrity Number) measures the uniformity of read coverage across a transcript. A TIN score of 100 means perfectly uniform coverage; lower scores indicate degradation or bias. TIN is computed using Shannon entropy of per-base read coverage at sampled positions along each transcript’s exonic regions.

RustQC reimplements RSeQC’s tin.py, computing TIN scores automatically as part of rustqc rna in the same single-pass BAM scan as all other analyses.

TIN is particularly useful for:

  • Detecting RNA degradation: degraded samples show low TIN scores across most transcripts
  • Sample QC: median TIN provides a single-number summary of RNA integrity, complementing RIN (RNA Integrity Number) from Bioanalyzer/TapeStation
  • Identifying problematic samples: samples with unusually low median TIN should be flagged for potential exclusion
File Description
{stem}.tin.xls Per-transcript TIN scores (TSV: geneID, chrom, tx_start, tx_end, TIN)
{stem}.summary.txt Summary statistics: mean, median, and standard deviation of TIN scores

The {stem}.tin.xls file is a tab-separated file with one row per transcript:

Column Description
geneID Transcript identifier (as tin.py)
chrom Chromosome
tx_start Transcript start position
tx_end Transcript end position
TIN Transcript Integrity Number (0-100)

Transcripts below the minimum coverage threshold are reported with a TIN of 0.0 and are left out of the summary statistics, as in tin.py. TIN values are written at full precision, like Python’s str(float).

Rows follow the BED order produced by nf-core/rnaseq’s eautils/gtf2bed module. The converter sorts by chromosome name, the start of each transcript’s first exon line in the GTF, then transcript ID. Exons without a transcript ID are omitted. Older versions of the converter break ties in Perl hash order, which varies between runs.

The {stem}.summary.txt file is a single-row tab-separated summary:

Column Description
Bam_file File name of the input BAM
TIN(mean) Mean TIN across all transcripts
TIN(median) Median TIN
TIN(stdev) Standard deviation (population) of TIN

The statistics are computed as NumPy computes them in tin.py (pairwise summation), over the transcripts that passed the coverage threshold. If none pass, the summary reports nan for all three statistics.

Median TIN Interpretation
> 70 Good RNA integrity
50-70 Moderate degradation
< 50 Significant degradation – consider excluding
< 30 Severe degradation

A bimodal distribution of per-transcript TIN scores (some very high, some very low) can indicate selective degradation of certain transcript classes rather than global degradation.

TIN parameters (sample_size, min_coverage) can be set in the YAML config file. See the Configuration page for details. Like tin.py, TIN does not filter reads by mapping quality.

The upstream tin.py tool processes each transcript independently and scales poorly with BAM size. On large production datasets (e.g., ~186M reads), tin.py can take over 9 hours and may fail to complete within typical pipeline time limits. RustQC computes TIN scores as part of its single-pass BAM scan, completing all analyses combined in under 15 minutes.

RustQC’s TIN output uses the same file format and column names as RSeQC’s tin.py. TIN scores are computed using the same Shannon entropy formula.

tin.py counts coverage with pysam’s pileup() and its default settings, and RustQC reproduces what that pileup counts at each sampled position:

  • Reads flagged unmapped, secondary, QC-fail or duplicate are not counted, and neither are orphans (paired reads without the proper-pair flag).
  • Bases with a base quality below 13 are not counted.
  • Overlapping mates are counted once. RustQC replays htslib’s overlap quality adjustment (tweak_overlap_quality, htslib 1.24 as bundled with pysam 0.24), including its quirks after deletions and reference skips.
  • Deleted and skipped (N) bases are not counted. A transcript that passes the minimum read check but has no counted base gets 100 / l when some read spans a sampled position, and 0 otherwise, as in tin.py.

The one pileup setting not reproduced is the max_depth cap of 8,000 reads per position, which only matters for extremely deep transcripts.

Small dataset - Identical

All 8,443 per-transcript TIN values agree with tin.py (RSeQC 5.0.4, pysam 0.24.1) to within 1e-13. Three values differ in the last printed digit because of exp/log rounding differences between platforms’ maths libraries.

Metric RSeQC RustQC
TIN mean 53.4665 53.4665
TIN median 56.1341 56.1341
TIN std dev 22.8055 22.8055
Large dataset - Both tools completed (measured before the pileup-parity fix)

The upstream tin.py took 9h 45m to complete on the large dataset. RustQC completes TIN analysis as part of its single-pass BAM processing in under 15 minutes total (inclusive of all other analyses).

Metric RSeQC RustQC
TIN mean 70.193 70.208
TIN median 77.980 78.007
TIN std dev 23.588 23.597

Like tin.py, RustQC reports one TIN score per transcript. Rows are written in GTF transcript order, while tin.py follows the order of its BED file.

RustQC reimplements RSeQC’s split_bam.py, which classifies every alignment against a BED file of regions. Its main use is rRNA quantification with an rRNA BED file (for example RSeQC’s hg38_rRNA.bed). This counts rRNA that the GTF/biotype route cannot see; see why biotype rRNA can read near zero.

Unlike the other RSeQC tools, split_bam needs an extra input, so it only runs when a BED file is given:

rustqc rna sample.markdup.bam --gtf genes.gtf --split-bam-bed hg38_rRNA.bed

Each alignment record falls into exactly one category:

Category Records
in Mapped, QC-passing records whose start (or mate’s start) is in a region
ex Mapped, QC-passing records outside every region
junk QC-failed (0x200) or unmapped (0x4) records

Classification follows split_bam.py exactly:

  • The BED file is read as BED12, and only the exon blocks count. A read starting inside an intron of a BED12 record is ex.
  • A record is in when its own 0-based start lies in a block on its chromosome. If the mate-unmapped flag (0x8) is not set, the mate’s start is also tested, against the read’s own chromosome even when the mate maps elsewhere.
  • Only the start position is tested, not the whole alignment.
  • No other flags are filtered. Secondary, supplementary and duplicate alignments are all classified, so multi-mapping rRNA reads count once per reported alignment.
  • Chromosome names are compared case-insensitively against the alignment file’s reference names. The chromosome_prefix / chromosome_mapping settings (which map alignment names to GTF names) do not apply.

RustQC warns when no BED chromosome matches any reference name in the alignment file (for example a chr6 BED against an Ensembl 6 BAM), a mismatch that split_bam.py silently reports as 0% in.

File Description
{stem}.split_bam.txt Record counts, identical to split_bam.py’s stdout
{stem}.in.bam Records in the regions (optional)
{stem}.ex.bam Records outside the regions (optional)
{stem}.junk.bam QC-failed and unmapped records (optional)

The summary file is byte-for-byte what split_bam.py -o {stem} prints. For the test fixture (tests/expected/split_bam/split_bam_test.split_bam.txt):

Total records: 33
split_bam_test.in.bam (Alignments consumed by input gene list):15
split_bam_test.ex.bam (Alignments not consumed by input gene list):11
split_bam_test.junk.bam (qcfailed, unmapped reads): 7

The counts come from the single pass. Writing the .in.bam, .ex.bam and .junk.bam files is optional because it needs one extra sequential read of the alignment file:

rustqc rna sample.markdup.bam --gtf genes.gtf \
--split-bam-bed hg38_rRNA.bed --split-bam-write-bams

The BAM files keep the input header unchanged and the records in input order, matching split_bam.py.

split_bam can also be enabled from the config file. See the Configuration page.

Validated against RSeQC 5.0.4 split_bam.py:

  • Test fixture (tests/data/split_bam_test.*): 33 records covering every classification branch, with a BED12 that has multi-block, zero-length, overlapping, truncated-block and mixed-case entries. Counts and all three BAM files are identical, record for record.
  • Small dataset (~52K reads, chr6 subset): with a 4,000-record BED12 built around the reads, the counts (32,150 in / 20,689 ex) and all three BAM files are identical to split_bam.py on both the single-threaded and the parallel code paths.

BED inputs that split_bam.py crashes on are accepted. Blank, #, track and browser lines are skipped, and BED3–BED11 records are used as a single chromStart–chromEnd block, with a warning.

All output files are designed to be drop-in replacements for the corresponding RSeQC Python tool output. File formats, column names, and numeric precision match the Python originals to facilitate migration from RSeQC to RustQC without downstream pipeline changes.

RustQC also generates the R scripts that RSeQC produces (for junction_annotation, junction_saturation, inner_distance, and read_duplication), maintaining full compatibility. However, unlike RSeQC, RustQC generates the plots directly as PNG and SVG files – there is no need to run the R scripts separately.