Skip to content

bcftools merge error: could not load index #1360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NadyaMamoozadeh opened this issue Dec 14, 2020 · 2 comments
Closed

bcftools merge error: could not load index #1360

NadyaMamoozadeh opened this issue Dec 14, 2020 · 2 comments

Comments

@NadyaMamoozadeh
Copy link

Hi there,

I've run into an issue with the bcftools merge utility and am hoping for feedback on how to resolve. I'm not sure whether it is user error or a bug in the program.

I have three VCF files for a non-model species that I'd like to merge into a single VCF file. Each file corresponds with a unique set of individuals and a subset of SNPs that is overlapping among files.

I first compress my VCF files in bgzip format with
bgzip -ci infileA.vcf > outfileA.vcf.gz

I next attempt to merge the files with
bcftools merge outfileA.vcf.gz outfileB.vcf.gz outfileC.vcf.gz

But I get an error message that the index files cannot be found, even though they are in the same directory: Failed to open outfileA.vcf.gz: could not load index

I've seen posts elsewhere that discuss this error message when attempting to use other tools in bcftools...some of these posts describe the issue as resulting from the system attempting to open too many files at once. But the system I am working on allows over 4,000 files to be open at once, and either way I am working with only six files (including the compressed VCF files and index files).

When I check the format of my files with htsfile I get the following:

htsfile outfileA.vcf.gz
outfileA.vcf.gz: VCF version 4.2 BGZF-compressed variant calling data

htsfile outfileA.vcf.gz.gzi
outfileA.vcf.gz.gzi: unknown data

Are the index files created via bgzip inappropriate for use with bcftools merge? Thanks!

@pd3
Copy link
Member

pd3 commented Dec 15, 2020

The correct way is:

bcftools -Oz -o out.vcf.gz in.vcf
bcftools index out.vcf.gz
bcftools merge ...

@NadyaMamoozadeh
Copy link
Author

Thanks for your help @pd3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants