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?
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.
1 answer
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.
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.
Yes, thanks. I am not sure what happened but it's fixed now.
i guess you are missing the '-e' option for echo, otherwise the tab wont be interpreted correctly.
Log in to answer this question.
You might want to have a look at the SAM format specifications