This is a test version of Biostars. For the public version, visit https://www.biostars.org.
merge vcf.gz file

I have vcf.gz file I am trying to merge with bcftools . when I am using the command line it works

bcftools index -f file 1 
bcftools index -f file 2 
bcftools merge file1  file2  > out.vcf

I get the following error when I call the commands from R or Python: the file is not BGZF compressed

The files are gzip-compressed variants. Why it's working only through the command line?

bcftools

"file 1 " , with a space, cannot be a real argument. show us the real filenames please, and the error messages.

file1 = '/sci/labs/orzuk/orzuk/projects/Skin/data/Ichilov/vcfFiles/vcfFiles/eb3_1001_748-gatk-haplotype.final.vcf.gz'
file2 = '/sci/labs/orzuk/orzuk/projects/Skin/data/Ichilov/vcfFiles/vcfFiles/g15_02001_785-gatk-haplotype.final.vcf.gz'
merged_vcf =  '/sci/home/mali.tsadok/merged.vcf'
bcftools_cmd = ["bcftools" , "index" ,"-f" ,file1 ]
proc = subprocess.run(bcftools_cmd)
bcftools_cmd = ["bcftools" , "index" ,"-f" ,file2 ]
proc = subprocess.run(bcftools_cmd)
bcftools_cmd = ["bcftools", "merge" ,file1,file2 ,  "-o", merged_vcf]
proc = subprocess.run(bcftools_cmd)


Failed to open /sci/labs/orzuk/orzuk/projects/Skin/data/Ichilov/vcfFiles/vcfFiles/eb3_1001_748-gatk-haplotype.final.vcf.gz: not compressed with bgzip

1 answer

You must compress with bgzip.

gzip -d your.vcf.gz
bgzip your.vcf

Log in to answer this question.