loopQTL

loopQTL is an R package which identifies SNPs associated with chromatin interaction signals across samples. It provides a complete analysis workflow, including functions for annotation and visualization of results. It implements a band-wise joint normalization approach (referenced from Brant et al, Brief Bioinform, 2024) that systematically tests the association between variants and their anchored loops.

Package documentation and vignette

Acquiring and installing loopQTL

R 4.6 or a newer version is required.

On recent versions of Ubuntu, successful installation may require several additional packages. They can be installed by running the following command in a terminal:

sudo apt-get install r-base-dev libcurl4-openssl-dev libfreetype-dev libfribidi-dev libfontconfig-dev libharfbuzz-dev libtiff-dev libxml2-dev libssl-dev

No dependencies other than R are required on macOS or Windows.

Two versions of this package are available.

To install the stable version from Bioconductor, start R and run:

## Install BiocManager, which is required to install packages from Bioconductor
if (!requireNamespace("BiocManager", quietly = TRUE)) {
    install.packages("BiocManager")
}

BiocManager::install("loopQTL")

The development version containing the most recent updates is available from our GitHub repository. To install the development version from GitHub, start R and run:

## Install prerequisite packages to install the development version from GitHub
if (!requireNamespace("BiocManager", quietly = TRUE)) {
    install.packages("BiocManager")
}
if (!requireNamespace("remotes", quietly = TRUE)) {
    install.packages("remotes")
}

BiocManager::install(version = "devel")
BiocManager::install("rhielab/loopQTL")

Workflow overview

loopQTLsetup()      -> validate VCF + .hic headers, read loop BEDPEs, build the
                        exact-coordinate consensus loop set (loops kept when they
                        appear in >= minSamples samples). Optionally auto-computes
                        per-sample cis depth from .hic.
                        After running this step, the loopQTL S4 class object will be
                        set up along with the consensus loops set stored.

loopQTLnormalize()  -> per-chromosome whole-genome straw pull (parallel):
                        log-CPM depth correction + band-wise quantile
                        normalization across samples, adapted from Kipper et al, 2024.
                        After running this step, the normalized matrix will be saved
                        in obj@phenotype.

runQTL()            -> targeted tabix VCF read of anchor SNPs, then MatrixEQTL
                        once per anchor.
                        After running this step, the loopQTL results will be saved in obj@results.

A single loopQTL S4 object is threaded through all functions; sample order is an invariant so matrices always stay aligned.

Quick start

library(loopQTL)

samplesDF <- data.frame(
  Sample = c("S1", "S2", "S3"),
  hic    = c("S1.hic", "S2.hic", "S3.hic"),
  loops  = c("S1_loops.bedpe", "S2_loops.bedpe", "S3_loops.bedpe"),
  # optional: precomputed cis-contact totals; otherwise computed from .hic
  cis    = c(8.1e7, 7.4e7, 9.2e7),
  stringsAsFactors = FALSE
)

obj <- loopQTLsetup(
  samples     = samplesDF,
  vcf         = "cohort.vcf.gz",     # bgzipped + tabix-indexed
  resolution  = 10000,              # bp; must exist in every .hic
  minSamples = 2                   # consensus filter
)

obj <- loopQTLnormalize(
  obj,
  BPPARAM = BiocParallel::MulticoreParam(workers = 8)
)
## obj@phenotype now holds the pre-RINT normalized output (inspect for QC)

## By default runQTL() applies RINT per loop before regression (normal = TRUE)
## AND auto-picks K phenotype PCs via PCAForQTL as the regression covariates.
## You can also pass a fixed covariate matrix instead:
##   pcs <- loopQTLchooseK(obj, Kmethod = "BE")$PCs
##   obj <- runQTL(obj, window = 0, covariates = pcs)

obj <- runQTL(obj, window = 0, normal = TRUE)
head(obj@results)
##   loopID  snpID  chrom  pos  ref  alt  anchor  beta  se  t  p  nUsed  maf

Annotate results with target genes and enhancer peaks

loopQTLannotate() adds three columns to obj@results:

obj <- loopQTLannotate(
  obj,
  gtf             = "gencode.v43.gtf.gz",
  peak            = "H3K27ac_peaks.bed",   # optional
  peakAnnotation = "Enhancer"
)
head(obj@results[, c("snpID", "loopID", "anchor", "gene", "peak", "Type")])

Save per-SNP contact submatrices for SNP-correlation maps

Pass saveWindows = TRUE to loopQTLnormalize() to also save a .rds containing a samples × cells matrix of post-band-QN contact values around each in-loop SNP. Values are sliced from the per-chrom matrix that fills the phenotype, so no recomputation. This is a diagnostic/visualization output - it does not affect obj@phenotype or runQTL().

obj <- loopQTLnormalize(
  obj,
  saveWindows = TRUE,
  windowsOut  = "loop_snp_windows.rds",
  window       = 1000000,       # minimum window extent in bp
  snpWindow   = 0         # anchor flank for SNP selection
)

w <- readRDS("loop_snp_windows.rds")
## w$cells       : samples x N_cells numeric matrix (post-band-QN, pre-RINT)
## w$cellCoordinates : data.frame(chrom, binI, binJ) per column
## w$snpIndex   : data.frame(snpID, chrom, pos, ref, alt, binLo, binHi,
##                            n_loops_anchored, colIndices)  -- one row per SNP

Plot a heatmap for a single SNP

loopQTLplotSnpWindow() renders a Hi-C-style beta heatmap around any single SNP, matching the visualization style of Shi et al. 2025 (Genome Biology):

p <- loopQTLplotSnpWindow(
  obj, snpID = "rs123456",
  chrom  = "chr16",
  start  = 72410000, end = 73470000,   # crop to a region of interest
  normal = TRUE, covariates = "auto"   # match runQTL()'s partial-beta test
)
ggplot2::ggsave("rs123456_snp_window.pdf", p, width = 8, height = 8)