MergeBamAlignment conflicting headers between mapped and unmapped
AnsweredHi,
I wanted to ask how MergeBamAlignment deals with conflicting header information. Specifically if the unmapped BAM and mapped BAM have different @RG tags in the header then how does it resolve? I do not see this in documentation.
My issue is that I add @RG tag information during alignment with BWA-MEM. But when I use mergebamalignment while the reads retain the @RG ID the header changes the @RGID to the unmapped BAM. Therefore the read group IDs of the actual reads is different than the header. I have three screen shots below of this.
I don't see any documentation of how to deal with conflicting headers - I know a workaround is to change the readgroups with AddOrReplace read groups after MergeBamAlignmnet but I would rather do this at the level of MergeBamAlignment
This question is similar but doesn't say how it resolves this conflict: https://gatk.broadinstitute.org/hc/en-us/community/posts/4406765311515-Read-group-info-in-mapped-and-unmapped-bam-files?input_string=MergeBamAlignment%20conflicting%20headers%20between%20mapped%20and%20unmapped
Thank you!
After merge bam alignment RG
BWA-MEM mapped RG
Unmapped read group
My version of GATK is 4.2.1.0
gatk MergeBamAlignment Aligned=sorted_mapped_group"$read_batch_num".bam UNMAPPED=sorted_unmapped_group"$read_batch_num".bam o=bam_aligned_"$read_batch_num".bam R=~/evronylab/reference-files/hg38-gatk/Homo_sapiens_assembly38.fasta
-
Hi TA,
We would expect that this tool should throw an error when the @RG tag information does not match. MergeBamAlignment is not the tool to fix this problem, other tools can fix this (such as the ones you mentioned).
At the moment, does MergeBamAlignment throw an error as we would expect?
Best,
Genevieve
-
Hi Genevieve,
Ok got it.
Currently it is not throwing an error. It seems to resolve the conflict by using the @RG tag information from the unaligned BAM. This created an issue for me later on as during alignment I added RG tags to each mapping in the BAM. There was then a discrepancy between the RG tag in the header and the read group information for each mapping. This then created an error when I tried to do something else with this BAM with GATK because of this discrepency
I have resolved the issue (I made sure to have the same @RGID in both unaligned and aligned BAM) but wanted to bring up this issue as other users might encounter. I agree it should give an error when you try to align an unaligned and aligned BAM with different RGIDs.
-
TA thank you for the response. I have created a ticket so that this tool will throw an error for this issue in the future: https://github.com/broadinstitute/picard/issues/1789
Could you submit a small snippet of your files to recreate this behavior for testing purposes? Here are the instructions: https://gatk.broadinstitute.org/hc/en-us/articles/360035889671
Thank you!
Please sign in to leave a comment.
3 comments