How to extract regions from abed file based on variants in vcf file
1
0
Entering edit mode
2.9 years ago
Kash ▴ 110

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.

vcf bed vcftools • 838 views
ADD COMMENT
0
Entering edit mode
2.9 years ago

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:

ADD COMMENT

Login before adding your answer.

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