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:
- 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
Useful in workflows including single-cell and Micro-Capture-C (MCC), and many others.
Documentation: API docs on docs.rs
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)
- bedGraph post-processing with
collapse-bedgraph - 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 API
BamNado provides Python bindings for high-performance BAM signal generation with flexible read filtering. Install from PyPI:
# or
Quick start
# Generate coverage from a BAM file
=
ReadFilter class
Customize read filtering with the ReadFilter class. All parameters are optional:
# Create a filter for high-quality, properly-paired reads
=
# Apply the filter
=
Filter parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
min_mapq |
int |
0 |
Minimum mapping quality |
proper_pair |
bool |
False |
Require properly paired reads |
min_length |
int |
0 |
Minimum read length (bp) |
max_length |
int |
1000 |
Maximum read length (bp) |
strand |
str |
"both" |
"forward", "reverse", or "both" |
min_fragment_length |
int | None |
None |
Minimum insert size (bp); paired-end only |
max_fragment_length |
int | None |
None |
Maximum insert size (bp); paired-end only |
blacklist_bed |
str | None |
None |
BED file of excluded regions |
whitelisted_barcodes |
list[str] | None |
None |
Cell barcodes to include (CB tag) |
read_group |
str | None |
None |
Read group to keep (RG tag) |
filter_tag |
str | None |
None |
SAM tag to filter on (e.g. "VP") |
filter_tag_value |
str | None |
None |
Required value for filter_tag |
Usage examples
Basic coverage
=
Nucleosome-free regions (ATAC-seq)
# Forward-strand reads, 100–200 bp fragments
=
=
Barcode-filtered coverage (single-cell)
# Get coverage for specific cell barcodes
=
=
=
Tag-filtered coverage (e.g. MCC viewpoint)
# Get coverage for specific viewpoint
=
=
High-confidence coverage
# High-quality, properly-paired reads
=
=
get_signal_for_chromosome parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
bam_path |
str |
— | Path to indexed BAM file |
chromosome_name |
str |
— | Chromosome to process (e.g. "chr1") |
bin_size |
int |
50 |
Bin width in base pairs |
scale_factor |
float |
1.0 |
Linear scaling factor |
use_fragment |
bool |
False |
Use fragment (pair) coordinates instead of read |
ignore_scaffold_chromosomes |
bool |
True |
Skip non-standard chromosomes |
read_filter |
ReadFilter | None |
None |
Optional read filter |
Returns: numpy.ndarray of dtype float32 with length = chromosome size / bin_size
Note: Fragment length filtering (min_fragment_length, max_fragment_length) requires paired-end BAM files and will raise ValueError on single-end data.
Command-line interface
Getting help
Available commands
- Coverage generation:
bam-coverage(coverage),multi-bam-coverage(multi-coverage) - BAM manipulation:
split,split-exogenous,modify - BigWig tools:
bigwig-compare(compare-bigwigs),bigwig-aggregate(aggregate-bigwigs) - bedGraph tools:
collapse-bedgraph(collapse)
Common naming cleanups
The CLI now exposes shorter, more descriptive option names. Older names still work as compatibility aliases.
Read filtering
All coverage commands share common read filter flags:
| Flag | Default | Description |
|---|---|---|
--strand |
both |
forward, reverse, or both |
--proper-pairs |
off | Keep only properly-paired reads |
--min-mapq |
20 | Minimum mapping quality |
--min-length |
20 | Minimum read length (bp) |
--max-length |
1000 | Maximum read length (bp) |
--min-fragment-len |
— | Minimum insert size (bp); paired-end only |
--max-fragment-len |
— | Maximum insert size (bp); paired-end only |
--blacklist |
— | BED file of regions to exclude |
--barcode-allowlist |
— | Text file of cell barcodes (one per line) |
--read-group |
— | Keep only this read group |
--tag / --tag-value |
— | Keep reads where TAG == VALUE |
Coverage-specific flags
| Flag | Default | Description |
|---|---|---|
--normalize |
raw |
Signal normalization method: raw, rpkm, or cpm |
--fragment-counts |
off | Count fragments instead of individual read alignments |
--ignore-scaffolds |
off | Skip scaffold or unplaced chromosomes |
--threads |
6 |
Threads used when writing BigWig output |
Examples
Generate basic coverage
Generate high-quality, normalized coverage
Extract nucleosome-free regions from ATAC-seq
Filter by cell barcode (single-cell)
Filter by SAM tag (MCC viewpoint)
Compare two BigWig files
Aggregate multiple BigWig files
Simplify bedGraph file
Development
License
Apache-2.0 OR MIT