This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How do I filter a multi-individual BCF file for genotype probabilities

I have BCFs with over a hundred individuals. I want to filter the files so that any genotype call with a max(GP) < 0.9 is removed. I don't want the whole site removed, I just want that individual genotype data removed for that site. I can't figure out how to do this without doing on each BCF individually.

Any suggestions?

vcf bcf

I don't want the whole site removed, I just want that individual genotype data removed for that site

it's not clear to me. Give us a short example of input/output.

I believe that when you say you want to remove genotype data, you mean that you want to make it missing. BCFtools filter can help you with that. You can try using this command (try using the latest version from Github):

bcftools filter -i 'FMT/GP>0.9' --set-GTs . <input BCF file> > <output BCF file>

This would include all genotypes that have a GP > 0.9 and covert others to missing. This rule is applied to all individuals. Furthermore, you could also try filtering based on Genotype quality (GQ) which is phred scaled.

This does not work.

bcftools filter -i 'FMT/GP[1-1699]>=0.9' --set-GTs . Seventh_imputations_1240K.vcf.gz still outputs problems like this 0|0:0.669,0.327,0.004

1 answer

bcftools +setGT test.vcf -- -t q -n . -e'FORMAT/GP>=0.90'

This should do what you need.

This does not.

I enter bcftools +setGT Seventh_imputations_1240K.vcf.gz -- -t q -n . -e'FORMAT/GP>=0.90'

I get Error: FORMAT vectors must be subscripted, e.g. GP[0] or GP[*]

Even if I subscript it [1-1699], I still find stuff like 0|0:0.53,0.373,0.097 and 1|0:0.107,0.891,0.002

Log in to answer this question.