Last data update: 2014.03.03

R: Draw a list of heatmaps
draw-HeatmapList-methodR Documentation

Draw a list of heatmaps

Description

Draw a list of heatmaps

Usage

## S4 method for signature 'HeatmapList'
draw(object,
    padding = unit(c(2, 2, 2, 2), "mm"),
    newpage = TRUE,
    row_title = character(0),
    row_title_side = c("left", "right"),
    row_title_gp = gpar(fontsize = 14),
    column_title = character(0),
    column_title_side = c("top", "bottom"),
    column_title_gp = gpar(fontsize = 14),
    heatmap_legend_side = c("right", "left", "bottom", "top"),
    show_heatmap_legend = TRUE,
    heatmap_legend_list = list(),
    annotation_legend_side = c("right", "left", "bottom", "top"),
    show_annotation_legend = TRUE,
    annotation_legend_list = list(),
    gap = unit(3, "mm"),
    main_heatmap = which(sapply(object@ht_list, inherits, "Heatmap"))[1],
    row_dend_side = c("original", "left", "right"),
    row_sub_title_side = c("original", "left", "right"), ...)

Arguments

object

a HeatmapList-class object

padding

padding of the plot. Elements correspond to bottom, left, top, right paddings.

newpage

whether create a new page for the graphics.

row_title

title on the row.

row_title_side

will the title be put on the left or right of the heatmap.

row_title_gp

graphic parameters for drawing text.

column_title

title on the column.

column_title_side

will the title be put on the top or bottom of the heatmap.

column_title_gp

graphic parameters for drawing text.

heatmap_legend_side

side of the heatmap legend.

show_heatmap_legend

whether show heatmap legend.

heatmap_legend_list

a list of self-defined legend, should be wrapped into grob objects.

annotation_legend_side

side of annotation legend.

show_annotation_legend

whether show annotation legend.

annotation_legend_list

a list of self-defined legend, should be wrapped into grob objects.

gap

gap between heatmaps, should be a unit object.

main_heatmap

name or index for the main heatmap

row_dend_side

if auto adjust, where to put the row dendrograms for the main heatmap

row_sub_title_side

if auto adjust, where to put sub row titles for the main heatmap

...

pass to make_layout,HeatmapList-method

Details

The function first calls make_layout,HeatmapList-method to calculate the layout of the heatmap list and the layout of every single heatmap, then makes the plot by re-calling the graphic functions which are already recorded in the layout.

Value

This function returns a list of row dendrograms and column dendrogram.

Author(s)

Zuguang Gu <z.gu@dkfz.de>

Examples

mat = matrix(rnorm(80, 2), 8, 10)
mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
rownames(mat) = letters[1:12]
colnames(mat) = letters[1:10]

ht = Heatmap(mat)
ht_list = ht + ht
draw(ht_list)
draw(ht_list, row_title = "row title", column_title = "column title", 
	heatmap_legend_side = "top")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ComplexHeatmap)
Loading required package: grid
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/ComplexHeatmap/draw-HeatmapList-method.rd_%03d_medium.png", width=480, height=480)
> ### Name: draw-HeatmapList-method
> ### Title: Draw a list of heatmaps
> ### Aliases: draw,HeatmapList-method
> 
> ### ** Examples
> 
> mat = matrix(rnorm(80, 2), 8, 10)
> mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
> rownames(mat) = letters[1:12]
> colnames(mat) = letters[1:10]
> 
> ht = Heatmap(mat)
> ht_list = ht + ht
Warning message:
In .local(object, ...) :
  Heatmap/row annotaiton names are duplicated: matrix_1
> draw(ht_list)
> draw(ht_list, row_title = "row title", column_title = "column title", 
+ 	heatmap_legend_side = "top")
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>