I merged bam files using
samtools merge -r out.bam in1.bam in2.bam ...
With -r option I got the RG tag for each read, as expected, good. However, the header of the merged bam does not have the @RG lines. So my question: Is there any off-the-shelf tools to add the @RG header lines once the reads have been tagged?
If not, the pipeline I have in mind goes along these lines:
- Scan the bam file and collect all the different RG tags
- Output the header of the bam file.
- Append the RG tags to the header the
- Reheader the original bam file.
Does it make sense?