gstacks Error: No BAM records.

184 views
Skip to first unread message

María Camila Latorre

unread,
Jun 30, 2023, 2:10:16 AM6/30/23
to Stacks
Hello everyone, 

I am trying to run the gstacks with the following command line:
gstacks -I /home/.mlatorre/bioinfo/aligned_stacks -O /home/.mlatorre/bioinfo/stacks -M /home/.mlatorre/bioinfo/aligned_stacks/popmap_qc.txt  --rm-pcr-duplicates  -t 28

and I got this output: 
Logging to '/home/.mlatorre/bioinfo/aligned_stacks/gstacks.log'.
Locus/sample distributions will be written to '/home/.mlatorre/bioinfo/aligned_stacks/gstacks.log.distribs'.

Configuration for this run:
  Input mode: reference-based
  Population map: '/home/.mlatorre/bioinfo/aligned_stacks/popmap_qc.txt'
  Input files: 165, e.g. '/home/.mlatorre/bioinfo/aligned_stacks/AZU1.bam'
  Output to: '/home/.mlatorre/bioinfo/aligned_stacks/'
  Model: marukilow (var_alpha: 0.01, gt_alpha: 0.05)
  Discarding unpaired reads.
  Removing PCR duplicates.

Reading BAM headers...
Processing all loci...
Error: No BAM records.
Error: (At the 0th record in file '/home/.mlatorre/bioinfo/aligned_stacks/Qcas5_3_10.bam'.)
Aborted.

I thought that the bam files could be corrupted, so I run the following command to check any possible error: 

picard ValidateSamFile I=Qcas5_3_10.bam MODE=SUMMARY

The output indicates that files have no errors:

[Thu Jun 29 23:41:39 CST 2023] picard.sam.ValidateSamFile INPUT=Qcas5_3_10.bam MODE=SUMMARY    MAX_OUTPUT=100 IGNORE_WARNINGS=false VALIDATE_INDEX=true IS_BISULFITE_SEQUENCED=false MAX_OPEN_TEMP_FILES=8000 VERBOSITY=INFO QUIET=false VALIDATION_STRINGENCY=STRICT COMPRESSION_LEVEL=5 MAX_RECORDS_IN_RAM=500000 CREATE_INDEX=false CREATE_MD5_FILE=false GA4GH_CLIENT_SECRETS=client_secrets.json
[Thu Jun 29 23:41:39 CST 2023] Executing as ..... on Linux 5.15.0-58-generic amd64; OpenJDK 64-Bit Server VM 17.0.7+4-jvmci-23.0-b10; Picard version: 1.141(8ece590411350163e7689e9e77aab8efcb622170_1447695087) IntelDeflater
No errors found

I do not know what is wrong with this. Does anyone have an idea or a suggestion for checking bam files?

PD: data are GBS paired-end and were aligned to a reference genome in bwa mem and then converted to bam file and sorted using samtools.

Thank you in advance

María Camila 

Heather Lounder

unread,
Jul 12, 2023, 3:57:40 PM7/12/23
to Stacks
Hi Maria, 

I am wondering if you figured this out? I seem to be experiencing the same issue. I tried re-aligning, filtering, and sorting my files, but continue to get the same error message. 

Thank you!

Heather 

Catchen, Julian

unread,
Jul 12, 2023, 5:23:57 PM7/12/23
to stacks...@googlegroups.com

Hi Heather,

 

What does “samtools flagstat” report for a few of your samples? What do the BAM file alignments look like? What was your BWA command for a few of your files?

 

julian

Heather Lounder

unread,
Jul 13, 2023, 11:17:29 AM7/13/23
to Stacks
Hi Julian, 

Thanks for the quick reply! I have attached the samtools flagstat output for a few of my samples, as well as the script I used to align them in BWA. Also attached is what the headers for my unsorted, aligned files look like. The alignment script I am using is the same I used for my Batch 1 data, and I had no issues running it through ref_map.pl afterwards, so I don't quite understand whats going on here?

I notice the log file seems to have an issue with the files containing "_B2" in their title specifically. These are replicate files from my first batch of data, and I changed the sample names after alignment and sorting, so maybe that is the cause of the issue? I am trying to run a version now that skips over these files to see if that works. 

 Apologies if it is a simple solution - I am still learning!

Cheers, 
Heather

Screen Shot 2023-07-13 at 10.45.04 AM.png

flagstat_output.txt
B2_run_BWA (1).sh

Heather Lounder

unread,
Jul 13, 2023, 4:30:29 PM7/13/23
to Stacks
Looks like I was right! Removing those samples resulting in the script running just fine. I guess Stacks just wasn't too happy that I had changed the file names. 

rama sarvani

unread,
Sep 25, 2024, 9:26:11 AM9/25/24
to Stacks
Hello,

I have similar issue saying there were no bam records found, and after some troubleshooting, I figured out the cause saying that there were no read groups. I have read in previous comments that using Picard I can attach the read groups to the aligned bam files but is there a better way to do this so i can streamline the analysis before hand?

Regards,
Rama
Reply all
Reply to author
Forward
0 new messages