samtools-stats(1)
π samtools-stats(1): the stats glow-up manual π
πΈ NAME πΈ
samtools stats β produces comprehensive statistics from an alignment file, like a full vibe check for your reads π
β¨ SYNOPSIS β¨
samtools stats [options] in.sam|in.bam|in.cram [region...]
π¦ DESCRIPTION π¦
Okay so samtools stats collects statistics from BAM files and outputs them in a text format. Bestie, the output can be visualized graphically using plot-bamstats, which is giving βdata but make it cuteβ β¨
Hereβs the output section lineup first, then the detailed lore:
CHKβ ChecksumSNβ Summary numbersFFQβ First fragment qualitiesLFQβ Last fragment qualitiesGCFβ GC content of first fragmentsGCLβ GC content of last fragmentsGCCβ ACGT content per cycleGCTβ ACGT content per cycle, read orientedFBCβ ACGT content per cycle for first fragments onlyFTCβ ACGT raw counters for first fragmentsLBCβ ACGT content per cycle for last fragments onlyLTCβ ACGT raw counters for last fragmentsBCCβ ACGT content per cycle for BC barcodeCRCβ ACGT content per cycle for CR barcodeOXCβ ACGT content per cycle for OX barcodeRXCβ ACGT content per cycle for RX barcodeMPCβ Mismatch distribution per cycleQTQβ Quality distribution for BC barcodeCYQβ Quality distribution for CR barcodeBZQβ Quality distribution for OX barcodeQXQβ Quality distribution for RX barcodeISβ Insert sizesRLβ Read lengthsFRLβ Read lengths for first fragments onlyLRLβ Read lengths for last fragments onlyMAPQβ Mapping qualitiesIDβ Indel size distributionICβ Indels per cycleCOVβ Coverage (depth) distributionGCDβ GC-depthRFSβ Reference Statistics
The βcycleβ terminology used here originates from the Illumina instruments, but it is interpreted more generally as the Nth base reported in the original read orientation (starting from 1). π§¬
Not all sections will be reported, because some depend on the data being coordinate sorted while others are only present when specific barcode tags are in use. Itβs giving βit depends,β lowkey.
Some of the statistics are collected for βfirstβ or βlastβ fragments. Records are put into these categories using the PAIRED (0x1), READ1 (0x40) and READ2 (0x80) flag bits, as follows:
- Unpaired reads (i.e.
PAIREDis not set) are all βfirstβ fragments. For these records, theREAD1andREAD2flags are ignored. - Reads where
PAIREDandREAD1are set, andREAD2is not set are βfirstβ fragments. - Reads where
PAIREDandREAD2are set, andREAD1is not set are βlastβ fragments. - Reads where
PAIREDis set and either bothREAD1andREAD2are set or neither is set are not counted in either category.
Information on the meaning of the flags is given in the SAM specification document at https://samtools.github.io/hts-specs/SAMv1.pdf. π
The CHK row contains distinct CRC32 checksums of read names, sequences and quality values. The checksums are computed per alignment record and summed, meaning the checksum does not change if the input file has the sort-order changed. Slay, stable checksums.
NOTE: Checksum calculation for quality values was modified and quality checksum value will be different from that generated using versions up to 1.21. β οΈ
The SN section contains a series of counts, percentages, and averages, in a similar style to samtools flagstat, but more comprehensive. Itβs the main character of summary sections, honestly π
raw total sequencesβ total number of reads in a file, excluding supplementary and secondary reads. Same number reported bysamtools view -c -F 0x900.filtered sequencesβ number of discarded reads when using-for-Foption.sequencesβ number of processed reads.is sortedβ flag indicating whether the file is coordinate sorted (1) or not (0).1st fragmentsβ number of first fragment reads (flags0x01not set; or flags0x01and0x40set,0x80not set).last fragmentsβ number of last fragment reads (flags0x01and0x80set,0x40not set).reads mappedβ number of reads, paired or single, that are mapped (flag0x4or0x8not set).reads mapped and pairedβ number of mapped paired reads (flag0x1is set and flags0x4and0x8are not set).reads unmappedβ number of unmapped reads (flag0x4is set).reads properly pairedβ number of mapped paired reads with flag0x2set.pairedβ number of paired reads, mapped or unmapped, that are neither secondary nor supplementary (flag0x1is set and flags0x100(256) and0x800(2048) are not set).reads duplicatedβ number of duplicate reads (flag0x400(1024) is set).reads MQ0β number of mapped reads with mapping quality 0.reads QC failedβ number of reads that failed the quality checks (flag0x200(512) is set).non-primary alignmentsβ number of secondary reads (flag0x100(256) set).supplementary alignmentsβ number of supplementary reads (flag0x800(2048) set).total lengthβ number of processed bases from reads that are neither secondary nor supplementary (flags0x100(256) and0x800(2048) are not set).total first fragment lengthβ number of processed bases that belong to first fragments.total last fragment lengthβ number of processed bases that belong to last fragments.bases mappedβ number of processed bases that belong to reads mapped.bases mapped (cigar)β number of mapped bases filtered by the CIGAR string corresponding to the read they belong to. Only alignment matches(M), inserts(I), sequence matches(=) and sequence mismatches(X) are counted.bases trimmedβ number of bases trimmed by bwa, that belong to non secondary and non supplementary reads. Enabled by-qoption.bases duplicatedβ number of bases that belong to reads duplicated.mismatchesβ number of mismatched bases, as reported by theNMtag associated with a read, if present.error rateβ ratio between mismatches and bases mapped (cigar).average lengthβ ratio between total length and sequences.average first fragment lengthβ ratio between total first fragment length and 1st fragments.average last fragment lengthβ ratio between total last fragment length and last fragments.maximum lengthβ length of the longest read (includes hard-clipped bases).maximum first fragment lengthβ length of the longest first fragment read (includes hard-clipped bases).maximum last fragment lengthβ length of the longest last fragment read (includes hard-clipped bases).average qualityβ ratio between the sum of base qualities and total length.insert size averageβ the average absolute template length for paired and mapped reads.insert size standard deviationβ standard deviation for the average template length distribution.inward oriented pairsβ number of paired reads with flag0x40(64) set and flag0x10(16) not set or with flag0x80(128) set and flag0x10(16) set.outward oriented pairsβ number of paired reads with flag0x40(64) set and flag0x10(16) set or with flag0x80(128) set and flag0x10(16) not set.pairs with other orientationβ number of paired reads that don't fall in any of the above two categories.pairs on different chromosomesβ number of pairs where one read is on one chromosome and the pair read is on a different chromosome.percentage of properly paired readsβ percentage of reads properly paired out of sequences.bases inside the targetβ number of bases inside the target region(s) (when a target file is specified with-toption).percentage of target genome with coverage > VALβ percentage of target bases with a coverage larger thanVAL. By default,VALis0, but a custom value can be supplied by the user with-goption.
The FFQ and LFQ sections report the quality distribution per first/last fragment and per cycle number. They have one row per cycle (reported as the first column after the FFQ/LFQ key) with remaining columns being the observed integer counts per quality value, starting at quality 0 in the left-most row and ending at the largest observed quality. Thus each row forms its own quality distribution and any cycle specific quality artefacts can be observed. Itβs giving quality drama per cycle π
GCF and GCL report the total GC content of each fragment, separated into first and last fragments. The columns show the GC percentile (between 0 and 100) and an integer count of fragments at that percentile. GC but split, periodt π
GCC, FBC and LBC report the nucleotide content per cycle either combined (GCC) or split into first (FBC) and last (LBC) fragments. The columns are cycle number (integer), and percentage counts for A, C, G, T, N and other (typically containing ambiguity codes) normalised against the total counts of A, C, G and T only (excluding N and other). A/C/G/T girlies stay winning π
GCT offers a similar report to GCC, but whereas GCC counts nucleotides as they appear in the SAM output (in reference orientation), GCT takes into account whether a nucleotide belongs to a reverse complemented read and counts it in the original read orientation. If there are no reverse complemented reads in a file, the GCC and GCT reports will be identical. No reverse complements, no difference, iconic π¦
FTC and LTC report the total numbers of nucleotides for first and last fragments, respectively. The columns are the raw counters for A, C, G, T and N bases. Raw counters, no filter, we love to see it π«Ά
MPC reports the number of mismatches per cycle and per quality value. The MPC statistics are only included when a reference is specified via the -r option. There is one row per cycle number. Each row includes the cycle number, the number of N bases (not counted in the per-qual columns), followed by one column per quality value (starting at zero and incrementing by one each time) listing the number of non-N mismatches with that quality. A mismatch is defined as an ACGT sequence base mismatching an ACGT reference base. Ambiguity codes are ignored (except for sequence N as mentioned above, which is counted even when the reference is also N). Mismatch lore, but make it per quality π₯
okay so we're still in DESCRIPTION bestie β here's the rest of the section list, no cap π
BCC, CRC, OXC and RXC</p> are literally the barcode equivalent of GCC β they show you the nucleotide content for the barcode tags BC, CR, OX and RX respectively π§¬. Their quality value distributions live in the QTQ, CYQ, BZQ and QXQ sections, and those correspond to the BC/QT, CR/CY, OX/BZ and RX/QX SAM format sequence/quality tags. These quality value distributions follow the exact same format used in the FFQ and LFQ sections, iykyk β¨.
All these section names get a number slapped on the end (1 or 2), and that number tells you whether the stats underneath are for the first or the second barcode β which only happens in the dual indexing case. So you'll see them as BCC1, CRC1, OXC1 and RXC1, hanging out with their quality besties QTQ1, CYQ1, BZQ1 and QXQ1 π«Ά. And if there's a separator in the barcode sequence (usually a hyphen) β which is the signal that dual indexing is happening β then the sections ending in "2" get reported too, showing the second tag statistics (so like, both BCC1 and BCC2 show up, iconic).
IS</p> reports insert size distributions, one row per size, with the size in the first column πΈ. The columns after that are: frequency of total pairs, inward oriented pairs, outward orient pairs, and other orientation pairs. The -i option sets the maximum insert size that gets reported.
RL</p> reports the distribution for all read lengths, one row per observed length (up to the maximum you set with the -l option). Columns are read length and frequency. FRL and LRL carry the exact same info, just split into first and last fragments π.
MAPQ</p> reports the mapping qualities for the mapped reads β and it ignores duplicates, supplementary, secondary and failing quality reads. Not them, blocked π.
ID</p> reports the distribution of indel sizes, one row per observed size. Columns are: size, frequency of insertions at that size, and frequency of deletions at that size.
IC</p> reports the frequency of indels occurring per cycle, broken down by both insertion / deletion and by first / last read π₯. Quick note bestie: for multi-base indels this only counts the first base location. Columns are cycle, number of insertions in first fragments, number of insertions in last fragments, number of deletions in first fragments, and number of deletions in last fragments.
COV</p> reports a distribution of the alignment depth per covered reference site π. For example, an average depth of 50 would ideally give you a normal distribution centred on 50 β but repeats or copy-number variation can pop extra peaks at approximate multiples of 50, which is very much a look π. The first column is an inclusive coverage range in the form of [min-max]. The next columns are a repeat of the maximum portion of the depth range (now as a single integer) and the frequency that depth range was observed. Minimum, maximum and range step size are all controlled by the -c option. Depths above and below the minimum and maximum get reported with ranges [<min] and [max<].
GCD</p> reports the GC content of the reference data aligned against, per alignment record π. One row per observed GC percentage, that percentage in the first column, and the whole thing is sorted on that column. The second column is a total sequence percentile, as a running total (ending at 100%). You can use the first and second columns together to produce a simple distribution of GC content β¨. The subsequent columns list the coverage depth at the 10th, 25th, 50th, 75th and 90th GC percentiles for this specific GC percentage β that's how you spot any GC bias in mapping. Heads up: these columns are averaged depths, so they're floating point with no maximum value.
RFS</p> reports statistics of the reference data π¦. The first line gives the overall statistics for the reference: total number of targets in the input file and the number covered, then the average GC content, and the minimum, maximum, average and total lengths of the targets in the report. The second and subsequent lines contain the statistics for each individual target. Targets are regions either specified on the command line or given in the target file (the -t option). If you don't choose any regions, all the reference data is used. Each line gives the name of the target, its length, GC content and number of unknown bases. For the GC content and the number of unknown bases you need a reference file (the -t option) β otherwise that value is set to -1. The lengths come from the region specification and from the file header.
β¨ OPTIONS β¨
-c,--coverage MIN,MAX,STEPβ sets the coverage distribution to the range you give (MIN,MAX,STEP, all integers) [1,1000,1]-d,--remove-dupsβ yeets reads marked as duplicates out of the statistics entirely-f,--required-flag STR|INTβ the required flag,0means unset. Also peepsamtools flags[0]-F,--filtering-flag STR|INTβ the filtering flag,0means unset. Also peepsamtools flags[0]--GC-depth FLOATβ the size of the GC-depth bins (smaller bin size = more memory needed, no cap) [2e4]-h,--helpβ this help message, your bestie π«Ά-i,--insert-size INTβ maximum insert size [8000]-I,--id STRβ include only the listed read group or sample name [[]]-l,--read-length INTβ only reads with the given read length make it into the statistics [-1]-m,--most-inserts FLOATβ report only the main part of inserts [0.99]-P,--split-prefix STRβ a path or string prefix to prepend to filenames when you're making categorised statistics files with-S/--split[input filename]-q,--trim-quality INTβ the BWA trimming parameter [0]-r,--ref-seq FILEβ reference sequence, which is required for GC-depth and mismatches-per-cycle calculation [[]]-S,--split TAGβ on top of the complete statistics, also output categorised statistics based on the tagged fieldTAG(like, use--split RGto split into read groups) π- Categorised statistics get written to files named
<prefix>_<value>.bamstat, whereprefixis whatever you gave--split-prefix(or the input filename by default) andvalueis a value that's been encountered as the specified tagged field's value in one or more alignment records.
- Categorised statistics get written to files named
-t,--target-regions FILEβ only do stats in these regions. Tab-delimited filechr,from,to, 1-based, inclusive [[]]-x,--sparseβ suppress outputtingISrows where there are no insertions-p,--remove-overlapsβ remove overlaps of paired-end reads from coverage and base count computations-g,--cov-threshold INTβ only bases with coverage above this value get included in the target percentage computation [0]-Xβ if this option is set, it lets you specify customised index file location(s) when the data folder has no index file in it. Example usage:samtools stats [options] -X /data_folder/data.bam /index_folder/data.bai chrM:1-10-@,--threads INTβ number of input/output compression threads to use in addition to the main thread [0].--ref-statsβ create statistics on reference data--ref-stats-chunk INTβ number of reference bases to read at a time, in Mbs, for reference statistics [1]
π AUTHOR π
Written by Petr Danacek, with major modifications by Nicholas Clarke, Martin Pollard, Josh Randall, and Valeriu Ohan β all from the Sanger Institute, absolute icons the lot of them ππ.
π SEE ALSO π
Samtools website: http://www.htslib.org/ β
aaaand that's the whole page bestie, you ate that πβ¨ this one's from samtools-1.24, dated 9 July 2026, and it's the samtools-stats(1) manual β go forth and stat responsibly, mwah ππ§
π¦ where this page comes from
- epel 10: samtools 1.24-2.el10_3 Β· MIT
- nixpkgs unstable: samtools 1.24
- Copyright (C) 2008-2011, 2013-2018, 2020-2021, 2024-2025 Genome Research Ltd
- copyright (C) 2010, 2011 Broad Institute
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms