fastbamqc 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to fastbamqc are documented in this file.
4
+ The format follows Keep a Changelog and the project uses Semantic Versioning.
5
+
6
+ ## [1.0.1] - 2026-10-27
7
+
8
+ ### Fixed
9
+ - Syntax error in `pyproject.toml` (unclosed quote) that prevent building the package in 1.0.0.
10
+ ## [1.0.0] - 2026-10-27
11
+
12
+ First public release.
13
+
14
+ ### Features
15
+ - Whole-genome mode: one row per sample (total_read, mapped_read, percentage_mapped,
16
+ mean_coverage, <d>X = % of positions covered at ≥ d reads).
17
+ - Amplicon / panel mode (--bed): one row per target and per sample, with --same-gene {merge,separate}.
18
+ - Exact per-position depth computed over independent windows (start/end difference array).
19
+ - Interpretability verdict on by default (75 % of the region at ≥ 10X); --interp-depth,
20
+ --interp-pct, --no-interp, and --interp-nodup (rule evaluated without duplicates, whole genome only).
21
+ - Self-contained HTML report (--report) with live sliders for the interpretability rule and,
22
+ for whole genomes, a duplicates section.
23
+ - Optional extra metrics: --uniformity and --read-stats (read-level QC, flagged and estimated duplicates).
24
+ - Multi-core processing: -c (total cores) and -t (cores per BAM); a single BAM is split into windows
25
+ shared between processes, with results identical whatever the number of cores.
26
+ - Output formats: TSV and CSV.
27
+
28
+ ### Notes
29
+ - Versions before 1.0.0 were internal development versions and are not documented here.
@@ -0,0 +1,41 @@
1
+ # This file tells GitHub / Zenodo / Zotero how to cite fastbamqc.
2
+ # Replace every TODO value, then check it with: pip install cffconvert && cffconvert --validate
3
+ cff-version: 1.2.0
4
+ message: "If you use fastbamqc, please cite it as below."
5
+ type: software
6
+ title: "fastbamqc: fast depth and interpretability QC for BAM files"
7
+ abstract: >-
8
+ fastbamqc computes mapping and depth metrics (percentage mapped, mean depth, percentage of positions covered at
9
+ least X-fold) and an interpretability verdict for sorted, indexed BAM files, for whole genomes and for
10
+ amplicon / panel data, with an optional self-contained HTML report.
11
+ version: 1.0.1
12
+ date-released: 2026-10-27
13
+ license: MIT
14
+ repository-code: "https://github.com/lvuillermet/fastbamqc"
15
+ url: "https://github.com/lvuillermet/fastbamqc"
16
+ doi: 10.5281/zenodo.23693362
17
+ keywords:
18
+ - BAM
19
+ - coverage
20
+ - depth
21
+ - quality control
22
+ - amplicon
23
+ - genomics
24
+ authors:
25
+ - family-names: "Vuillermet"
26
+ given-names: "Loïc"
27
+ email: "loic.vuillermet@univ-rouen.fr"
28
+ affiliation: "Université de Rouen Normandie, Laboratoire de parasitologie-mycologie, UR7510"
29
+ - family-names: "Cosson"
30
+ given-names: "Anna"
31
+ affiliation: "Université Paris Cité, IRD, Inserm, MERIT"
32
+ - family-names: "Coppée"
33
+ given-names: "Romain"
34
+ affiliation: "Université de Rouen Normandie, Laboratoire de parasitologie-mycologie, UR7510"
35
+ # preferred-citation:
36
+ # type: article
37
+ # title: "..."
38
+ # authors: [...]
39
+ # journal: "Bioinformatics"
40
+ # year: 2026
41
+ # doi: "10.1093/bioinformatics/..."
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fastbamqc Laboratoire ESCAPE, Université Rouen Normandie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include LICENSE README.md CHANGELOG.md CITATION.cff
2
+ recursive-include src/fastbamqc/templates *.html
@@ -0,0 +1,496 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastbamqc
3
+ Version: 1.0.1
4
+ Summary: Fast mapping and depth QC metrics for sorted, indexed BAM files (whole genome or amplicon/panel)
5
+ Author-email: Loic Vuillermet <loic.vuillermet@univ-rouen.fr>, Anna Cosson <anna.cosson@u-paris.fr>, Romain Coppee <romain.coppee@univ-rouen.fr>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/lvuillermet/fastbamqc
8
+ Project-URL: Issues, https://github.com/lvuillermet/fastbamqc/issues
9
+ Project-URL: Changelog, https://github.com/lvuillermet/fastbamqc/blob/main/CHANGELOG.md
10
+ Keywords: bam,coverage,depth,quality control,amplicon,genomics
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: pysam>=0.21
21
+ Requires-Dist: numpy>=1.21
22
+ Dynamic: license-file
23
+
24
+ <h1 align="center">fastbamqc</h1>
25
+
26
+ <p align="center">
27
+ <b>Fast mapping and depth QC for sorted, indexed BAM files</b><br>
28
+ Whole genome or amplicon / panel &nbsp;·&nbsp; interpretability verdict &nbsp;·&nbsp; self-contained HTML report
29
+ </p>
30
+
31
+ <p align="center">
32
+ <code>v1.0.0</code> &nbsp;·&nbsp; Python ≥ 3.9 &nbsp;·&nbsp; Linux / macOS (Windows through WSL)
33
+ </p>
34
+
35
+ ---
36
+
37
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.23693362.svg)](https://doi.org/10.5281/zenodo.23693362)
38
+
39
+ ## Contents
40
+
41
+ 1. [What it does](#what-it-does)
42
+ 2. [Installation](#installation)
43
+ 3. [Quick start](#quick-start)
44
+ 4. [How it works](#how-it-works)
45
+ 5. [Command-line reference](#command-line-reference)
46
+ 6. [Examples](#examples)
47
+ 7. [Output files and columns](#output-files-and-columns)
48
+ 8. [Interpretability verdict](#interpretability-verdict)
49
+ 9. [HTML report](#html-report)
50
+ 10. [Extra metrics](#extra-metrics)
51
+ 11. [Using several CPU cores](#using-several-cpu-cores)
52
+ 12. [Definitions and known limits](#definitions-and-known-limits)
53
+ 13. [Performance](#performance)
54
+ 14. [Troubleshooting](#troubleshooting)
55
+ 15. [Citation and licence](#citation-and-licence)
56
+
57
+ ---
58
+
59
+ ## What it does
60
+
61
+ For every BAM file of a directory, fastbamqc reports in one table:
62
+
63
+ | Metric | Meaning |
64
+ |---|---|
65
+ | `total_read`, `mapped_read`, `percentage_mapped` | read counts, taken from the BAM index |
66
+ | `mean_coverage` | mean depth over the genome (or over each target) |
67
+ | `1X`, `5X`, `10X`, … | % of positions covered by at least *d* reads (you choose the thresholds) |
68
+ | `interpretability` | `INTERPRETABLE` / `NON_INTERPRETABLE` according to a rule you can change |
69
+
70
+ Two modes:
71
+
72
+ - **Whole genome** (default): one row per sample, over every contig of the BAM header.
73
+ - **Amplicon / panel** (`--bed`): one row per target (gene) and per sample.
74
+
75
+ Optionally it also writes a **single HTML file** (works offline, can be e-mailed) with overview charts, one page per sample,
76
+ live sliders to change the interpretability rule, and, for whole genomes, a duplicates section.
77
+
78
+ It was designed as a fast, lightweight alternative to Qualimap for routine QC of many samples. It does not replace a
79
+ full-featured QC suite (insert size, GC bias, base-quality plots, …): it focuses on depth and breadth of coverage.
80
+
81
+ ---
82
+
83
+ ## Installation
84
+
85
+ fastbamqc needs **Python ≥ 3.9** and two libraries, installed automatically: [`pysam`](https://pysam.readthedocs.io) and
86
+ [`numpy`](https://numpy.org). `samtools` is **not** required to run it (only to sort and index your BAM files).
87
+
88
+ > **Windows:** `pysam` does not run on native Windows. Install WSL (Ubuntu) and follow the Linux instructions inside it.
89
+
90
+ ### Option A: from the repository, in a Python virtual environment (`venv`)
91
+
92
+ Works on any machine with Python 3.9+ and `git` (check with `python3 --version`).
93
+
94
+ ```bash
95
+ # 1. get the code
96
+ git clone https://github.com/lvuillermet/fastbamqc.git
97
+ cd fastbamqc
98
+
99
+ # 2. create and activate a virtual environment
100
+ python3 -m venv .venv
101
+ source .venv/bin/activate # Linux / macOS / WSL
102
+
103
+ # 3. install
104
+ pip install --upgrade pip
105
+ pip install .
106
+
107
+ # 4. check
108
+ fastbamqc --version
109
+ ```
110
+
111
+ No `git`? Download the repository as a zip archive from GitHub (green **Code** button → **Download ZIP**), unzip it,
112
+ `cd` into the folder and continue at step 2.
113
+
114
+ Next time, only `source .venv/bin/activate` is needed before using `fastbamqc`.
115
+ To update: `git pull`, then `pip install .` again.
116
+ For development, use `pip install -e .`: code changes are then picked up immediately.
117
+
118
+ > On Debian / Ubuntu, if `python3 -m venv` fails, install the module first: `sudo apt install python3-venv`.
119
+
120
+ ### Option B: from the repository, in a conda / mamba / micromamba environment
121
+
122
+ ```bash
123
+ git clone https://github.com/lvuillermet/fastbamqc.git
124
+ cd fastbamqc
125
+
126
+ micromamba create -n fastbamqc -c conda-forge -c bioconda python=3.11 pysam numpy samtools
127
+ micromamba activate fastbamqc
128
+ pip install .
129
+
130
+ fastbamqc --version
131
+ ```
132
+
133
+ (`conda` or `mamba` work the same way in place of `micromamba`.) `samtools` is only there to sort and index BAM files.
134
+
135
+ ### Option C: PyPI and Bioconda (coming soon)
136
+
137
+ Once the package is published, these one-line installations will be available:
138
+
139
+ ```bash
140
+ pip install fastbamqc # PyPI
141
+ conda install -c conda-forge -c bioconda fastbamqc # Bioconda
142
+ ```
143
+
144
+ Until then, use options A or B.
145
+
146
+ ---
147
+
148
+ ## Quick start
149
+
150
+ BAM files must be **coordinate-sorted and indexed** (`samtools sort` then `samtools index`, so that each `x.bam` has an `x.bam.bai`).
151
+
152
+ ```bash
153
+ # whole genome, tables only
154
+ fastbamqc -i ./bams -o ./results
155
+
156
+ # whole genome, with the HTML report
157
+ fastbamqc -i ./bams -o ./results --report
158
+
159
+ # amplicon / panel
160
+ fastbamqc -i ./bams -o ./results --bed amplicons.bed --report
161
+ ```
162
+
163
+ Results are written to `./results` (`fastbamqc_summary.tsv`, and `fastbamqc_summary.html` with `--report`).
164
+
165
+ ---
166
+
167
+ ## How it works
168
+
169
+ ```mermaid
170
+ flowchart LR
171
+ A[BAM + index] --> B[Read counts<br/>from the index]
172
+ A --> C[Windows over the contigs<br/>or over the BED targets]
173
+ C --> D[Depth per position<br/>start/end difference array]
174
+ D --> E[Mean depth<br/>% positions ≥ X]
175
+ E --> F[Interpretability verdict]
176
+ F --> G[TSV / CSV]
177
+ F --> H[HTML report]
178
+ ```
179
+
180
+ 1. **Read counts.** `total_read`, `mapped_read` and `percentage_mapped` come from the BAM index (`idxstats`), without reading the file.
181
+ 2. **Depth.** Reads are scanned window by window. For each window, every read adds +1 at its start and −1 after its end
182
+ in an array; a cumulative sum gives the exact depth of **every position**. Mean depth and the % of positions at
183
+ ≥ *d* reads are then exact, not sampled or approximated.
184
+ 3. **Independent windows.** Each read is counted in one window only, so windows can be processed in any order and
185
+ by different processes; the totals are exactly identical whatever the number of cores.
186
+ 4. **Amplicon mode.** Only the BED targets are read. Targets sharing a gene name are merged by default (`--same-gene`).
187
+ 5. **Interpretability.** A row is `INTERPRETABLE` when at least *P* % of its region is covered at ≥ *D* X (default **75 % at 10X**).
188
+ 6. **Duplicates (whole genome, with `--read-stats` or `--report`).** Duplicates are the reads flagged 0x400 in the
189
+ BAM **and** the reads estimated from the alignments (same start, end, strand, mate position and template length as
190
+ an earlier read). The estimate is conservative compared with `samtools markdup` (see [limits](#definitions-and-known-limits)).
191
+
192
+ Values are rounded to 2 decimals in the tables.
193
+
194
+ ---
195
+
196
+ ## Command-line reference
197
+
198
+ ```
199
+ fastbamqc -i DIRECTORY [-f PATTERN] [-b FILE.bed] [options]
200
+ ```
201
+
202
+ ### Required
203
+
204
+ | Option | Description |
205
+ |---|---|
206
+ | `-i`, `--input-dir DIRECTORY` | Directory containing the BAM files. **The only mandatory option.** |
207
+
208
+ ### Input
209
+
210
+ | Option | Default | Description |
211
+ |---|---|---|
212
+ | `-f`, `--pattern PATTERN` | `*.bam` | Pattern of the files to analyse, e.g. `"*_sorted.bam"`. Always quote it. Sample names are the file names without the fixed part of the pattern. |
213
+ | `-b`, `--bed FILE.bed` | none | Enables **amplicon / panel mode**. BED columns: 1 chrom, 2 start (0-based), 3 end, 4 gene name. Without a 4th column, targets are named `chrom:start-end`. Contig names must match the BAM. |
214
+ | `--same-gene {merge,separate}` | `merge` | With `--bed`, how to handle several BED lines sharing a gene name: `merge` groups them into one target with merged regions, `separate` treats each line as an independent target. |
215
+ | `--contigs LIST` | all | Whole genome only: restrict to comma-separated contigs, e.g. `chr1,chr2,chrX`. Not compatible with `--bed`. Useful to leave out decoy / alt contigs. |
216
+
217
+ ### Output
218
+
219
+ | Option | Default | Description |
220
+ |---|---|---|
221
+ | `-o`, `--out-dir DIRECTORY` | current directory | Output directory (created if needed). |
222
+ | `-n`, `--out-name NAME` | `fastbamqc_summary` | Name of the main output file, without extension. |
223
+ | `-F`, `--out-format {tsv,csv}` | `tsv` | Table format (tab- or comma-separated). |
224
+ | `--report` | off | Also write a self-contained HTML report `<out-dir>/<out-name>.html`. |
225
+ | `--report-title TEXT` | `fastbamqc report` | Title shown in the report. |
226
+ | `--log-file FILE` | none | Also write the progress messages to a file. |
227
+
228
+ ### Depth and filters
229
+
230
+ | Option | Default | Description |
231
+ |---|---|---|
232
+ | `-d`, `--depths LIST` | `1,5,10` | Depth thresholds. One `<d>X` column per threshold. |
233
+ | `-q`, `--min-mapq MAPQ` | `0` | Minimum mapping quality for a read to count in the depth. |
234
+ | `--exclude-flags FLAGS` | `0` | SAM flags excluded from the depth (decimal or `0x…`). Unmapped reads are always excluded. `1024` = duplicates, `3584` = duplicates + secondary + supplementary. **Do not exclude duplicates on amplicon data.** |
235
+
236
+ ### Interpretability
237
+
238
+ | Option | Default | Description |
239
+ |---|---|---|
240
+ | `--interp-depth DEPTH` | `10` | Depth (X) a position must reach to count as covered. Added to the `<d>X` columns if missing. |
241
+ | `--interp-pct PERCENT` | `75` | Minimum % of the region that must reach that depth. |
242
+ | `--interp-nodup` | off | Whole genome only. Evaluate the rule on the depth **without duplicates** (flagged or estimated). Adds `<d>X_nodup` columns. About +50–60 % run time. Recommended for libraries with many duplicates (WGA, low input). |
243
+ | `--no-interp` | off | No interpretability column and no sliders in the report. |
244
+
245
+ ### Extra metrics
246
+
247
+ | Option | Description |
248
+ |---|---|
249
+ | `--read-stats` | Whole genome only. Read-level QC and duplicates (see [Extra metrics](#extra-metrics)). Turned on automatically by `--report` in whole-genome mode. |
250
+ | `--uniformity` | Depth-evenness columns (median, CV, fold-80, …), per sample or per target. |
251
+
252
+ ### Performance
253
+
254
+ | Option | Default | Description |
255
+ |---|---|---|
256
+ | `-c`, `--max-cores N` | `4` | **Total** number of CPU cores to use. |
257
+ | `-t`, `--threads-per-bam N` | automatic | Cores used by **each** BAM. Automatic: the cores are shared between the files (1 file → all cores). See [Using several CPU cores](#using-several-cpu-cores). |
258
+
259
+ ### Other
260
+
261
+ | Option | Description |
262
+ |---|---|
263
+ | `-V`, `--version` | Show the version and exit. |
264
+ | `-h`, `--help` | Show the help and exit. |
265
+
266
+ ---
267
+
268
+ ## Examples
269
+
270
+ **Whole genome, defaults** (10X / 75 % verdict):
271
+ ```bash
272
+ fastbamqc -i ./bams -o ./results
273
+ ```
274
+
275
+ **Whole genome with report, 8 cores, project title:**
276
+ ```bash
277
+ fastbamqc -i ./bams -o ./results -n run42 --report --report-title "Run 42" -c 8
278
+ ```
279
+
280
+ **Library with many duplicates (WGA): judge the samples without duplicates:**
281
+ ```bash
282
+ fastbamqc -i ./bams -o ./results --report --interp-nodup -c 8
283
+ ```
284
+
285
+ **Stricter rule: 90 % of the genome at ≥ 20X, extra thresholds:**
286
+ ```bash
287
+ fastbamqc -i ./bams -o ./results -d 1,5,10,20,30 --interp-depth 20 --interp-pct 90
288
+ ```
289
+
290
+ **Only some contigs, CSV output, pattern on file names:**
291
+ ```bash
292
+ fastbamqc -i ./bams -f "*_sorted.bam" -o ./results -F csv --contigs chr1,chr2,chr3
293
+ ```
294
+
295
+ **Only well-mapped reads count (MAPQ ≥ 20):**
296
+ ```bash
297
+ fastbamqc -i ./bams -o ./results -q 20
298
+ ```
299
+
300
+ **Amplicon / panel:**
301
+ ```bash
302
+ fastbamqc -i ./bams -o ./results --bed amplicons.bed -d 1,10,100,500 --report
303
+ ```
304
+
305
+ **Amplicon with a different rule, or no verdict at all:**
306
+ ```bash
307
+ fastbamqc -i ./bams -o ./results --bed amplicons.bed --interp-depth 30 --interp-pct 90
308
+ fastbamqc -i ./bams -o ./results --bed amplicons.bed --no-interp
309
+ ```
310
+
311
+ **Many files on a big machine, 2 cores per BAM (so 8 files at a time on 16 cores):**
312
+ ```bash
313
+ fastbamqc -i ./bams -o ./results -c 16 -t 2
314
+ ```
315
+
316
+ **Uniformity metrics and read statistics (tables only):**
317
+ ```bash
318
+ fastbamqc -i ./bams -o ./results --uniformity --read-stats
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Output files and columns
324
+
325
+ **Whole genome**: one table `<out-dir>/<out-name>.<fmt>`, one row per sample.
326
+
327
+ | Column | Meaning |
328
+ |---|---|
329
+ | `sample` | sample name |
330
+ | `total_read`, `mapped_read`, `percentage_mapped` | from the BAM index |
331
+ | `mean_coverage` | mean depth over the analysed contigs |
332
+ | `<d>X` | % of positions with depth ≥ d |
333
+ | `interpretability` | verdict (unless `--no-interp`) |
334
+
335
+ **Amplicon / panel** (`--bed`): one row per target and per sample.
336
+
337
+ - `<out-dir>/<out-name>.<fmt>`: all rows of all samples.
338
+ - `<out-dir>/per_sample/<sample>.amplicons.<fmt>`: one file per sample.
339
+
340
+ | Column | Meaning |
341
+ |---|---|
342
+ | `sample`, `gene` | sample and target names |
343
+ | `chrom`, `start`, `end` | extent of the target |
344
+ | `length`, `n_regions` | bases actually targeted, number of merged regions |
345
+ | `reads`, `percentage_of_mapped` | reads on the target, and as % of the mapped reads |
346
+ | `mean_coverage`, `<d>X`, `interpretability` | as above |
347
+
348
+ With `--report`: a single HTML file `<out-dir>/<out-name>.html`.
349
+
350
+ ---
351
+
352
+ ## Interpretability verdict
353
+
354
+ A row (a sample in whole-genome mode, a gene in amplicon mode) is **`INTERPRETABLE`** when at least `--interp-pct` percent
355
+ of its region is covered by at least `--interp-depth` reads, and `NON_INTERPRETABLE` otherwise. Defaults: **75 % at 10X**.
356
+
357
+ - The comparison is `≥` on the 2-decimal value shown in the table (exactly 75.00 is `INTERPRETABLE`).
358
+ - `--interp-depth` and `--interp-pct` are independent: the one you omit keeps its default.
359
+ - The depth is added to the `<d>X` columns if it is not in `--depths`, so the verdict can always be re-checked from the table.
360
+ - In whole-genome mode the region is the set of analysed contigs: use `--contigs` to leave out decoys.
361
+ - **`--interp-nodup`** uses the coverage *without duplicates*. With whole-genome amplification (WGA) or low-input
362
+ libraries, duplicates can be the majority of the reads; the raw depth then overstates the usable depth.
363
+ The two rules can give different verdicts: choose before looking at the results, and report which one you used.
364
+
365
+ ---
366
+
367
+ ## HTML report
368
+
369
+ `--report` writes one self-contained HTML file: no internet connection and no external file are needed.
370
+
371
+ - **Overview**: summary cards, comparison charts of all samples, full sortable and filterable table (CSV download).
372
+ - whole genome: mean coverage per sample (coloured by verdict), % mapped, breadth of coverage, coverage curves, **Duplicates** section;
373
+ - amplicon: targets × samples heatmap, interpretable targets per sample, coverage and interpretability rate per target.
374
+ - **Sample details**: choose a sample in the menu. Whole genome: metrics, duplicates and read breakdown, depth distribution,
375
+ coverage curve, mean depth per contig. Amplicon: table of the targets, depth profile along each target, gallery of all targets.
376
+ - **Live sliders** (depth X and minimum % covered) re-evaluate every verdict, chart, table and the CSV download. The
377
+ percentage covered at the slider depth is computed exactly by fastbamqc (52 depths plus your `--depths`), so the sliders
378
+ give the same verdicts as a new run with the same thresholds.
379
+ - A link such as `report.html#sample=S1` opens directly on a sample.
380
+ - The Duplicates section exists in whole-genome mode only (duplicates are expected in amplicon data).
381
+
382
+ ---
383
+
384
+ ## Extra metrics
385
+
386
+ Both options are off by default; without them the output and the speed are unchanged.
387
+
388
+ ### `--uniformity` (whole genome and amplicon)
389
+
390
+ | Column | Meaning |
391
+ |---|---|
392
+ | `median_coverage` | median depth |
393
+ | `cv_coverage` | standard deviation / mean (0 = perfectly even) |
394
+ | `pct_above_0.2_mean` | % of positions with depth ≥ 0.2 × mean |
395
+ | `fold_80` | mean depth / depth reached by 80 % of the positions (1 = even) |
396
+
397
+ Exact per target in amplicon mode. In whole-genome mode they come from a depth histogram capped at 1000X; a value
398
+ needing the capped tail is reported as `NA`.
399
+
400
+ ### `--read-stats` (whole genome only)
401
+
402
+ | Column | Meaning |
403
+ |---|---|
404
+ | `primary_mapped_reads` | primary mapped reads (denominator of the percentages) |
405
+ | `pct_properly_paired`, `pct_mapq0` | % of primary mapped reads |
406
+ | `secondary_reads`, `supplementary_reads`, `qcfail_reads` | counts |
407
+ | `marked_dup_reads`, `pct_marked_dup` | reads flagged 0x400 in the BAM |
408
+ | `est_dup_reads`, `pct_est_dup` | duplicates **estimated from the alignments** |
409
+ | `mean_coverage_nodup` | mean depth without duplicates (flagged or estimated) |
410
+
411
+ These counters ignore `--min-mapq` and `--exclude-flags` (only `mean_coverage_nodup` follows them).
412
+
413
+ ---
414
+
415
+ ## Using several CPU cores
416
+
417
+ - `-c N` is the **total** number of cores (default 4).
418
+ - In whole-genome mode a BAM is cut into independent windows shared between processes, so **a single big file also uses
419
+ several cores**. The results are exactly identical whatever the number of cores.
420
+ - By default (`-t` not given) the cores are shared between the files: 1 file → all cores, 3 files on 4 cores → 3 files at the same time.
421
+ - `-t N` fixes the number of cores per file; files processed in parallel = `-c // -t`.
422
+ - In amplicon mode `-t` is the number of BAM decompression threads per file.
423
+ - **Memory** grows with the number of processes (roughly 100–250 MiB each in our tests).
424
+
425
+ Rule of thumb: just set `-c` to the number of cores you can use, and leave `-t` alone.
426
+
427
+ ---
428
+
429
+ ## Definitions and known limits
430
+
431
+ **What is counted in the depth** (same convention as `mosdepth --fast-mode` and `samtools depth -J`):
432
+
433
+ - only unmapped reads are excluded by default (duplicates, secondary reads and low MAPQ are kept unless you filter them);
434
+ - a **deletion counts as covered**;
435
+ - overlapping mates are **counted twice**;
436
+ - the denominator is the whole length of the analysed contigs (or of the BED targets).
437
+
438
+ Other tools use other conventions: `samtools coverage` does not count deletions as covered (about 0.25X lower on our
439
+ ~75X *P. falciparum* data), and Picard counts overlapping mates once. Differences between tools may come from
440
+ these definitions rather than from errors.
441
+
442
+ **Duplicate estimate.** Without a prior `MarkDuplicates`, the 0x400 flag is absent, so duplicates are estimated:
443
+ reads with the same start, end, strand, mate start and template length. This is an **estimate**:
444
+
445
+ - it is conservative compared with `samtools markdup` (on one *Cyclospora* WGA sample: 87.95 % estimated vs 92.31 % with `samtools markdup`);
446
+ it has been compared to `samtools markdup` on that one sample only, so compare it with your own data when possible;
447
+ - reads differing only by soft clipping are not matched;
448
+ - at very high depth on a small genome, independent fragments can coincide and be counted as duplicates.
449
+
450
+ **Other limits.**
451
+
452
+ - BAM files must be sorted and indexed. CRAM is not supported.
453
+ - In amplicon mode, BED targets with *different* names are never merged, even if they overlap; each gene is computed independently.
454
+ - Tested on Linux. macOS should work but has not been tested; native Windows is not supported (use WSL).
455
+
456
+ ---
457
+
458
+ ## Performance
459
+
460
+ Measured with the companion benchmark (`fastbamqc-benchmark`): 8 *Plasmodium falciparum* WGS BAM files (mean depth 47–85X),
461
+ 4 cores, warm disk cache, median of 3 runs, one machine.
462
+
463
+ | Tool | Time, 8 BAM | Peak memory | Mean-coverage error vs `samtools depth` |
464
+ |---|---|---|---|
465
+ | mosdepth | 12.0 s | 77 MiB | 0.000 |
466
+ | **fastbamqc** (tables) | **30.7 s** | 202 MiB | 0.002 |
467
+ | **fastbamqc** (`--report`) | **44.8 s** | 204 MiB | 0.002 |
468
+ | samtools coverage | 122.9 s | 13 MiB | 0.229 (does not count deletions) |
469
+ | Qualimap | 241.6 s | 1803 MiB | 0.000 |
470
+
471
+ mosdepth is faster (about 2.6×) because it computes depth only; fastbamqc also gives the interpretability verdict, the
472
+ threshold columns, and the report. The 0.002X difference with the reference is compatible with the 2-decimal rounding of the tables.
473
+ Results on other genomes, other machines or cold caches may differ.
474
+
475
+ ---
476
+
477
+ ## Troubleshooting
478
+
479
+ | Message / symptom | Cause and fix |
480
+ |---|---|
481
+ | `index missing (.bai/.csi)` | Index the file: `samtools index x.bam`. |
482
+ | `No file matching '…'` / `Directory not found` | Check `-i` and `-f`; quote the pattern (`"*.bam"`). |
483
+ | `BED contig(s) not found in the BAM` | The BED chromosome names do not match the BAM (`chr1` vs `1`). |
484
+ | `pysam` cannot be installed | Use Linux, macOS or WSL; on native Windows `pysam` is not available. |
485
+ | Memory too high | Lower `-c` (each process uses its own memory). |
486
+ | Verdicts differ from what you expected | Check `--interp-depth`, `--interp-pct` and whether `--interp-nodup` is on. |
487
+
488
+ ---
489
+
490
+ ## Citation and licence
491
+
492
+ fastbamqc is released under the [MIT licence](LICENSE).
493
+
494
+ If you use it, please cite it using the metadata in [`CITATION.cff`](CITATION.cff) (GitHub shows a *Cite this repository* button). The citation of the article and the DOI of the archived release will be added here once available.
495
+
496
+ Changes between versions are listed in [`CHANGELOG.md`](CHANGELOG.md).