Skip to content

Intersecting Loops

This code snippet shows how to intersect loops with intersect_bedpe in a Docker or Tinker environment.

We’ll start by assigning variables. First, our loops (called in Snippet: Calling Loops), then two .bed files, one containing CTCF sites and another with TSSs.

Terminal window
loops=my_loops.bedpe
TSS=$HOME/lab-data/hg38/reference/GENCODE_TSSs_hg38.bed
CTCF=$HOME/lab-data/hg38/reference/ENCODE3_cCRE-CTCF_hg38.bed

Our output will contain loops that have at least one anchor that intersects with either a TSS or a CTCF site.

To print the intersecting loops in your terminal, use:

Terminal window
intersect_bedpe --bedpe $loops --bed_A $TSS --bed_B $CTCF

To save the intersecting loops to a file, use:

Terminal window
intersect_bedpe --bedpe $loops --bed_A $TSS --bed_B $CTCF > TSS-CTCF-loops.bedpe

To visualize the changes, let’s view our loops before and after using intersect_bedpe with plot_contacts.

Before intersecting with TSSs and CTCF sites: visualizing_loops2

After intersecting with TSSs and CTCF sites: intersecting_loops2