Let's say you have two bam files from two different runs you need to merge.
- bam1_batch1.bam
- bam1_batch2.bam
Using samtools view -H <bamfile>
, get @RG information for each of two bams. I usually get ID, DT and PL info. from bam header and then add SM (sample tag) tag using following script. You can run this script before samtools merge
command in your PBS script.