Bedtools tutorial
Help 5 / 20
bedtools intersect

Find overlaps

By default, intersect reports intervals that represent overlaps between your two files. To demonstrate, let’s identify all of the CpG islands that overlap exons:

bedtools intersect -a cpg.bed -b exons.bed | head -n 5

The -wa (write A) and -wb (write B) options allow one to see the original records from the A and B files that overlapped.

As such, instead of not only showing you where the intersections occurred, it shows you what intersected.

bedtools intersect -a cpg.bed -b exons.bed -wa -wb | head -n 5
Loading...