skills/gtars/references/coverage.md
Verified against gtars-cli==0.9.0 / gtars-uniwig==0.9.0 on
2026-07-23. The public BEDbase page is partly under construction; tagged CLI
and crate source take precedence where examples differ.
RegionSet.coverage(other) returns a single fraction of base pairs in
the first set covered by the second.gtars uniwig creates positional signal tracks (WIG, NPY, bedGraph, bigWig,
and limited BAM-derived outputs).Python 0.9.2 does not export gtars.uniwig. Old examples using
gtars.uniwig.coverage_from_bed, coverage.normalize(), smooth(),
call_peaks(), or to_bigwig() are not current APIs.
For BED and narrowPeak:
chrom.sizes;The official module guide states that uniwig expects a single chromosome-sorted input. Never concatenate samples, patients, or assemblies without a reviewed aggregation policy.
Run the deterministic preflight:
python3 -B scripts/coverage_preflight.py \
--input fragments.sorted.bed.gz \
--input-type bed \
--chrom-sizes GRCh38.p14.chrom.sizes \
--assembly GRCh38.p14 \
--output-prefix derived/sample01 \
--output-type bw \
--count-type core \
--threads 4
It validates local paths, bounds, sorting, Gtars u32 coordinates, output
collision, and a conservative dense-value budget. It writes and executes
nothing.
BigWig generation uses the root uniwig command directly—there is no generate
subcommand:
gtars uniwig \
--file fragments.sorted.bed.gz \
--filetype bed \
--chromref GRCh38.p14.chrom.sizes \
--smoothsize 5 \
--stepsize 1 \
--fileheader derived/sample01_ \
--outputtype bw \
--counttype core \
--threads 4 \
--zoom 1
Equivalent short options are -f, -t, -c, -m, -s, -l, -y, -u,
-p, and -z. Valid batch count types are:
start: accumulations at interval starts;end: accumulations at interval ends;core: interval-body accumulations;all: produce start, end, and core;shift: BAM-specific shifted workflow.The implementation accepts wig, npy, bedgraph, bw, and bigwig strings
along relevant paths, but use the documented compact bw for BigWig. BED and
narrowPeak can produce WIG, NPY, bedGraph, or BigWig. BAM paths produce BigWig or
BED in the documented workflow.
Other batch flags:
--score uses narrowPeak score;--bamscale FLOAT scales BAM values (default 1.0);--no-bamshift disables direction-aware BAM shifting;--wigstep fixed|variable selects WIG step style;--debug increases output.Validate scientific meaning before using start/end/shift signals. ATAC cut-site shifts and ChIP fragment-body counts are not interchangeable.
For very large BED input, 0.9.0 exposes a streaming processor whose state is bounded by smoothing/gap behavior:
gtars uniwig \
--file fragments.sorted.bed.gz \
--filetype bed \
--chromref GRCh38.p14.chrom.sizes \
--smoothsize 5 \
--stepsize 1 \
--fileheader derived/sample01_ \
--outputtype bedgraph \
--counttype core \
--streaming \
--dense 0
Streaming constraints in tagged source:
wig or bedgraph output, not BigWig or NPY;start, end, core, or all (not BAM shift);--dense 0 is sparse, --dense -1 is fully dense, and positive N fills
gaps no wider than N;--stdout is available; multiple count types receive separator comments.If stdin is used with --counttype all, the handler buffers stdin into memory so
it can replay it. Do not claim constant memory for that combination.
Library-complexity metrics are a subcommand:
gtars uniwig bamqc \
--input aligned.bam \
--output bamqc.tsv \
--threads 1
Parallel BAM QC (--threads >1) requires a .bai index. Bound BAM size, index
size, decompression work, threads, and output. Metrics NRF/PBC1/PBC2 are technical
QC summaries, not evidence of biological quality or suitability.
For BAM-to-bigWig, the batch path requires the same --smoothsize,
--stepsize, --fileheader, --chromref, and output controls. Keep alignment
assembly, filtering, duplicate policy, paired-end handling, and shift/scaling in
the provenance record.
Before generation:
After generation:
UCSC documents bedGraph coordinates as 0-based half-open and numerically ordered. Its BigWig tools require matching chromosome sizes. A successful binary write does not prove the assembly or signal semantics are correct.
Enable only uniwig:
[dependencies]
gtars = { version = "=0.9.0", default-features = false, features = ["uniwig"] }
The wrapper re-exports gtars_uniwig as gtars::uniwig. The primary batch
function is:
uniwig_main(
vec_count_type, smoothsize, filepath, chromsizerefpath, bwfileheader,
output_type, filetype, num_threads, score, stepsize, zoom, debug,
bam_shift, bam_scale, wigstep
) -> Result<(), Box<dyn Error>>
It is deliberately string-heavy and has many arguments; prefer the pinned CLI unless embedding is necessary. The typed streaming API is:
uniwig::stream::uniwig_streaming(
input, output, chrom_sizes, smooth_size, step_size,
CountType::{Start|End|Core},
OutputFormat::{Wig|BedGraph},
max_gap
)
read_chrom_sizes(BufRead) parses the dictionary. BigWig is a batch API, not a
streaming OutputFormat.
--threads; the CLI default is 6.--threads path.