samtools-depth(1)

πŸ’… samtools-depth β€” the read-depth calculator, bestie edition

Okay so real talk, this is the manual page for samtools-depth, part of the samtools fam (bioinformatics tools, iykyk). Stick with me, we're gonna get you reading depths like a main character. πŸŽ€


✨ NAME ✨

samtools depth β€” computes the read depth at each position or region. Slay. That's literally the whole job and she does it gorgeously. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

samtools depth [options] [in1.sam|in1.bam|in1.cram
[in2.sam|in2.bam|in2.cram] [...]]

🌸 DESCRIPTION 🌸

Computes the depth at each position or region. That's it, that's the vibe check. Give her alignments, she gives you numbers. πŸ”₯


✨ OPTIONS ✨

The full menu, no skips, no cap:

  • -a β€” Output all positions, including the ones with zero depth. Nobody gets left on read, not even the empty spots. πŸ’œ
  • -a -a, -aa β€” Output absolutely all positions, including unused reference sequences. Highkey extra. Heads up though: when you use this with a BED file, -a may sometimes act like -aa was specified if the reference sequence has coverage outside of the region specified in the BED file. 🫢
  • -b FILE β€” Compute depth at the list of positions or regions in the specified BED FILE. Default is []. πŸ“
  • -f FILE β€” Use the BAM files specified in FILE (a file of filenames, one file per line). Default []. So meta, she reads a list of files. 🧚
  • -H β€” Write a comment line showing column names at the start of the output. The names are CHROM, POS, and then the input file name for each depth column. And if one of the inputs came from stdin, the name β€œ-” is used for that column. Label your girls. πŸ‘‘
  • -l INT β€” Ignore reads shorter than INT. Specifically this is the number of bases in the sequence, minus any soft clips. Bye to the shorties. πŸ’…
  • -m, -d INT β€” Deprecated since 1.13. This option previously limited the depth to a maximum value. It's still accepted as an option, but it's ignored. She's still invited to the party, she just doesn't do anything. 😭
Note for single files: the behaviour of old samtools depth -J -q0 -d INT FILE is identical to samtools mpileup -A -Q0 -x -d INT FILE | cut -f 1,2,4 β€” keep this in your back pocket, iykyk.
  • -o FILE β€” Write output to FILE. Using β€œ-” for FILE sends the output to stdout (which is also the default if this option isn't used). 🌈
  • -q, --min-BQ INT β€” Only count reads with base quality greater than or equal to INT. Standards! ✨
  • -Q, --min-MQ INT β€” Only count reads with mapping quality greater than or equal to INT. More standards! ⭐
  • -r CHR:FROM-TO β€” Only report depth in the specified region. Tunnel vision, but make it intentional. πŸ¦‹
  • -X β€” If this option is set, it lets you specify customized index file location(s) when your data folder doesn't contain any index file. Example usage: samtools depth [options] -X /data_folder/in1.bam [/data_folder/in2.bam [...]] /index_folder/index1.bai [/index_folder/index2.bai [...]]. Your indexes can live wherever they want, we don't judge. πŸ’–
  • -g FLAGS β€” By default, reads that have any of the flags UNMAP, SECONDARY, QCFAIL, or DUP set are skipped. To include these reads back in the analysis, use this option together with the desired flag or flag combination. FLAGS can be specified in hex by beginning with 0x (i.e. /^0x[0-9A-F]+/), in octal by beginning with 0 (i.e. /^0[0-7]+/), as a decimal number not beginning with '0', or as a comma-separated list of flag names. Default [0]. For a list of flag names see samtools-flags(1). πŸ“Ž
  • -G FLAGS, --excl-flags FLAGS β€” Discard reads that have any of the flags specified by FLAGS set. FLAGS are specified as for the -g option. Default [UNMAP,SECONDARY,QCFAIL,DUP]. Blocked, blocked, blocked. πŸ™ˆ
  • --incl-flags FLAGS β€” Only include reads with at least one bit set in FLAGS present in the FLAG field. FLAGS are specified as for the -g option. Default [0]. πŸ’œ
  • --require-flags FLAGS β€” Only include reads with all bits set in FLAGS present in the FLAG field. FLAGS are specified as for the -g option. Default [0]. All or nothing, periodt. πŸ”₯
  • -J β€” Include reads with deletions in depth computation. Giving the deleted bases their moment. 🌟
  • -s β€” For the overlapping section of a read pair, count only the bases of the first read. Note this algorithm changed in 1.13, so the results may differ slightly to older releases. She's grown, okay? 😭

πŸ’€ CAVEATS πŸ’€

So it may appear that "samtools depth" is simply "samtools mpileup" with some of the columns removed β€” and genuinely, earlier versions of this command were just that. But both then and now there are subtle differences in parameters which make the two not entirely comparable. Differences, other than the obvious speed benefits, include:

  • Deletions (CIGAR element "D") are ignored by default in "depth". These may be counted by adding the -J option. "Mpileup" always counts the deleted bases, and has no option to toggle this. No toggle, no choice. πŸ’€
  • Beware there are idiosyncrasies in option naming. Specifically the -q and -Q options have their meanings swapped between "depth" and "mpileup". Do not get caught lacking on this one. πŸ™ˆ
  • The removal of overlapping sequences (option -s) is on by default in "mpileup" and off by default in "depth". Additionally the overlap removal algorithm differs, giving subtle changes when Ns are present in the sequence. Also any paired read is considered for overlap removal by "depth", rather than only those with the properly-paired flag set ("mpileup"). See above for a more detailed description. πŸŽ€
  • The default minimum quality value is 0 for "depth" and 13 for "mpileup". Different defaults, different girls. ⭐
  • Specifying multiple BAMs will produce one depth column per file with "depth", but these are merged in "mpileup". Columns stay separate, we're not merging anything, periodt. πŸ’…
  • "Depth" doesn't have a maximum depth limit, while "mpileup" defaults to a maximum of 8000. She has no ceiling, honestly iconic. πŸ‘‘
  • If a reference is specified to "mpileup" the BAQ algorithm will be used to adjust quality values, although it can be disabled. "Depth" never uses BAQ. Never ever. πŸ¦‹

🫢 AUTHOR 🫢

Written by Heng Li and James Bonfield from the Sanger Institute. Legends, fr fr. πŸ’–


🌈 SEE ALSO 🌈

samtools(1), samtools-mpileup(1), samtools-coverage(1), samtools-sort(1)

Samtools website: <http://www.htslib.org/>


And that's the whole page bestie β€” go compute some depth. πŸ’…βœ¨

Sign-off szn: this gorgeous specimen is from samtools-1.24, dated 9 July 2026. Screenshot it, memorise it, tell your friends. πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from