Intersecting vcf files with bedtools
2
0
Entering edit mode
7.8 years ago
Maj • 0

Hello,

I want to intersect two vcf files :

File 1 :

CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT  7.bam

Scaffold_1        223     .       G       T       10.8428 . DP=7;DPR=5,2;VDB=0.18;SGB=-0.453602;RPB=0.8;MQB=1;MQSB=1;BQB=0.9;MQ0F=0;ICB=1;HOB=0.5;AC=1;AN=2;DP4=5,0,0,2;MQ=60 GT:PL:DP:DV:SP:DP4:DPR   0/1:44,0,110:7:2:13:5,0,0,2:5,2

Scaffold_1        435     .       T       C       20.145  .       DP=3;DPR=1,2;VDB=0.1;SGB=-0.453602;RPB=1;MQB=1;MQSB=1;BQB=1;MQ0F=0;ICB=1;HOB=0.5;AC=1;AN=2;DP4=0,1,2,0;MQ=60    GT:PL:DP:DV:SP:DP4:DPR     0/1:53,0,30:3:2:0:0,1,2,0:1,2

File 2 : 

CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT  S07

scaffold_11       651457  929888  G       T       .       PASS    Ty=SNP;Rk=1;UL=.;UR=.;CL=.;CR=.;Genome=C;Sd=1   GT:DP:PL:AD:HQ  0/0:4:4,16,84:4,0:70,0

scaffold_1188     2186    894758  T       G       .       PASS    Ty=SNP;Rk=1;UL=.;UR=.;CL=.;CR=.;Genome=T;Sd=1   GT:DP:PL:AD:HQ  1/1:4:84,16,4:0,4:0,70

This is the error :

bedtools intersect -a 7.variant_snp.vcf -b 7.variant_snp2.vcf | head

ERROR: file 7.variant_snp.vcf has non positional records, which are only valid for the groupBy tool.

I don't know how to deal with this issue. Does anyone have experience of this kind of error?

Thanks in advance

bedtools vcf intersectbed • 6.0k views
ADD COMMENT
0
Entering edit mode

might be worth simply parsing the "VCF" files into a BED format? Should be able to just include the POS field twice to stand in for the Start & Stop positions.

ADD REPLY
0
Entering edit mode
7.8 years ago
Manvendra Singh ★ 2.2k

First may be you get rid of headers As per I remember, I always used one vcf and one bed file to intersect by bedtools

May be you use vcftools to intersect two vcf files

It has nice command as "vcf-isec" Creates intersections and complements of two or more VCF files Nice documentation is here

ADD COMMENT
0
Entering edit mode

Thank you :) I tried it but now i have a new error "The command "tabix" not found, please add it to your PATH" I'm trying to fix it. Thank you again

ADD REPLY
0
Entering edit mode
7.7 years ago

The examples you show do not match the VCF format specs. The header line (beginning with 'CHROM') should be preceded by a hash '#'. Otherwise, 'POS' is read as a value that should be an integer but is not (i.e., non-positional).

ADD COMMENT
0
Entering edit mode

Also, bedtools 'intersect' does not output headers by default, and using the output for subsequent 'intersect' operations can produce errors. You can include by using the '-header' flag.

ADD REPLY

Login before adding your answer.

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