Hi, Is there a way to select only variants that exist in all samples?
Assume that I merged to VCF files, and I want to select variants that exist in both using bcftools.
bcftools view -i 'GT[0]!="./." && GT[1]!="./."' my.input.vcf.gz
This will do the work, but this way is not efficient if we have more than two samples, I tried:
bcftools view -i 'GT[*]!="./."'
But, it did not work.
The same task could be achieved using:
SnpSift.jar filter -f my.input.vcf.gz "( GEN[?].GT[?] != './.' )"
Any suggestions?
Thanks!!
Update
Using this code "( GEN[?].GT[?] != './.' ) & ( GEN[?].GT[?] != '0/0' )"
solved the difference between the answer method and the SnpSift method.
That worked! But, there are seven variants more in your case (I need to debug that).
i just select the variant where the number of hom-ref genotypes is 0 and the number of no-call genotypes is 0
Thank you for the clarificarion!