Adding Read Groups To Bam Files
4
11
Entering edit mode
11.8 years ago

Greetings all,

Let me start by saying I know how to add read groups to a BAM file. What I am looking for is the easiest way to do it. This problem has been around for a while so I though I would see what neat tricks people are using.

Thanks

bam gatk samtools bwa • 51k views
ADD COMMENT
16
Entering edit mode
ADD COMMENT
1
Entering edit mode

What parameter would you use for these options (mandatory) in AddOrReplaceReadGroups

LB=String    Read Group Library  Required.
PU=String    Read Group platform unit (eg. run barcode)  Required.
SM=String    Read Group sample name  Required.
ADD REPLY
6
Entering edit mode
11.8 years ago
Rm 8.3k

See this.

The library information of each read group is kept in rg.txt

perl -e 'print "@RG\tID:ga\tSM:hs\tLB:ga\tPL:Illumina\n@RG\tID:454\tSM:hs\tLB:454\tPL:454\n"' > rg.txt
samtools merge -rh rg.txt - ga.bam 454.bam | samtools rmdup - - | samtools rmdup -s - aln.bam

Some discussion over here.

Python: Adding Read Group (@RG) tags to BAM or SAM files:

How can I tell if my BAM file has read group and sample information

Related post: Read Group In Sam/Bam Files: What Do They Exactly Describe?

ADD COMMENT
1
Entering edit mode

I think this solution is invalid.

  1. you need to escape @ character, so it would be at least:

    perl -e 'print "\@RG\tID:ga\tSM:hs\tLB:ga\tPL:Illumina\n\@RG\tID:454\tSM:hs\tLB:454\tPL:454\n"' > rg.txt
    
  2. The second problem is that the line defined only the header and -r flag will assign readgroups by filenames - in this case ga and 454. Related question I asked to find a neat solution is here

ADD REPLY
0
Entering edit mode

Thanks for the note on escaping the @ character...was really confused

ADD REPLY
0
Entering edit mode

Could you please explain these two commands.

Can i use the same rg.txt in my libraries. Or i need to replace them. Not sure by what ?

In second command, why there are two bam ?

ADD REPLY
2
Entering edit mode
4.1 years ago
sagitaninta ▴ 20

I know this question is years ago, but I just want to add that there is bamaddrg as part of bamtools that has really straightforward usage: http://github.com/ekg/bamaddrg

ADD COMMENT
0
Entering edit mode
2.8 years ago
Gregor Rot ▴ 540

Should samtools be able to do this: http://www.htslib.org/doc/samtools-addreplacerg.html

ADD COMMENT

Login before adding your answer.

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