This is a test version of Biostars. For the public version, visit https://www.biostars.org.
The GATK "The given bam input has no sample names." error
for f in MINIMAP BWA ;
do
    ~/gatk-4.2.0.0/gatk HaplotypeCaller --reference  /home/tmichel/projects/rbge/HybSeq_thibauld/reference_genomes/Begonia_loranthoides_scaffold.fasta --input  Hillebrandia_sorted.$f.bam  --output Hillebrandia.$f.g.vcf.gz --emit-ref-confidence GVCF ; 
done

I have used GATK to call variants in BAM files files with both minimap2 and bwa mem with the following script:

~/gatk-4.2.0.0/gatk HaplotypeCaller \
--reference  REF.fasta \
--input  INPUT.bam  \
--output OUTPUT.g.vcf.gz \
--emit-ref-confidence GVCF

But the following error popped:

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.

I have then check the samples names in my BAM file:

 ~/gatk-4.2.0.0/gatk GetSampleName \
        -I INPUT.bam

But the following error popped:

A USER ERROR has occurred: Bad input: The given bam input has no sample names.

It is a bit odd, as I have processed other samples through the PALEOMIX pipeline, using BWA as well for alignement, and never had this issue. Has anyone here experienced the same issue?

gatk bwa

1 answer

your bam is missing a 'SM' section in the read groups. This should have been specified when mapping with bwa. https://gatk.broadinstitute.org/hc/en-us/articles/360035890671-Read-groups

Thank you for the info! Very curious Minimap and BWA do not include this field as default in the sam file. I will try to find the options to do so.

You can also add the sample name with gatk with AddOrReplaceReadGroups

Thank you. For some reason, although the command is working, no name is detected using GetSampleName. I hope to find the proper option to name the sample while using BWA or Minimap to align the reads. Let me know if you are using them!

This thread --> Can't add read group correctly to minimap2 sam alignmnet shows you how to add read groups in minimap2 and bwa commands. The thread is about something else but just take a look at the original post for how to specify read groups with minimap2 and @h.mons comment to see how to do it for bwa,

Log in to answer this question.