Learn R Programming

heatmaply (version 0.3.2)

heatmaply: Creates a plotly heatmap

Description

An object of class heatmapr includes all the needed information for producing a heatmap. The goal is to seperate the pre-processing of the heatmap elements from the graphical rendaring of the object, which could be done

Usage

heatmaply(x, colors = viridis(n = 256, alpha = 1, begin = 0, end = 1, option = "viridis"), limits = NULL, na.value = "grey50", row_text_angle = 0, column_text_angle = 45, margin = 0, row_dend_left = FALSE, ..., scale_fill_gradient_fun = scale_fill_gradientn(colors = colors, na.value = na.value, limits = limits), srtRow, srtCol)

Arguments

x
can either be a heatmapr object, or a numeric matrix Defaults to TRUE unless x contains any NAs.
colors
a vector of colors to use for heatmap color. The default uses viridis(n=256, alpha = 1, begin = 0, end = 1, option = "viridis") It is passed to scale_fill_gradientn.
limits
a two dimensional numeric vector specifying the data range for the scale.
na.value
color to use for missing values (default is "grey50").
row_text_angle
numeric (Default is 0), the angle of the text of the rows. (this is called srtRow in heatmap.2)
column_text_angle
numeric (Default is 45), the angle of the text of the columns. (this is called srtCol in heatmap.2)
margin
passed to subplot. Default is 0. Either a single value or four values (all between 0 and 1). If four values are provided, the first is used as the left margin, the second is used as the right margin, the third is used as the top margin, and the fourth is used as the bottom margin. If a single value is provided, it will be used as all four margins.
row_dend_left
logical (default is FALSE). Should the row dendrogram be plotted on the left side of the heatmap. If false then it will be plotted on the right side.
...
other parameters passed to heatmapr (currently, various parameters may be ignored.
scale_fill_gradient_fun
A function that creates a smooth gradient for the heatmap. The default uses scale_fill_gradientn with the values of colors, limits, and na.value that are supplied by the user. The user can input a customized function, such as scale_colour_gradient() in order to get other results (although the virids default is quite recommended)
srtRow
if supplied, this overrides row_text_angle (this is to stay compatible with heatmap.2)
srtCol
if supplied, this overrides column_text_angle (this is to stay compatible with heatmap.2)

Please submit an issue on github if you have a feature that you wish to have added)

Examples

Run this code
## Not run: 
# 
# # mtcars
# # x <- heatmapr(mtcars)
# library(heatmaply)
# heatmaply(iris[,-5], k_row = 3, k_col = 2)
# heatmaply(cor(iris[,-5]))
# heatmaply(cor(iris[,-5]), limits = c(-1,1))
# heatmaply(mtcars, k_row = 3, k_col = 2)
# 
# # make sure there is enough room for the labels:
# heatmaply(mtcars) %>% layout(margin = list(l = 130, b = 40))
# 
# # control text angle
# heatmaply(mtcars, column_text_angle = 90) %>% layout(margin = list(l = 130, b = 40))
# # the same as using srtCol:
# # heatmaply(mtcars, srtCol = 90) %>% layout(margin = list(l = 130, b = 40))
# 
# 
# 
# x <- mtcars
# # different colors
# heatmaply(x, colors = heat.colors(200))
# # using special scale_fill_gradient_fun colors
# heatmaply(x, scale_fill_gradient_fun = scale_colour_gradient())
# 
# ## End(Not run)

Run the code above in your browser using DataLab