How to remove regions from a vcf file ?
1
3
Entering edit mode
8.4 years ago
d0ct0r ▴ 30

I need to remove specific regions (in a bed file) from a vcf file. I am aware of the bcftools view options to filter regions. But It only subsets the regions. I need to do the opposite. I need to drop those regions from the vcf file. My solution is by subtracting the bed regions from vcf file regions using bedtools and then using the resulting bed file to filter the vcf file. But I think there will be some straightforward way to do it.

bed vcf vcftools genome bcftools • 8.8k views
ADD COMMENT
5
Entering edit mode
bedtools intersect -v -a file.vcf -b bed.vcf -wa > out.vcf


Are you looking for something like this? With this command, you'll get all the variants that do not overlap with the regions specified in the bed file.

ADD REPLY
0
Entering edit mode

What is -v option? It says unrecognized parameter

ADD REPLY
1
Entering edit mode

Sorry. My mistake. Try now the command. -v is the argument for printing all the vcf variants that DO NOT overlap with the given region, without -v, you'd get the overlapping variants.

ADD REPLY
0
Entering edit mode

intersectBed

ADD REPLY
0
Entering edit mode

this does not work for .vcf files, because they do not follow the chrom \t start \t stop table format

edit: nevermind, I realized you need to use bcftools view or query with a format expression that includes CHROM POS END to get the proper format to use with bedtools

ADD REPLY
0
Entering edit mode
8.4 years ago

Check out this post

ADD COMMENT

Login before adding your answer.

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