This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Filter variants in vcf file according to genotype of particular samples?

Hello

I have a multi-sample vcf file having data of eight samples. I want to exclude that variants which are homozygous in six of these samples. Please tell me if there is any way we can filter the variants in vcf file based on genotypes of particular samples. I am unable to find any such option in bcftools and vcftools.

Thank you

variant filtration genotype

3 answers

You can filter the SNPs based on their GT value. i.e if the GT is 0/1 then it is heterogous and if GT is 1/1 then it is homozygous. Thus you can just use simple grep command or VCF tool for fetching particular value. You can also refer similar biostar post

using vcffilterjdk: http://lindenb.github.io/jvarkit/VcfFilterJdk.html

  • 3 sample names: S1, S2,S3
  • convert to stream of name
  • convert each name to a genotype
  • check that all genotypes are HOM_REF
$ java -jar dist/vcffilterjdk.jar -e 'return Arrays.asList("S1","S2","S3").stream().map(S->variant.getGenotype(S)).allMatch(G->G.isHomRef());' src/test/resources/rotavirus_rf.vcf.gz

Hello arsala521,

you can filter with SnpSift. Especially have a look at the part "Available operands and functions".

fin swimmer

Log in to answer this question.