How to extract regions from abed file based on variants in vcf file
Hi everyone,
I have a vcf file and a bed file which contains region information for some of the variants in vcf file. I want to extract the regions in the bed file which are corresponding to the variants in the vcf file. Can someone please tell me how I can do this? I know vcf tools can filter a vcf file using a bed file, but here I want to filter the bed file based on vcf file and out put the regions in bed file.
• 1,303 views
•
link
1 answer
One way, via bedops and vcf2bed:
$ bedops -e 1 <(sort-bed regions.bed) <(vcf2bed < variants.vcf) > answer.bed
If you want the associations between regions and SNPs, you could use bedmap:
$ bedmap --echo --echo-map --skip-unmapped --delim '\t' <(sort-bed regions.bed) <(vcf2bed < variants.vcf) > answer.bed
This prints each region and those variants which overlap a region. If a region does not contain any variants, --skip-unmapped skips over that region.
Reference:
• 0 views
•
link
Log in to answer this question.