This function creates a Hi-C contact matrix visualization from various input types. It provides a high-level interface supporting both square heatmap and triangle (rotated) views commonly used in genome browsers.
Arguments
- data
Input data. Can be:
A matrix: Dense contact matrix
A data frame: Sparse format with (pos1, pos2, score) or (bin1, bin2, score)
A file path: Tab-delimited matrix file
- region
Genomic region to display (e.g., "chr1:1000000-2000000")
- resolution
Resolution of the Hi-C data in base pairs (default: 10000)
- style
Visualization style: "triangle" (default, rotated view) or "square"
- palette
Color palette: "cooler" (red, default), "ylgnbu", "viridis", or "bwr"
- trans
Scale transformation: "identity" (linear), "log10" (default), "log2", "sqrt"
- limits
Numeric vector of length 2 for color scale limits (default: NULL, auto)
- max_distance
Maximum interaction distance to show in base pairs (default: NULL, show all). Only applies to triangle style.
- rasterize
Logical. If TRUE and ggrastr package is available, rasterize the plot for better performance with large matrices. Default: FALSE
- show_diagonal
Logical. If TRUE, show the diagonal (self-interactions). Default: TRUE
- ...
Additional arguments passed to geom_hic or geom_hic_triangle
Examples
if (FALSE) { # \dontrun{
# Create example data
mat <- matrix(runif(2500), nrow = 50)
mat <- mat + t(mat) # Make symmetric
diag(mat) <- diag(mat) * 2 # Stronger diagonal
# Triangle view (default)
ez_hic(mat, "chr1:1000000-1500000", resolution = 10000)
# Square heatmap view
ez_hic(mat, "chr1:1000000-1500000", resolution = 10000, style = "square")
# With log10 transformation and custom palette
ez_hic(mat, "chr1:1000000-1500000",
resolution = 10000,
trans = "log10",
palette = "ylgnbu"
)
# Limit maximum distance shown
ez_hic(mat, "chr1:1000000-1500000",
resolution = 10000,
max_distance = 200000
)
} # }