This is a test version of Biostars. For the public version, visit https://www.biostars.org.
View specific chromosome in vcf file

I am trying to extract a single chromosome from a vcf file, using this bcftools command

bcftools view inputfile.vcf.gz --regions chr1

and I get this error: 'Failed to read from inputfile.vcf.gz could not load index'

I thought this would be very straightforward, what am I missing? Thanks!

filtering vcf

1 answer

inputfile.vcf.gz must be indexed

bcftools index inputfile.vcf.gz

I did this once before without indexing but I may have used vcftools instead of bcftools, should there be a difference?

Either way, will run this index command and output a new file, then run the command I mentioned above? thanks

I may have used vcftools instead of bcftools

vcftools is deprecated . Use bcftools

will run this index command and output a new file

bcftools will create an associated file 'inputfile.vcf.gz.csi' (the index) next to inputfile.vcf.gz

When a suggestion is given, please try it instead of asking "Will your suggestion solve my problem?". Try it, and if it does not solve your problem, come back with what you tried and how you think it failed.

Log in to answer this question.