Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
> [preseq](https://github.com/smithlabcode/preseq) `lc_extrap`)
> - **samtools-compatible** flagstat, idxstats, and full stats output
> - **Gene body coverage** profiling with Qualimap-compatible output
> - **bigWig** genome coverage tracks (bedtools `genomecov` + UCSC `bedClip` /
> `bedGraphToBigWig`; nf-core/rnaseq's three files by default)
>
> Binary crate (`rustqc`), Rust edition 2021.

Expand Down Expand Up @@ -64,7 +66,7 @@ src/
io.rs — Shared I/O utilities (gzip-transparent file reading)
gtf.rs — GTF annotation file parser (with configurable attribute extraction)
rna/
mod.rs — Re-exports all submodules (dupradar, featurecounts, rseqc, bam_flags, preseq, qualimap, rng)
mod.rs — Re-exports all submodules (dupradar, featurecounts, rseqc, bam_flags, preseq, qualimap, rng, bigwig)
bam_flags.rs — BAM flag constants
dupradar/
mod.rs — Re-exports counting, dupmatrix, fitting, plots
Expand All @@ -76,6 +78,11 @@ src/
mod.rs — Re-exports output
output.rs — featureCounts-format output & biotype counting
preseq.rs — preseq lc_extrap library complexity extrapolation
bigwig/
mod.rs — Re-exports accumulator, output and writer
accumulator.rs — Streaming bedtools genomecov coverage (memory bounded by read span)
output.rs — Per-track bigWig output (file names, bedtools-style scaling)
writer.rs — bigWig writer following UCSC bedGraphToBigWig (trees, zlib sections, zooms)
rng.rs — MT19937 + libstdc++ binomial port for preseq bootstrap reproducibility
qualimap/
mod.rs — Re-exports all Qualimap modules
Expand Down Expand Up @@ -121,8 +128,9 @@ dupRadar duplicate rate analysis, featureCounts-compatible gene counting,
the RSeQC-equivalent tools (bam_stat, infer_experiment, read_duplication,
read_distribution, junction_annotation, junction_saturation, inner_distance,
TIN, and split_bam when `--split-bam-bed` is given), preseq library complexity extrapolation, samtools-compatible outputs
(flagstat, idxstats, stats), and gene body coverage profiling with
Qualimap-compatible output. The GTF parser extracts transcript-level
(flagstat, idxstats, stats), gene body coverage profiling with
Qualimap-compatible output, and nf-core/rnaseq-compatible bigWig coverage
tracks. The GTF parser extracts transcript-level
structure (exons + CDS features) to derive all data needed by every tool.

Individual tools can be disabled via the YAML config file (each has an `enabled`
Expand Down Expand Up @@ -299,8 +307,19 @@ forwarded to `count_reads()` as the `skip_dup_check: bool` parameter).
chromosomes match alignment reference names, not GTF-mapped names.
- `split_bam` parity fixtures (`tests/data/split_bam_test.*`, `tests/expected/split_bam/`)
are generated by `tests/create_split_bam_test_data.sh` with RSeQC 5.0.4; do not edit by hand.
- Under `rna:`, there are also sections for `preseq:`, `qualimap:`,
- Under `rna:`, there are also sections for `preseq:`, `qualimap:`, `bigwig:`,
`flagstat:`, `idxstats:`, and `samtools_stats:`. Each has an `enabled: bool` toggle.
`bigwig:` mirrors `bedtools genomecov` options: `tracks` (`combined`/`forward`/`reverse`;
unset = combined, plus forward/reverse for stranded libraries, labels swapped for
reverse-stranded ones), `split` (`-split`, default true), `du` (`-du`, default true),
`scale`, `bga`, `read_end` (`5p`/`3p`), `fragment_size` (`-fs`); CLI `--bigwig-*`
and `--skip-bigwig`. The defaults must keep producing nf-core/rnaseq's files.
- The bigWig parity fixtures `tests/expected/bigwig/<bam>.<case>.bedGraph` (and
`tests/data/bigwig_edge.bam`, from `bigwig_edge.sam`) are real bedtools 2.31.1
`genomecov` output, regenerated by `tests/create_bigwig_test_data.sh`; do not edit
by hand. The bigWig writer's zoom levels follow UCSC `bbiWriteZoomLevels` (f32
summaries, first level from the average interval size); keep them that way so
`bigWigSummary` and genome browsers give the same answers as for UCSC's files.
Preseq has additional parameters: `max_extrap`, `step_size`, `n_bootstraps`,
`confidence_level`, `seed`, `max_terms`, `defects`. TIN has `sample_size` and
`min_coverage`.
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Unreleased]

### Features

- Add bigWig genome coverage tracks in the existing BAM streaming pass, matching `bedtools genomecov` + UCSC `bedClip` + `bedGraphToBigWig` ([#112](https://github.com/seqeralabs/RustQC/issues/112), [#114](https://github.com/seqeralabs/RustQC/pull/114))
- By default writes nf-core/rnaseq's files: `{sample}.bigWig` (`-split -bg`), plus `{sample}.forward.bigWig` / `{sample}.reverse.bigWig` (`-split -du -strand +/-`, swapped for reverse-stranded libraries) for stranded libraries
- Options for `-split`, `-du`, `-strand` (track selection), `-scale`, `-bga`, `-5`/`-3` and `-fs`, under `rna.bigwig` in the config and as `--bigwig-*` flags; `--skip-bigwig` turns the tracks off
- Pure-Rust bigWig writer with `bedGraphToBigWig`'s file layout, zoom levels and zoom summaries; no C dependencies

### Other changes

- Migrate BAM/SAM/CRAM I/O from rust-htslib to pure-Rust [noodles](https://crates.io/crates/noodles) (#113)
Expand Down
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ src/
io.rs Shared I/O utilities (gzip-transparent file reading)
gtf.rs GTF annotation file parser
rna/
mod.rs Re-exports all submodules (bam_flags, dupradar, featurecounts,
preseq, qualimap, rng, rseqc)
mod.rs Re-exports all submodules (bam_flags, bigwig, dupradar,
featurecounts, preseq, qualimap, rng, rseqc)
bam_flags.rs BAM flag constants
dupradar/
mod.rs Re-exports counting, dupmatrix, fitting, plots
Expand All @@ -80,6 +80,11 @@ src/
mod.rs Re-exports output
output.rs featureCounts-format output and biotype counting
preseq.rs preseq lc_extrap library complexity extrapolation
bigwig/
mod.rs Re-exports accumulator, output and writer
accumulator.rs bedtools genomecov streaming coverage accumulation
output.rs Per-track bigWig output (file names, scaling)
writer.rs bigWig file writer (bedGraphToBigWig layout and zoom levels)
rng.rs MT19937 + libstdc++ binomial port for preseq bootstrap
qualimap/
mod.rs Re-exports accumulator, coverage, index, output, plots, report
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.2.1"
edition = "2021"
rust-version = "1.89"
authors = ["Phil Ewels <phil.ewels@seqera.io>", "Jon Manning <jonathan.manning@seqera.io>"]
description = "Fast RNA-seq QC in a single pass: dupRadar, featureCounts, 9 RSeQC tools, preseq, samtools stats, and Qualimap — reimplemented in Rust"
description = "Fast RNA-seq QC in a single pass: dupRadar, featureCounts, 9 RSeQC tools, preseq, samtools stats, Qualimap, and bigWig coverage tracks — reimplemented in Rust"
license = "GPL-3.0-or-later"
repository = "https://github.com/seqeralabs/RustQC"
readme = "README.md"
Expand All @@ -21,6 +21,7 @@ path = "src/lib.rs"
name = "rustqc"
path = "src/main.rs"


[dependencies]
# CLI argument parsing
clap = { version = "4", features = ["derive", "env"] }
Expand Down Expand Up @@ -70,6 +71,7 @@ indicatif = "0.18"
number_prefix = "0.4"
serde_json = "1"


[profile.release]
opt-level = 3
lto = true
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/seqeralabs/RustQC/main/docs/public/benchmarks/benchmark_dark.png">
<img src="https://raw.githubusercontent.com/seqeralabs/RustQC/main/docs/public/benchmarks/benchmark_light.png" alt="Benchmark: RustQC ~14m 54s vs traditional tools ~15h 34m sequential (dupRadar + featureCounts + 8 RSeQC tools incl. TIN + preseq + samtools + Qualimap)" width="600">
<img src="https://raw.githubusercontent.com/seqeralabs/RustQC/main/docs/public/benchmarks/benchmark_light.png" alt="Benchmark: RustQC ~14m 54s vs traditional tools ~15h 34m sequential (dupRadar + featureCounts + 8 RSeQC tools incl. TIN + preseq + samtools + Qualimap + bigWig)" width="600">
</picture>
</p>

Expand All @@ -53,11 +53,12 @@ It currently includes:
| split_bam | [RSeQC](https://rseqc.sourceforge.net/#split-bam-py) `split_bam.py` | BED-region (e.g. rRNA) read classification, needs `--split-bam-bed` |
| preseq | [preseq](http://smithlabresearch.org/software/preseq/) `lc_extrap` | Library complexity extrapolation |
| Qualimap rnaseq | [Qualimap](http://qualimap.conesalab.org/) `rnaseq` | Gene body coverage, read origin, strand specificity |
| bigWig | [bedtools](https://github.com/arq5x/bedtools2) `genomecov` + UCSC `bedGraphToBigWig` | Genome coverage tracks; by default the nf-core/rnaseq set |
| flagstat | [samtools](http://www.htslib.org/) `flagstat` | Alignment flag summary |
| idxstats | [samtools](http://www.htslib.org/) `idxstats` | Per-chromosome read counts |
| stats | [samtools](http://www.htslib.org/) `stats` | Full samtools stats output including all histogram sections |

All outputs are format- and numerically identical to the upstream tools, and compatible with [MultiQC](https://multiqc.info/) for reporting.
Most outputs are format- and numerically identical to the upstream tools, and compatible with [MultiQC](https://multiqc.info/) for reporting. bigWig coverage matches [bedtools](https://github.com/arq5x/bedtools2) `genomecov` exactly; the `.bigWig` files have the same layout and zoom levels as UCSC `bedGraphToBigWig` output (see [bigWig docs](https://seqeralabs.github.io/RustQC/rna/bigwig/)).

## Quick start

Expand Down Expand Up @@ -85,7 +86,7 @@ See the [documentation](https://seqeralabs.github.io/RustQC/) for full usage det

## Use as a Rust library

The crate is also published as a library, so the QC analysis modules (GTF parsing, dupRadar, featureCounts, RSeQC, Qualimap, preseq, samtools-style outputs) can be embedded into other Rust programs:
The crate is also published as a library, so the QC analysis modules (GTF parsing, dupRadar, featureCounts, RSeQC, Qualimap, bigWig, preseq, samtools-style outputs) can be embedded into other Rust programs:

```toml
[dependencies]
Expand Down
1 change: 1 addition & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default defineConfig({
{ label: "featureCounts", slug: "rna/featurecounts" },
{ label: "RSeQC", slug: "rna/rseqc" },
{ label: "Qualimap", slug: "rna/qualimap" },
{ label: "bigWig", slug: "rna/bigwig" },
{ label: "Preseq", slug: "rna/preseq" },
{ label: "Samtools", slug: "rna/samtools" },
],
Expand Down
18 changes: 18 additions & 0 deletions docs/src/content/docs/about/credits.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ Qualimap rnaseq report.
- Website: [qualimap.conesalab.org](http://qualimap.conesalab.org/)
- Publication: [doi.org/10.1093/bioinformatics/bts503](https://doi.org/10.1093/bioinformatics/bts503)

## bigWig coverage tracks

RustQC writes genome-wide bigWig coverage tracks that match
[bedtools](https://github.com/arq5x/bedtools2) `genomecov` followed by UCSC
`bedClip` and `bedGraphToBigWig`, with nf-core/rnaseq's settings by default.
See the [bigWig](../rna/bigwig/) page for output files, options, and
validation details.

> Quinlan AR, Hall IM. BEDTools: a flexible suite of utilities for comparing
> genomic features. *Bioinformatics*. 2010;26(6):841-842.

- bedtools: [github.com/arq5x/bedtools2](https://github.com/arq5x/bedtools2)
- Publication: [doi.org/10.1093/bioinformatics/btq033](https://doi.org/10.1093/bioinformatics/btq033)
- bigWig format (UCSC): Kent WJ, Zweig AS, Barber G, Hinrichs AS, Karolchik D.
BigWig and BigBed: enabling browsing of large distributed datasets.
*Bioinformatics*. 2010;26(17):2204-2207.
[doi.org/10.1093/bioinformatics/btq351](https://doi.org/10.1093/bioinformatics/btq351)

## Key dependencies

RustQC is built with the following open-source Rust libraries:
Expand Down
2 changes: 2 additions & 0 deletions docs/src/content/docs/getting-started/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RustQC is a fast quality control toolkit for sequencing data, written in Rust. I
- [preseq](https://github.com/smithlabcode/preseq): library complexity extrapolation (lc_extrap)
- [samtools](http://www.htslib.org/): flagstat, idxstats, and full stats output including all histogram sections
- [Qualimap](http://qualimap.conesalab.org/): gene body coverage profiling and RNA-seq QC summary
- [nf-core/rnaseq](https://nf-co.re/rnaseq) bigWig: genome-wide coverage tracks (`bedtools genomecov` + UCSC utilities)

## Why RustQC?

Expand Down Expand Up @@ -41,6 +42,7 @@ Given a duplicate-marked BAM file and a GTF annotation, `rustqc rna` runs all of
| dupRadar | [dupRadar](https://bioconductor.org/packages/dupRadar/) | RNA-seq PCR duplicate rate analysis |
| featureCounts | [featureCounts](http://subread.sourceforge.net/) | Gene-level read counting and biotypes |
| Qualimap rnaseq | [Qualimap](http://qualimap.conesalab.org/) rnaseq | Gene body coverage and RNA-seq QC |
| bigWig | [nf-core/rnaseq](https://nf-co.re/rnaseq) `bedtools genomecov` | Genome-wide coverage tracks |
| preseq | [preseq](http://smithlabresearch.org/software/preseq/) `lc_extrap` | Library complexity extrapolation |
| flagstat | `samtools flagstat` | Alignment flag statistics |
| idxstats | `samtools idxstats` | Per-chromosome read counts |
Expand Down
5 changes: 3 additions & 2 deletions docs/src/content/docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A basic RustQC analysis from install to results.

## RNA-seq duplicate analysis

Run all RNA-seq QC analyses (dupRadar, featureCounts, RSeQC tools including TIN, Qualimap, preseq, and samtools) in a single pass:
Run all RNA-seq QC analyses (dupRadar, featureCounts, RSeQC tools including TIN, Qualimap, bigWig coverage tracks, preseq, and samtools) in a single pass:

```bash
rustqc rna sample.markdup.bam --gtf genes.gtf -p -o results/
Expand All @@ -27,7 +27,8 @@ This command:

### Output

Output files are organized into subdirectories by tool group.
Output files are organized into subdirectories by tool group
(for example `dupradar/`, `rseqc/`, `qualimap/`, `bigwig/`, `preseq/`, and `samtools/`).
Files are generally named the same as their upstream tool equivalents.
This means that MultiQC should find them and report them as if they were created
by the original tool.
Expand Down
8 changes: 5 additions & 3 deletions docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const base = import.meta.env.BASE_URL;
<a href="https://subread.sourceforge.net/">featureCounts</a>,{" "}
<a href="https://rseqc.sourceforge.net/">RSeQC</a>,{" "}
<a href="http://qualimap.conesalab.org/">Qualimap</a>,{" "}
<a href="https://nf-co.re/rnaseq">nf-core/rnaseq bigWig</a>,{" "}
<a href="https://daehwankimlab.github.io/preseq/">preseq</a>, and{" "}
<a href="https://www.htslib.org/">samtools</a> in Rust, delivering
matching results much faster.
Expand Down Expand Up @@ -163,15 +164,16 @@ export const base = import.meta.env.BASE_URL;
<Card title="Matching Results" icon="approve-check">
Produces identical or near-identical output to R's dupRadar and featureCounts,
plus faithful reimplementations of 9 RSeQC tools (including TIN and split_bam), preseq,
and samtools. See [benchmark details](./rna/benchmark-details/).
samtools, and nf-core/rnaseq-compatible bigWig coverage tracks.
See [benchmark details](./rna/benchmark-details/).
</Card>
<Card title="Dramatically Faster" icon="rocket">
Processes ~186M reads in 14m 54s on AWS vs ~15h 34m of sequential tool
runtimes - including TIN, which takes 9h 45m alone in the traditional
workflow.
</Card>
<Card title="All-in-One" icon="puzzle">
Replaces 14+ separate QC tool invocations with a single CLI command.
Replaces 15+ separate QC tool invocations with a single CLI command.
One task to stage data for. One pass through the BAM file.
Minimal staging and I/O overhead.
</Card>
Expand All @@ -183,5 +185,5 @@ export const base = import.meta.env.BASE_URL;

## Credits

RustQC reimplements established tools including dupRadar, featureCounts, RSeQC, preseq, samtools, and Qualimap.
RustQC reimplements established tools including dupRadar, featureCounts, RSeQC, preseq, samtools, Qualimap, and nf-core/rnaseq bigWig coverage tracks.
See the [Credits & Citations](./about/credits/) page for the full list and how to cite them.
4 changes: 3 additions & 1 deletion docs/src/content/docs/rna/benchmark-details.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ across chromosomes.

Per-tool comparison tables and known differences are on the individual tool pages:
[dupRadar](../dupradar/), [featureCounts](../featurecounts/), [RSeQC](../rseqc/),
[preseq](../preseq/), [Samtools](../samtools/), [Qualimap](../qualimap/).
[preseq](../preseq/), [Samtools](../samtools/), [Qualimap](../qualimap/),
[bigWig](../bigwig/).

## Upstream tool versions

Expand All @@ -59,6 +60,7 @@ RustQC output was validated against these specific versions:
| preseq | 3.2.0 |
| samtools | 1.22.1 |
| Qualimap | 2.3 |
| bedtools | 2.31.1 |

Exact container tags and commands are in the
[RustQC-benchmarks](https://github.com/seqeralabs/RustQC-benchmarks) Nextflow pipeline.
Expand Down
Loading
Loading