BamNado
High-performance tools and utilities for working with BAM and BigWig files in modern genomics workflows. BamNado is written in Rust for speed and low memory use and provides both a command-line interface and Python bindings.
Overview
BamNado is designed for efficient, streaming manipulation of BAM files and signal tracks. It focuses on fast coverage generation, flexible filtering, and lightweight post-processing of bedGraph and BigWig data.
Common use cases include:
- Rapid generation of coverage tracks from large BAM files
- Filtering reads by tags or barcodes to produce targeted BigWigs
- Fragment-aware coverage for ATAC-seq and related assays
- BigWig comparison and aggregation across samples
- Post-processing of binned signal tracks for visualization
BamNado is useful in a range of workflows, including single-cell and Micro-Capture-C (MCC), but is not limited to those applications.
Features
- High-performance, streaming implementations in Rust
- Cross-platform support (Linux, macOS, Windows)
- BAM → bedGraph / BigWig coverage generation
- Fragment-aware and strand-specific pileups
- Read filtering by mapping quality, length, strand, fragment size, tags, and barcodes
- BigWig comparison (subtraction, ratio, log-ratio)
- BigWig aggregation (sum, mean, median, min, max)
collapse-bedgraphutility to merge adjacent bins with identical scores- Python bindings for selected functionality
Installation
Pre-built binaries (recommended)
Download the appropriate binary from the releases page.
After downloading:
(Optional) install system-wide:
Docker
Images are available for linux/amd64 and linux/arm64.
Cargo
If you have Rust installed:
Build from source
Optional dependency: samtools
samtools is not required but is strongly recommended if your BAM files have non-standard or incomplete headers (e.g. files produced by CellRanger). BamNado automatically falls back to samtools view -H to parse the header when the built-in parser fails. Without samtools on your PATH, BamNado will error on such files.
Install via conda or your system package manager:
# or
Python Interface
BamNado provides Python bindings for selected high-performance operations and is available directly from PyPI.
Python Installation
# or
ReadFilter
All read filtering options are controlled through the ReadFilter class:
| Parameter | Type | Default | Description |
|---|---|---|---|
min_mapq |
int |
0 |
Minimum mapping quality score |
proper_pair |
bool |
True |
Keep only properly paired reads |
min_length |
int |
0 |
Minimum read length (bp) |
max_length |
int |
1000 |
Maximum read length (bp) |
strand |
str |
"both" |
Strand to keep: "forward" / "fwd" / "+", "reverse" / "rev" / "-", or "both" |
min_fragment_length |
int | None |
None |
Minimum insert size / TLEN (bp); requires paired-end data |
max_fragment_length |
int | None |
None |
Maximum insert size / TLEN (bp); requires paired-end data |
blacklist_bed |
str | None |
None |
Path to a BED file of regions to exclude |
whitelisted_barcodes |
list[str] | None |
None |
Cell barcodes (CB tag) to include |
read_group |
str | None |
None |
Read group (RG tag) to keep |
filter_tag |
str | None |
None |
Two-character SAM tag to filter on (e.g. "VP") |
filter_tag_value |
str | None |
None |
Required string value for filter_tag |
A ValueError is raised if min_fragment_length or max_fragment_length is set on a single-end BAM file.
Example
# Basic coverage — default filter settings
=
# Forward-strand nucleosome-free region coverage (100–200 bp fragments)
=
=
# Tag-filtered coverage (e.g. MCC viewpoint)
=
=
Command-line usage
List available commands:
Get help for a specific command:
Available commands
bam-coverage– generate coverage from a BAM filemulti-bam-coverage– coverage from multiple BAMssplit– split BAMs based on filters (e.g. barcodes)split-exogenous– split endogenous vs exogenous readsmodify– apply transformations and filters to BAMsbigwig-compare– compare two BigWigsbigwig-aggregate– aggregate multiple BigWigscollapse-bedgraph– merge adjacent bedGraph bins with identical scores
Read filtering
All coverage commands share a common set of read filter flags:
| Flag | Default | Description |
|---|---|---|
--strand |
both |
Include only forward, reverse, or both strands |
--proper-pair |
off | Keep only properly-paired reads |
--min-mapq |
20 | Minimum mapping quality |
--min-length |
20 | Minimum read sequence length (bp) |
--max-length |
1000 | Maximum read sequence length (bp) |
--min-fragment-length |
— | Minimum insert size / TLEN (bp); requires paired-end data |
--max-fragment-length |
— | Maximum insert size / TLEN (bp); requires paired-end data |
--blacklisted-locations |
— | BED file of regions to exclude |
--whitelisted-barcodes |
— | Text file of cell barcodes to keep (one per line) |
--read-group |
— | Keep only reads belonging to this read group |
--filter-tag / --filter-tag-value |
— | Keep reads where SAM tag equals the given value |
Fragment length filtering operates on the SAM TLEN field and is only meaningful for paired-end BAMs. BamNado will return an error if these flags are used with a single-end file.
Example: BAM coverage
Example: strand- and fragment-length-filtered coverage
Useful for isolating nucleosome-free regions in ATAC-seq data:
Example: tag-filtered BigWig generation
BigWig comparison
BigWig aggregation
collapse-bedgraph
Development
License
Apache-2.0 OR MIT