Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • epigen
    Senior Member
    • May 2010
    • 101

    Bedtools intersectBed with vcf format

    Since I could not find any documentation on how Bedtools intersectBed works with vcf format, I'm posting my question here:

    I'm intersecting a vcf file from mpileup and bcftools with dbSNP132 that is in vcf format:

    intersectBed -a mutations_chr8.vcf -b dbSNP132_chr8.vcf -wao > mutations_chr8_dbSNP132.txt

    In my example below I expected to see only dbSNP entries that have the exactly same coordinates, ie.e chr8 112454855, but I also get hits for chr8 112454865 and chr8 112454876:

    Code:
    chr8	112454855	.	Tacacacacacacacacacacaca	TACacacacacacacacacacacaca	35.5	.	INDEL;DP=24;AF1=0.5;CI95=0.5,0.5;DP4=0,3,2,2;MQ=46;PV4=0.43,0.3,0.34,1	PL:GT:GQ	73,0,78:0/1:75	chr8	112454855	rs76365113	T	A	.	.	dbSNPBuildID=131;VP=050000000001070008000100;WGT=1;VC=SNP;VLD;G5A;G5;KGPilot1	1
    chr8	112454855	.	Tacacacacacacacacacacaca	TACacacacacacacacacacacaca	35.5	.	INDEL;DP=24;AF1=0.5;CI95=0.5,0.5;DP4=0,3,2,2;MQ=46;PV4=0.43,0.3,0.34,1	PL:GT:GQ	73,0,78:0/1:75	chr8	112454855	rs67322031	A	AAC	.	.	dbSNPBuildID=130;VP=050000000001000000000200;WGT=1;VC=INDEL	1
    chr8	112454855	.	Tacacacacacacacacacacaca	TACacacacacacacacacacacaca	35.5	.	INDEL;DP=24;AF1=0.5;CI95=0.5,0.5;DP4=0,3,2,2;MQ=46;PV4=0.43,0.3,0.34,1	PL:GT:GQ	73,0,78:0/1:75	chr8	112454855	rs71851070	TAC	T	.	.	dbSNPBuildID=130;VP=050000000001000000000200;WGT=1;VC=INDEL	3
    chr8	112454855	.	Tacacacacacacacacacacaca	TACacacacacacacacacacacaca	35.5	.	INDEL;DP=24;AF1=0.5;CI95=0.5,0.5;DP4=0,3,2,2;MQ=46;PV4=0.43,0.3,0.34,1	PL:GT:GQ	73,0,78:0/1:75	chr8	112454865	rs34424884	CAC	C	.	.	dbSNPBuildID=126;VP=050000000001000000000200;WGT=1;VC=INDEL	3
    chr8	112454855	.	Tacacacacacacacacacacaca	TACacacacacacacacacacacaca	35.5	.	INDEL;DP=24;AF1=0.5;CI95=0.5,0.5;DP4=0,3,2,2;MQ=46;PV4=0.43,0.3,0.34,1	PL:GT:GQ	73,0,78:0/1:75	chr8	112454876	rs36066513	ACA	A	.	.	dbSNPBuildID=126;VP=050100000001030100000200;WGT=1;VC=INDEL;SLO;G5A;G5;GNO	3
    This is correct and useful considering that indel coordinates are often a bit shifted. However, I'd like to how Bedtools determines the interval in which to look for the intersection. I guess it determines the length of the reference allele the -a file, but does it also do the same for the -b file? And how could I restrict the intersection to the exact position instead of the interval?

    Thanks in advance for any help - and for Bedtools in general

    Barbara
  • mpiro
    Member
    • Nov 2009
    • 10

    #2
    Hi Barbara

    If you generate a bed file from your VCF file you can define intervals for one base like this:

    Code:
    chr8	112454855 112454856 Tacacacacacacacacacacaca	TACacacacacacacacacacacaca	35.5	.	INDEL;DP=24;AF1=0.5;CI95=0.5,0.5;DP4=0,3,2,2;MQ=46;PV4=0.43,0.3,0.34,1	PL:GT:GQ	73,0,78:0/1:75
    Using shell this can be done by:

    Code:
    cat mutations_chr8.vcf | awk '{print $1"\t"$2"\t"$2+1"\t"$0}' | cut -f -3,6- > mutations_chr8.bed
    
    cat dbSNP132_chr8.vcf  | awk '{print $1"\t"$2"\t"$2+1"\t"$0}' | cut -f -3,6- > dbSNP132_chr8.bed
    Then using intersectBed will match exact position.

    Comment

    • jerryliu
      Junior Member
      • Aug 2008
      • 4

      #3
      Good trick. Just a minor correction, the VCF pos is 1-based and BED pos is 0-based, so the awk part should be:
      awk '{print $1"\t"$2-1"\t"$2"\t"$0}'

      Comment

      Latest Articles

      Collapse

      • SEQadmin2
        Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
        by SEQadmin2



        Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
        ...
        07-09-2026, 11:10 AM
      • SEQadmin2
        Cancer Drug Resistance: The Lingering Barrier to Rising Survival
        by SEQadmin2



        Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

        There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
        07-08-2026, 05:17 AM
      • GATTACAT
        Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
        by GATTACAT
        Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
        07-01-2026, 11:43 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, 07-13-2026, 10:26 AM
      0 responses
      20 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-09-2026, 10:04 AM
      0 responses
      30 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-08-2026, 10:08 AM
      0 responses
      18 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-07-2026, 11:05 AM
      0 responses
      34 views
      0 reactions
      Last Post SEQadmin2  
      Working...