Command to extract SNPs from VCF file using bcftool
1
1
Entering edit mode
8.6 years ago
MAPK ★ 2.1k

I have a bed file called my.bed with CHROM, START, and END Position. Can someone please explain me how I can use bcftools or command to extract the regions from myvcf.vcf file?

SNPs bcftools VCF • 18k views
ADD COMMENT
3
Entering edit mode

Doesn't bedtools intersect work with VCF files?

ADD REPLY
8
Entering edit mode
8.6 years ago

my preferred option when dealing with vcf files is bcftools, which requires vcf indexing:

tabix -p vcf my.vcf
bcftools view -R my.bed my.vcf.gz

another perfectly valid alternative, as Devon has just pointed out, would be bedtools intersect:

bedtools intersect -a my.vcf -b my.bed
ADD COMMENT
0
Entering edit mode

get this error with bcftools:

`view: invalid option -- 'R'
[bcf_sync] incorrect number of fields (0 != 5) at 0:0
ADD REPLY
1
Entering edit mode

that's strange. it looks like it's asking you for better formed bed file (chr, start, end, value, strand), but I constantly use the --regions-file option with single positions (chr, pos) or regions (chr, start, end) as explained here. maybe you could be using an old bcftools version? I'm using 1.3 (1.3.1 has just been released).

ADD REPLY

Login before adding your answer.

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