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
• 5,475 views
•
link
3 answers
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
• 1 views
•
link
Log in to answer this question.
this post from bcftools github may help you: https://github.com/samtools/bcftools/issues/118