---
name: "QTLtools-bamstat"
section: "1"
platform: "linux"
package: "qtltools"
version: "1.3.1+dfsg-4+b3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/QTLtools-bamstat"
---

# QTLtools-bamstat(1)

Calculate stats of overlap between an RNAseq BAM file and an annotation

## NAME

QTLtools bamstat - Calculate stats of overlap between an RNAseq BAM file and an annotation

## SYNOPSIS

**QTLtools bamstat --bam \[*sample.bam\|sample.sam\|sample.cram*\] --bed \[*gene\_annotation.bed*\]  --out *output\_file*** \[*OPTIONS*\]

## DESCRIPTION

This mode counts the number of RNAseq reads, and the ones that overlap with an annotation file.  We recommend using uniquely mapping reads only by specifying the correct **--filter-mapping-quality**.

## OPTIONS

- **--bed *annotation.bed***

  Annotation of interest REQUIRED.

- **--bam, -b \[*in.bam*\|*in.sam*\|*in.cram*\]**

  Sequence data in BAM/SAM/CRAM format. REQUIRED.

- **--out, -o *output***

  Output file name REQUIRED.

- **--filter-mapping-quality *integer***

  Minimum mapping quality for a read or read pair to be considered.  Set this to only include uniquely mapped reads. DEFAULT=10

- **--filter-keep-duplicates**

  Keep reads designated as duplicate by the aligner. RECOMMENDED for RNAseq

## OUTPUT FILE COLUMNS

- **--out** *filename*

  This file does not have header and it contains the following columns:

  | | |
  | --- | --- |
  | 1 | The total number of reads in the BAM file |
  | 2 | The number of mapped sequencing reads passing the **--filter-mapping-quality** |
  | 3 | The number of mapped sequencing reads falling within the annotations specified with **--bed** |
  | 4 | The total number of annotations in the **--bed** file |
  | 5 | The number of annotations covered by at least one sequencing read |

## EXAMPLES

- o

  Running bamstat on an RNAseq sample mapped with GEM and GENCODE gene annotations:

-

  QTLtools bamstat --bam HG00381.chr22.bam  --out HG00381.chr22.bamstat.txt --bed gencode.v19.annotation.bed.gz --filter-mapping-quality 150 --filter-keep-duplicates

## SEE ALSO

[*QTLtools*(1)](/QTLtools/1.md)

QTLtools website: \<https://qtltools.github.io/qtltools\>

## BUGS

Please submit bugs to \<https://github.com/qtltools/qtltools\>

## CITATION

Delaneau, O., Ongen, H., Brown, A. et al. A complete tool set for molecular QTL discovery and analysis. *Nat Commun* **8**, 15452 (2017).  \<https://doi.org/10.1038/ncomms15452\>

## AUTHORS

Olivier Delaneau (olivier.delaneau@gmail.com), Halit Ongen (halitongen@gmail.com)
