filter VCF based on FORMAT
0
1
Entering edit mode
20 months ago
Matteo Ungaro ▴ 100

Hi there I have a VCF file generated by hap.py I need to first generate two files for SNPs and INDELs, respectively which I have done with the following commands:

bcftools view -V indels -l 9 -Oz -o eval_indels.vcf.gz eval.vcf.gz

to retain SNPs only, and

bcftools view -V snps -l 9 -Oz -o eval_indels.vcf.gz eval.vcf.gz

to retain INDELs only.

What I need to do next is to generate two files for each variant type (four in total) containing the FPs calls and the FNs calls only. Now, these are FORMAT values and the way I'm doing it is as follow (example for INDELs):

bcftools view -e 'BD="FN" && BD="TP" && BD="TN"' -l 9 -Oz -o eval_indelsFP.vcf.gz eval_indels.vcf.gz

to exclude everything but FPs values, and

bcftools view -e 'BD="FP" && BD="TP" && BD="TN"' -l 9 -Oz -o eval_indelsFN.vcf.gz eval_indels.vcf.gz

to exclude everything but FNs values. However, for some reason, I'm getting wrong output results where other classes of calls are still present. If helpful, I can attach an image of what eval_indels.vcf.gz looks like. Thanks in advance!

vcf bcftools • 811 views
ADD COMMENT
1
Entering edit mode

It would be helpful to see the first few lines of your VCF file. However, the following might work:

bcftools filter -i FORMAT/BD="FP" -o new.vcf.gz eval_indels.vcf.gz
ADD REPLY
0
Entering edit mode

If I understand well what you're trying to do, I would use the || operator instead of the &&

ADD REPLY

Login before adding your answer.

Traffic: 1551 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