This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Merging vcf files with bcftools ([E::get_intv] Failed to parse TBX_VCF, was wrong -p [type] used?)

Hello,

I am trying to using bcftools to combine 2 VCF files (in the folder there are the two .tbi files) with following command:

 bcftools merge -m snps -O v -o merged.vcf a.vcf.gz b.vcf.gz

but got these error :

[E::get_intv] Failed to parse TBX_VCF, was wrong -p [type] used? 
The offending line was: "##contig=<ID=2,length=242193529>" 
[E::get_intv] Failed to parse TBX_VCF, was wrong -p [type] used? 
The offending line was: "##contig=<ID=3,length=198295559>"
[E::get_intv] Failed to parse TBX_VCF, was wrong -p [type] used? 
The offending line was: "##contig=<ID=4,length=190214555>"

I don't know what this means and how to solve the problem. Can anybody help me? Thank you in advance.

vcf tabix bcftools

1 answer

The vcf where indexed with tabix the wrong way. index your VCF using:

bcftools index -f a.vcf.gz
bcftools index -f b.vcf.gz

Thank you! That was helpful, and I didn't encounter any issues with the command:

bcftools merge -m snps -O v -o merged.vcf a.vcf.gz b.vcf.gz

However, when merging two VCFs—one with 2000 SNPs and the other with 1200— I ended up with a merged VCF containing only 1100 SNPs. Ideally, I'd like to generate a VCF with 2000 SNPs or more, with all the variants in the two vcfs.

your command crashed or you have duplicates in your vcfs

Log in to answer this question.