This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to filter INFO on a vcf file with bcftools

Hello,

I want to filter a vcf file by eliminating all the SNPs which have INFO <= 0.4.

In the shell, I therefore enter the following command : bcftools filter -e 'INFO<=0.4' myfile.vcf.gz The command runs for a veeeeeeery long time and, at the end, the file remains exactly the same. I have the feeling that it just reads all my file but nothing is filtered.

How could I modify my command to get a real filtering ? Thanks for any help.

bcftools vcf info imputation

what is the definition in the header of this 'INFO' field ?

bcftools view --header-only input.vcf | grep "ID=INFO"

I get this :

INFO=<ID=INFO,Number=1,Type=Float,Description="IMPUTE2 info score">

I have paste the response as I got it. But clearly it is uppercase because if I try to enter the command with 'info', I get : Error: the tag "info" is not defined in the VCF header.

Question! After getting vcf files back from the Michigan server, I noticed I don't have any 'ID=INFO' within my header (running your command above outputs nothing). Would you know the reason why this happens/a way around it?

Hi,

I am trying to filter all SVTYPE=BND variants and this is what i tried

bcftools query -i SVTYPE!="BND" wgs_HG001-lumpy.vcf.gz -f "%CHROM\t%POS0\t%END\t%SVTYPE\n" wgs_HG001-lumpy.vcf.gz >nobnd_wgs_HG001-lumpy.vcf.gz
[filter.c:1379 filters_init1] Error: the tag "INFO/BND" is not defined in the VCF header.

I could do it through grep -v but I am seeing if I could use bcftools

Please do not add answers unless they actually do answer the question. Just in case, try surrounding your expression in quotes: -i 'SVTYPE!="BND"'. Also, if SVTYPE is an INFO field, use -i 'INFO/SVTYPE!="BND"'.

1 answer

bcftools filter -e 'INFO/info<=0.4' myfile.vcf.gz

Question! After getting vcf files back from the Michigan server, I noticed I don't have an 'INFO/info' value. Checking within my headers, this command:

bcftools view --header-only input.vcf | grep "ID=INFO"

Doesn't produce anything. Would you know the reason why this happens/a way around it?

It could be because the info is in lower case. Try grep "ID=info"

I thought the same a while ago but nothing was outputted. Additionally, using

bcftools query - f 'INFO \n'

Didn't bring about the 'info' value/field. I created a separate post about it if you happen to know why/want a further explanation.

Log in to answer this question.