This is a test version of Biostars. For the public version, visit https://www.biostars.org.
filtering heterozygous genotypes

I have merged vcf file. I need to keep heterozygous genotypes with heterozygosity < 0.2.

How can I do through bcftools?

I found this command to remove heterozygous genotypes:

bcftools view -e 'GT="het"' merged_annotated_snps.vcf > merged_annotated_polymorphic_snps.vcf

How can I modify above command to retain genotypes with heterozygosity < 0.2 ?

Also my goal is to keep polymorphic alleles.

Thanks a lot

bcftools heterozygous

1 answer

How can I modify above command to retain genotypes with heterozygosity < 0.2 ?

you meant Allele Frequency ? if INFO/AF is defined

bcftools view -i 'AF>=0.2'  in.vcf

otherwise, set AF using bcftools +fill-tags

No i mean heterozygosity such as 'GT="het"'

Log in to answer this question.