Add Information To @Rg Using Picard, Without Replacing Read Groups
2
1
Entering edit mode
11.0 years ago
DonJoe ▴ 30

Hello!

I'm using GATK to process some BAM files using their Best Practices. However, I forgot to add platform information under the @RG tag in the BAM header when I did the alignment (using BWA).

So, I've done dedup marking, indel realignment and the next step is base score recalibration. GATK won't do this since the platform information is missing from the BAM file. My first thought was to just use AddOrReplaceReadGroups from Picard, but as I understand it, this removes all other read groups in the BAM file and replace them with the one specified when running the program.

My question is: Can I just add platform information to the existing BAM file without removing the read groups in it (and replacing them with a single one)?

To clarify further, my header now looks something like this:

...    
@RG     ID:ABC0021    SM:SAMPLE123
@RG     ID:ABC0026    SM:SAMPLE123
@RG     ID:ABC0013    SM:SAMPLE123
...

And I want it to look something like this:

...    
@RG     ID:ABC0021    SM:SAMPLE123    PL:illumina    PU:1    LB:Lib1
@RG     ID:ABC0026    SM:SAMPLE123    PL:illumina    PU:1    LB:Lib1
@RG     ID:ABC0013    SM:SAMPLE123    PL:illumina    PU:1    LB:Lib1
...

Also with the platform info added to the reads.

Is this possible to achieve using Picard?

picard • 8.0k views
ADD COMMENT
0
Entering edit mode
ADD REPLY
1
Entering edit mode
11.0 years ago

Ignore me if you have already figured out the solution otherwise you can try something like this:

samtools view -H $BAM | sed "s/SM:SAMPLE123/SM:SAMPLE123\tPL:ILLUMINA/g" | samtools reheader - $BAM 

No temporary files will be created.

ADD COMMENT
0
Entering edit mode
ADD COMMENT
0
Entering edit mode

I don't believe I'm asking exactly the same question since my problem is not just the header. I want to modify the header and make the corresponding changes in the information for each read.

ADD REPLY
0
Entering edit mode

as far as I can see the RG-ID of the reads would not change isn't it ?

ADD REPLY
0
Entering edit mode

My mistake, I thought that I also had to change something in the read information. Sorry and thank you for pointing me to the answer :)

ADD REPLY

Login before adding your answer.

Traffic: 2023 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6