I assume you are using GATK software tools for downstream analysis. If that's the case, then you will most likely encounter issues due to missing information on read groups. I believe that GATK can't differentiate between read groups if they are all similar.
In all cases, you can find more information about SAM/BAM and related specifications on the 1.3 The header section as they describe what is mandatory.
So, if you have access to FastQ files, you can add them directly during the alignment process with
- bwa mem
-R STR Complete read group header line. ’\t’ can be used in STR and will be converted to a TAB in the output SAM. The read group ID will
be attached to every read in the output. An example is
An example command line would be:
$bwa mem \
-M \ // Mark shorter split hits as secondary (for Picard compatibility).
-t "$cpus" \ // number of threads
"$genome" \ // genome reference
"$fastq_r1" \ // R1
"$fastq_r2" \ // provide this line if you have R2
-R "@RG\tID:1\tLB:lib1\tPL:illumina\tSM:$sampleName\tPU:runBarcode" \
> "$sampleName".sam // Output
- bwa2 mem
Bwa-mem2 is the next version of the bwa-mem algorithm in bwa. It
produces alignment identical to bwa and is ~1.3-3.1x faster depending
on the use-case, dataset and the running machine.
The command line is exactly similar to the command line above, except that you would be using
As you have mentioned, you can completely overwrite (default mode) the read groups already existing by doing:
samtools addreplacerg \
-r "@RG\tID:1\tLB:lib1\tPL:illumina\tSM:$sampleName\tPU:runBarcode" \
-m overwrite_all \ // mode to replace all
-@ 5 \ // number of cpus
-O b \ // output bam
-o "$sampleName"_RG.bam \
- Picard AddOrReplaceReadGroups
java -jar $picard AddOrReplaceReadGroups \ // Also available in GATK tools