Generate a ggplot2 theme for Hi-C plots.
Usage
theme_hic(
hide_y = TRUE,
coord_ratio = 1,
scale_fill_gradientn = TRUE,
breaks = ggplot2::waiver(),
labels = scales::unit_format(unit = "M", scale = 1e-06),
xmin = NULL,
xmax = NULL,
expand_x = c(0, 0)
)
Arguments
- hide_y
A logical value indicating whether to hide the y-axis. Default is
TRUE
.- coord_ratio
The ratio of the ggplot2::coord_fixed. Default is
1
.- scale_fill_gradientn
A logical value indicating whether to apply the gradient color scale. Default is
TRUE
.- breaks
This argument is passed to ggplot2::scale_x_continuous.
- labels
This argument is passed to ggplot2::scale_x_continuous.
- xmin
The minimum x-axis value. Default is
NULL
.- xmax
The maximum x-axis value. Default is
NULL
.- expand_x
A numeric vector of length 2 to expand the x-axis. Default is
c(0, 0)
.
Examples
if (FALSE) { # \dontrun{
library(gghic)
library(ggplot2)
library(dplyr)
library(HiCExperiment)
library(InteractionSet)
library(scales)
library(glue)
library(rappdirs)
dir_cache_gghic <- user_cache_dir(appname = "gghic")
url_file <- paste0(
"https://raw.githubusercontent.com/mhjiang97/gghic-data/refs/heads/",
"master/cooler/chr4_11-5kb.cool"
)
path_file <- file.path(dir_cache_gghic, "chr4_11-5kb.cool")
download.file(url_file, path_file)
hic <- path_file |>
CoolFile() |>
import()
gis <- interactions(hic)
gis$score <- log10(gis$balanced)
x <- as_tibble(gis)
scores <- x$score[pairdist(gis) != 0 & !is.na(pairdist(gis) != 0)]
scores <- scores[!is.na(scores) & !is.infinite(scores)]
x$score <- oob_squish(x$score, c(min(scores), max(scores)))
x |>
filter(
seqnames1 == "chr11", seqnames2 == "chr11",
center1 > 67000000, center1 < 67100000,
center2 > 67000000, center2 < 67100000
) |>
ggplot(
aes(
seqnames1 = seqnames1, start1 = start1, end1 = end1,
seqnames2 = seqnames2, start2 = start2, end2 = end2,
fill = score
)
) +
geom_hic() +
theme_hic()
} # }