Entering edit mode
9.9 years ago
dariober
15k
Hello,
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?
Thanks
Dario
Thanks! I'll keep it mind and use picard in the future.
and you can use http://broadinstitute.github.io/picard/command-line-overview.html#AddOrReplaceReadGroups
Hi again Pierre. Sorry maybe I'm being thick. I'm not sure if/how to use
AddOrReplaceReadGroup
for this purpose as it complains thatRG ID on SAMRecord not found in header
. But that's what I want to do: Put the RG ID from the reads to the header.Did you find a solution for this? I'm having the same issue.
@Jordan My solution was to write the script linked in my answer below.