samtools addreplacerg gives error
1
0
Entering edit mode
5.3 years ago

I have bam files, created by bowtie2, to which I need to add read group information. The obvious tool is samtools addreplacerg from samtools v1.3.1 , but I always get an error. Below is the simplest command I tried, with the error. I have tried single quotes, double quotes, adding "@RG\t" to the text, and too many other variants to mention. All give the same message. Can anyone tell me what I am doing wrong?

samtools addreplacerg -r ID:S1 -o 3D7-D3-B3_S1_RGID.bam 3D7-D3-B3_S1_s.bam

[parse_args] The supplied RG line lacks an ID tag.

alignment bam samtools • 4.7k views
ADD COMMENT
0
Entering edit mode

In the meantime I created a header file for each bam file and used samtools merge -rh tempheader_S1 ... which worked fine. So the task is done, but I would still like to know why I couldn't use the more obvious command, which gives me other options for the ID flag than the input bam filename

ADD REPLY
0
Entering edit mode

Try this command it will surely work

samtools addreplacerg -r "@RG\tID:S1" -o 3D7-D3-B3_S1_RGID.bam 3D7-D3-B3_S1_s.bam 
ADD REPLY
0
Entering edit mode
  1. At the time this did not work, as I said in the list of things I tried.
  2. Since samtools 1.4 release this will work, as stated in the comment by John Marshall
  3. My actual mistake was failing to repeat '-r' before each element I was adding to the information, but thinking that a single '-r' was needed for the entire key:tag set. This is stated in my comment on John Marshall's answer
ADD REPLY
0
Entering edit mode

oh sure, thanks

ADD REPLY
2
Entering edit mode
5.3 years ago

This is a samtools bug that has since been fixed, though the fix has not yet appeared in a release.

This "lacks an ID tag" message was incorrectly triggered if -r ID:foo is the last -r option given. Normally the reason for adding an RG header is that you want to add lots of interesting information about the read group:

samtools addreplacerg -r ID:S1 -r LB:L1 -r SM:SAMPLE1 -o output foo.bam

and naturally you would put the most important bit (the primary key!) ID first :-), and so addreplacerg would complete successfully and not erroneously give this error.

Amusingly enough, this was fixed for ideological reasons not because this minor bug was noticed.

ADD COMMENT
0
Entering edit mode

Thanks! I originally had:

samtools addreplacerg -r ID:S1 SM:S1 PL:ILLUMINA -o out.bam in.bam

without the repeated "-r", which gives the same "The supplied RG line lacks an ID tag", and that error message had me trying all sorts of incorrect fixes, including stripping down to just the ID tag

ADD REPLY
0
Entering edit mode

This fix subsequently appeared in the samtools 1.4 release, in 2017.

ADD REPLY

Login before adding your answer.

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