How to remove regions from a vcf file ?
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.
• 10,844 views
•
link
1 answer
Log in to answer this question.
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.
What is
-voption? It says unrecognized parameterintersectBed
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.
this does not work for .vcf files, because they do not follow the
chrom \t start \t stoptable formatedit: nevermind, I realized you need to use
bcftools vieworquerywith a format expression that includesCHROM POS ENDto get the proper format to use with bedtools