Picard Addreplacereadgroup Error: Rg Id Not Found In Header
1
4
Entering edit mode
11.9 years ago
William ★ 5.3k

I have a bam file which is missing read groups in the header.

Picard ValidateSamFile.jar gives : ERROR: Record 1, Read name M0VN6:402:2486, RG ID on SAMRecord not found in header: M0VN6 ...

So I try to use Picard AddOrReplaceReadGroups:

AddOrReplaceReadGroups.jar I= myBam.bam O= myBam.readGroupReplaced.bam SORT_ORDER=coordinate RGID=myBam RGLB=myBam RGPL=IONTORRENT RGSM=myBam RGPU=myBam

This gives the error:

ERROR: Record 1, Read name M0VN6:402:2486, RG ID on SAMRecord not found in header: M0VN6 ...

Why does Picard AddOrReplaceReadGroups crash about this? This is what I am trying to fix by using that function. Or do I misunderstand what AddOrReplaceReadGroups does?

What I get from the AddOrReplaceReadGroups discription is that it replaces all read groups in the Bam file with the one specified and assigns all reads to this read group.

bam picard • 12k views
ADD COMMENT
0
Entering edit mode

You might want to have a look at the SAM format specifications

ADD REPLY
6
Entering edit mode
11.9 years ago

You have read group tags in each individual read (RGID). What you are telling Picard to do is add a conflicting @RG line to the header of your SAM file. You should just add the RG header line in the format:

@RG ID:id   PL:iontorrent   LB:library  SM:sample

This is all you need, since your reads already have RG ids. You should be able to verify this by looking at a read and finding the RG:Z:id tag.

ADD COMMENT
0
Entering edit mode

Ok how do I ad a read group to the bam header? Do I manually copy and edit the header to a file and then use picard ReplaceSamHeader?

ADD REPLY
2
Entering edit mode

That would be fine. You can do the following to append the @RG line to your BAM header:

echo '@RG\tID:id\tPL:iontorrent\tLB:library\tSM:sample' > rg
samtools view -H my.bam | cat - rg | header
samtools reheader header my.bam
ADD REPLY
1
Entering edit mode

i guess you are missing the '-e' option for echo, otherwise the tab wont be interpreted correctly.

ADD REPLY
0
Entering edit mode

There's a typo here, right? You don't want 'echo' there twice, and the read group fields have to be separated by a tab.

ADD REPLY
0
Entering edit mode

Yes, thanks. I am not sure what happened but it's fixed now.

ADD REPLY

Login before adding your answer.

Traffic: 1629 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