This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Add or reveal read groups on .sam file aligned by BWA

Hi, I'm trying to use GATK HaplotypeCaller but everytime I run its says

A USER ERROR has occurred: Argument emit-ref-confidence has a bad value: Can only be used in single sample mode currently. Use the --sample-name argument to run on a single sample out of a multi-sample BAM file.

According to what I searched, it is because there are multiple reads on my .bam file even though it is not. Mu procedure to generate .bam file is:

  • Use fastp to trim adapters and low-quality single-ended MGI DNB Sequencing on fastp file
  • Use bwa mem to align, command is bwa mem -t 8 {ref file} {fastq file} | grep -e "@RG" -e "@SQ" -e "@PQ" -e "@NM:i:0" > out.sam
  • Then I convert it to .bam file and sort by using command samtools view -@ 4 -q 20 -bS -T {ref file} out.sam | samtools sort -@ 8 > sort.bam
  • And then I run gatk followed by procedure in gatk website gatk HaplotypeCaller -R {ref file} -I temp/sort.bam -O output.g.vcf.gz -ERC GVCF and its returned with the error notes above.

When I try to identify read groups on .bam file by using command samtools view -@ 8 -H sort.bam | grep "@RG" it returned with no results. Is there any way to add read groups or make read groups appeared. I just new to NGS, I have tried to search for many solutions but I cannot understand them. Please help me, thank you very much

gatk haplotypecaller

1 answer

Your command was not quite the right way to add read groups, the whole grepping on the bwa output makes little sense, you are altering a SAM file while it is being created. Don't do that in the future!

Luckily you can add read groups later with

samtools addreplacerg

check the manual:

Log in to answer this question.