This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Samtools Depth Option For More Than One Bam Files

Hi everyone,

I've been stuck on this for several days. I want to use the samtools depth command but not only for a single bam file. I need to find a way to include all my bam files downloaded in the command.

Has anyone got an idea of how i can do this??

Thank you in advance, Maria

samtools

1 answer

The usage says that you can link multiple files, make sure the specify the options before the bam files

Usage: samtools depth [options] in1.bam [in2.bam [...]]
Options:
   -b <bed>            list of positions or regions
   -f <list>           list of input BAM filenames, one per line [null]
   -l <int>            minQLen
   -q <int>            base quality threshold
   -Q <int>            mapping quality threshold
   -r <chr:from-to>    region

Be warned though, samtools depth (at least as of version 1.1-30-g7f47a7c) doesn't combine the depth info across bam files for samples (same SM tag) occurring in multiple files.
I expected it to output one column per sample since most other commands work that way, but instead it outputs one column per bam file.

Hey, If my command is :

samtools depth -a -f list.txt > all.depth

and list.txt looks like this:

F1.bam
F2.bam
...
F10.bam

Is samtools output in the same order?

I mean is the third column F1.bam, the fourth F2.bam, and so on?

enter image description here

Log in to answer this question.