#' Display a part of a Hi-C matrix
#'
#' @name GENOVA_image
#' @param x A \code{contacts_matrix} object, as returned by
#' \code{\link[GENOVA]{select_subset}()}.
#' @param col a list of colors such as that generated by
#' \code{\link[grDevices]{hcl.colors}}, \code{\link[grDevices]{gray.colors}}
#' or similar functions. Defaults to GENOVA palette.
#' @param zlim the minimum and maximum z values for which colors should be
#' plotted, defaulting to the range of finite values of off-diagonal elements
#' of \code{x}.
#' @param xlab,ylab each a character string giving the labels for the x and y
#' axis. Default is to use the chromosome name as axis title.
#' @inheritDotParams graphics::image.default -y -z
#' @export
#'
#' @examples
#' \dontrun{
#' x <- select_subset(exp, "chr1", 50e6, 60e6)
#' image(x)
#' }
image.contacts_matrix <- function(
x,
col = NULL, zlim = NULL,
xlab = NULL, ylab = NULL,
...
) {
if (is.null(col)) {
col <- .choose_palette()
col <- colorRampPalette(col)
col <- col(255)
}
if (is.null(zlim)) {
zlim <- x$z
diag(zlim) <- 0
zlim <- range(zlim)
diag(x$z) <- zlim[2]
}
if (is.null(xlab)) {
xlab <- paste0(attr(x, "chrom"), " (Mb)")
x$x <- x$x / 1e6
}
if (is.null(ylab)) {
ylab <- paste0(attr(x, "chrom"), " (Mb)")
x$y <- x$y / 1e6
}
image.default(x = x$x, y = x$y, z = x$z,
zlim = zlim, xlab = xlab, ylab = ylab,
col = col, ...)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.