How to extract passed SNVs from a VCF file using bcftools?
2
0
Entering edit mode
23 months ago
addamyeo • 0

Hi! I just got started with bioinformatics, so I just barely got used to what a VCF file or bcftools is. But yeah I am trying to create a new VCF file that only consists of passed SNP/SNVs from a very large VCF file, using bcftools. Thanks!

vcf • 1.3k views
ADD COMMENT
0
Entering edit mode
23 months ago
Shred ★ 1.4k

For such a simple task there's no need for bcftools. Pure bash solution

grep "#" whole_snv.vcf > filtered_snv.vcf && grep -v '#' whole_snv.vcf | awk -F'\t' '{if ($7=="PASS") print $0}' >> filtered_snv.vcf

With bcftools:

bcftools view -f 'PASS' whole_snv.vcf

Please check if already asked on this forum, as this is a very common question. It was already answered here

ADD COMMENT
0
Entering edit mode
23 months ago

bcftools view --apply-filters 'PASS,.' --types 'snps' in.vcf

ADD COMMENT
0
Entering edit mode

So I'm actually trying to create a passed SNV file into its complements and intersections, so I tried doing:

bcftools isec -f 'PASS,.' --types 'snps' [file1.vcf.gz] [file2.vcf.gz] -p dir

But obviously, this is different than view. Is there are a way I can still filter out the passed SNVs using isec? Thanks!

ADD REPLY

Login before adding your answer.

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