This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools mpileup's options -b (more than one bam file) and -r cannot be used together

Hi, I would like to generate a mpileup file from 2 bam files in some regions instead of the whole chromosomes:

samtools -b bam_list_file -r regions_to_be_parsed.bed > mpileup_from_two_bam_files.pileup

The content in the bam_list_file is

~/1.bam

~/2.bam

but an error was given:

[E::mpileup] fail to parse region 'regions_to_be_parsed.bed' with 1.bam.

I do not think there is something wrong with the bam files or the bed file, because it works when I ran with the following command:

samtools -r regions_to_be_parsed.bed ~/1.bam > mpile1.pileup

samtools -r regions_to_be_parsed.bed ~/2.bam > mpile2.pileup

samtools -b bam_list_file > mpileup_from_two_bam_files.pileup

Is there some way to generate a mpileup file from two bam files with regions in bed file? Thanks for your time!

software error sequence

Hello jing.mengrabbit,

Please use the formatting bar (especially the code option) to present your post better.

Formatting bar

For example:

samtools -b bam_list_file -r regions_to_be_parsed.bed > mpileup_from_two_bam_files.pileup

Besides, I believe your command is:

samtools mpileup -b bam_list_file -r regions_to_be_parsed.bed > mpileup_from_two_bam_files.pileup

1 answer

Are you sure about -r regions_to_be_parsed.bed? The help says:

-r, --region REG region in which pileup is generated

I think -r should be used as -r chr1:200-210. For using bed files as intervals, you should use -l:

-l, --positions FILE skip unlisted positions (chr pos) or regions (BED)

Thanks for your reply. I misunderstood the helper documentation. It should be -l instead of -r as you said.

Log in to answer this question.