17  Lab 8: Investigating Hi-C contact maps

NoteAims
  • Compute the distance-dependent contact probability for a Hi-C contact map
  • Annotate chromatin loops and borders
  • Visualize Hi-C contact maps
  • Visualize Hi-C maps aggregated over structural features

17.1 Annotate chromatin loops and borders

We will use the chromosight software in the terminal to annotate chromatin loops and borders.

  • Check chromosight help to understand how to use it.
  • Annotate separately loops and borders from the Hi-C contact map in Share/HiC/HiC_G2M.coolusing chromosight detect with the --pattern option.
bash
chromosight detect --pattern loops Share/HiC/HiC_G2M.cool HiC_loops
chromosight detect --pattern borders Share/HiC/HiC_G2M.cool HiC_borders
  • Check the aggregated plots generated for loops and borders.
  • Check the content of the tsv files generated for loops and borders.

17.2 Compute a distance-dependent contact probability from a pairs file

We have a set of Hi-C pairs stored in the ~/Share/HiC/HiC.pairs file.

  • Use vroom package to import the file in R
  • Use plyinteractions to coerce the data frame into a GInteractions object
r
library(vroom)
library(plyinteractions)
df <- vroom("~/Share/HiC/HiC_filtered.pairs", col_names = c("readid", "seqnames1", "start1", "seqnames2", "start2", "strand1", "strand2", "pair_type"), comment = "#")
gi <- as_ginteractions(df, end1 = start1, end2 = start2)
  • Compute the pairdist distance between each anchor of every interaction in the GInteractions object.
  • Tally the number of interactions at each distance, and convert it to a probability by dividing the number of interactions at each distance by the total number of interactions.
  • Plot the distance-dependent contact probability as a function of distance, using HiContacts::plotPs.
r
library(tidyverse)
gi <- add_pairdist(gi)
df <- as_tibble(gi) |> 
    mutate(strands = paste0(strand1, strand2)) |>
    group_by(strands, pairdist) |>
    tally() |> 
    mutate(prob = n / sum(n))

p <- ggplot(df, aes(x = pairdist, y = prob, color = strands)) +
    geom_smooth() +
    scale_x_log10(limits = c(100, NA)) +
    scale_y_log10() + 
    theme_bw()

17.3 Visualize Hi-C contact maps

We will use the HiContacts package in R to visualize Hi-C contact maps.

  • Create a pointer to the Share/HiC/HiC_G2M.cool file in R.
  • Check the available chromosomes and resolutions stored in the cool file.
  • Import data over the 4th chromosome.
  • Use the plotContactMap function to visualize the Hi-C contact map.
r
library(HiContacts)
cf <- CoolFile("Share/HiC/HiC_G2M.cool")
availableChromosomes(cf)
availableResolutions(cf)
hic <- import(cf, focus = 'IV')
plotMatrix(hic)
Back to top