This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Merge BAM files without retaining sample information

I want to merge several groups of BAM files in such a way that when I then create an mpileup from the resulting merged files, reads in each group are treated as if they are coming from the same population. Should I do

samtools merge -r 1.bam 1.1.bam 1.2.bam 1.3.bam

samtools merge -r 2.bam 2.1.bam 2.2.bam 2.3.bam

etc.

and then

samtools mpileup -R -o 123.mpileup 1.bam 2.bam etc.

OR

should I simply not use -r in samtools merge or -R in samtools mpileup?

Is there a difference?

Thank you!

samtools

1 answer

You could use the 'AddOrReplaceReadGroups' command in Picard (https://sourceforge.net/projects/picard/) to set the read group to what you want them to be in each BAM file after merging.

Log in to answer this question.