This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Finding shared genotypes between multiple VCF files

I have several VCF files generated from WES. Some share a condition, and others could be considered controls. I want to know which SNPs are shared between the files with the condition, and not in the controls. By "shared" I mean for a given SNP, I want to know whether they share the same genotype at that location. Many of the tools that I have tried, like bcftools isec seem to intersect by position, not by the actual genotype. Other tools like bcftools stats seem to only compare 2 files at once. Is there any way to do this for multiple files at once?

vcf snp exome

1 answer

merge your VCF files with bcftools merge and the select the variants with vcffilterjdk http://lindenb.github.io/jvarkit/VcfFilterJdk.html

e.g:

java -jar vcffilterjdk.jar -e 'return variant.getGenotype("sample1").sameGenotype(variant.getGenotype("sample2")) && variant.getGenotype("sample2").sameGenotype(variant.getGenotype("sample3"));'

Log in to answer this question.