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?
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?
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
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).
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Doesn't
bedtools intersect
work with VCF files?