Learn R Programming

Make Enriched Heatmaps

Enriched heatmap is a special type of heatmap which visualizes the enrichment of genomic signals on specific target regions. It is broadly used to visualize e.g. how histone marks are enriched to specific sites.

There are several tools that can make such heatmap (e.g. ngs.plot or deepTools). Here we implement Enriched heatmap by ComplexHeatmap package. Since this type of heatmap is just a normal heatmap but with some fixed settings, with the functionality of ComplexHeatmap, it would be much easier to customize the heatmap as well as concatenating a list of heatmaps to show correspondance between differnet data sources.

Install

EnrichedHeatmap is available on Bioconductor, you can install it by:

source("http://bioconductor.org/biocLite.R")
biocLite("EnrichedHeatmap") 

If you want the latest version, install it directly from GitHub:

library(devtools)
install_github("jokergoo/EnrichedHeatmap")

Example

Like other tools, the task involves two steps:

  1. Normalize the accosiations between genomic signals and target regions to a matrix.
  2. Draw heatmaps.
mat1 = normalizeToMatrix(H3K4me3, tss, value_column = "coverage", 
    extend = 5000, mean_mode = "w0", w = 50)
mat2 = normalizeToMatrix(meth, tss, value_column = "meth", mean_mode = "absolute",
    extend = 5000, w = 50, empty_value = NA, smooth = TRUE)
partition = kmeans(mat1, centers = 3)$cluster
lgd = Legend(at = c("cluster1", "cluster2", "cluster3"), title = "Clusters", 
    type = "lines", legend_gp = gpar(col = 2:4))
ht_list = Heatmap(partition, col = structure(2:4, names = as.character(1:3)), name = "partition",
              show_row_names = FALSE, width = unit(3, "mm")) +
          EnrichedHeatmap(mat1, col = c("white", "red"), name = "H3K4me3", split = partition, width = 1,
              top_annotation = HeatmapAnnotation(lines = anno_enriched(gp = gpar(col = 2:4))), 
              top_annotation_height = unit(2, "cm"), row_title_rot = 0,
              column_title = "H3K4me3", combined_name_fun = NULL) + 
          EnrichedHeatmap(mat2, name = "methylation", width = 1,
              top_annotation = HeatmapAnnotation(lines = anno_enriched(gp = gpar(col = 2:4))), 
              top_annotation_height = unit(2, "cm"),
              column_title = "Methylation") +
          Heatmap(log2(rpkm+1), col = c("white", "orange"), name = "log2(rpkm+1)", 
              show_row_names = FALSE, width = unit(5, "mm"))
draw(ht_list, main_heatmap = "H3K4me3", gap = unit(c(2, 10, 2), "mm"))

Actually you can generate rather complex heatmaps:

License

GPL (>= 2)

Copy Link

Version

Version

1.2.2

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Zuguang Gu

Last Published

April 26th, 2016

Functions in EnrichedHeatmap (1.2.2)

anno_enriched

Annotation function to show the enrichment
EnrichedHeatmap

Constructor method for EnrichedHeatmap class
EnrichedHeatmapList-class

Class for a list of heatmaps
show-EnrichedHeatmapList-method

Draw a list of heatmaps with default parameters
draw-dispatch

Method dispatch page for draw
[.normalizedMatrix

Subset normalized matrix by rows
default_smooth_fun

Default smooth function
draw-EnrichedHeatmap-method

Draw a single heatmap
copyAttr

Copy attributes to another object
normalizeToMatrix

Normalize associations between genomic signals and target regions into a matrix
EnrichedHeatmapList

Constructor method for EnrichedHeatmapList class
enriched_score

Enriched scores
+.AdditiveUnit

Add heatmaps or row annotations to a heatmap list
draw-EnrichedHeatmapList-method

Draw a list of heatmaps
getSignalsFromList

Get signals from a list
makeWindows

Split regions into windows
EnrichedHeatmap-class

Class for a single heatmap
show-EnrichedHeatmap-method

Draw the single heatmap with default parameters
show-dispatch

Method dispatch page for show
print.normalizedMatrix

Print normalized matrix