Select variants that exist in all samples from a merged VCF file using bcftools
1
0
Entering edit mode
3.0 years ago
Medhat 9.8k

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.

SNVs bcftools • 1.9k views
ADD COMMENT
1
Entering edit mode
3.0 years ago
bcftools view -i 'count(GT="RR")==0 && count(GT="mis")==0' 

?

ADD COMMENT
0
Entering edit mode

That worked! But, there are seven variants more in your case (I need to debug that).

ADD REPLY
0
Entering edit mode

i just select the variant where the number of hom-ref genotypes is 0 and the number of no-call genotypes is 0

ADD REPLY
0
Entering edit mode

Thank you for the clarificarion!

ADD REPLY

Login before adding your answer.

Traffic: 1943 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6