This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bedtools intersect correct usage

Hello, I am trying to compare genome vcf file with bed file, to get out from genome file only these positions present in bed file

which syntax could be correct: bedtools intersect -a file.vcf -b file1.bed or bedtools intersect -a file1.bed -b file.vcf ?

I am confused, and also second variant seems to be correct, but is not working

genome
bcftools view --regions-file  file1.bed indexed.file.vcf.gz

Thank you! But now I got this:

Could not parse header line: ##VEP version: v101
Could not parse header line: ##dbSNP version: b154

this is not VCF file or a BED file. Show us the header of both files.

1 answer

Hello! It would be better if you use the parameter -wa, which can report the original overlap entry in file A.

bedtools intersect -a file.vcf -b file1.bed -wa > res.txt

This command will report the positions in file.vcf that are overlapped with file1.bed.

The following pic would show you how -wa works. (Source: bedtools official website)

bedtools intersect

Log in to answer this question.