You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
addreplacerg overwrite_all doesn't overwrite the old RG tags #856
Initially I was thinking this would be CRAM specific, given the description and because cram stores RG tags in a different way (they're an index into the Nth header record instead of an auxiliary tag string).
However I get the same effect with BAM files. I think it's just a documentation thing. It is adding or replacing RG lines in records, but it cannot replace an RG line in the header. Indeed in the simplest example with a single RG line with ID:1#49 I tried replacing it via -r ID:1#49 -r SM:z and it tells me:
[init] ID of new RG line specified conflicts with that of an existing header RG line. Overwrite not yet implemented.
So yes, sadly it is normal! I'll leave this open though as it's a useful feature request to actually replace RG tags in the header too as the name of the command hints at.
Until then, you can try outputting to stdout and feed that to a samtools reheader command with a corrected header.
I was also confused addreplacerg did not work for replacing, but just appending a new RG with r parameter. I also tried the -R, which always outputed a message "RG ID supplied does not exist in header. Supply full @rg line with -r instead?", thought I had the same RG ID in bam file. So, I am afraid I gonna try the pircard to replace RG info.
As addreplacerg otherwise removes any trace of foo, it seems sensible to completely replace the @RG ID:foo line too. Hopefully this will be easier with the new header API…
Activity
jkbonfield commentedon May 30, 2018
Initially I was thinking this would be CRAM specific, given the description and because cram stores RG tags in a different way (they're an index into the Nth header record instead of an auxiliary tag string).
However I get the same effect with BAM files. I think it's just a documentation thing. It is adding or replacing RG lines in records, but it cannot replace an RG line in the header. Indeed in the simplest example with a single RG line with
ID:1#49I tried replacing it via-r ID:1#49 -r SM:zand it tells me:So yes, sadly it is normal! I'll leave this open though as it's a useful feature request to actually replace RG tags in the header too as the name of the command hints at.
Until then, you can try outputting to stdout and feed that to a samtools reheader command with a corrected header.
huizhen2014 commentedon Nov 8, 2018
I was also confused addreplacerg did not work for replacing, but just appending a new RG with r parameter. I also tried the -R, which always outputed a message "RG ID supplied does not exist in header. Supply full @rg line with -r instead?", thought I had the same RG ID in bam file. So, I am afraid I gonna try the pircard to replace RG info.
huizhen2014 commentedon Nov 8, 2018
Just now, I have tried with picard AddOrReplaceReadGroups, it worked and directly replaced the old RG info
jmarshall commentedon Jul 17, 2019
We recently ran afoul of this with BAM files in our pipeline. Here is an example with a SAM file replacerg.sam:
As
addreplacergotherwise removes any trace offoo, it seems sensible to completely replace the@RG ID:fooline too. Hopefully this will be easier with the new header API…