Make a farily standard interactive heatmap with optional clustering and
row and column annotations. For more flexibility and options, see the
main_heatmap
function and other modular functions as described
in vignette.
# S4 method for matrix
iheatmap(
data,
x = default_x(data),
y = default_y(data),
cluster_rows = c("none", "hclust", "kmeans"),
cluster_cols = c("none", "hclust", "kmeans"),
row_clusters = NULL,
col_clusters = NULL,
row_k = NULL,
col_k = NULL,
row_clust_dist = stats::dist,
col_clust_dist = stats::dist,
name = "Signal",
scale = c("none", "rows", "cols"),
scale_method = c("standardize", "center", "normalize"),
colors = NULL,
col_clusters_colors = NULL,
col_clusters_name = "Col
Clusters",
row_clusters_colors = NULL,
row_clusters_name = "Row
Clusters",
show_row_clusters_colorbar = TRUE,
show_col_clusters_colorbar = TRUE,
row_annotation = NULL,
col_annotation = NULL,
row_annotation_colors = NULL,
col_annotation_colors = NULL,
row_labels = NULL,
col_labels = NULL,
row_title = NULL,
col_title = NULL,
colorbar_grid = setup_colorbar_grid(),
layout = list(),
source = "iheatmapr",
...
)
Iheatmap-class
object, which can be printed to generate
an interactive graphic
matrix of values to be plotted as heatmap
x xaxis labels, by default colnames of data
y axis labels, by default rownames of data
"none","hclust", or "k-means" for no clustering, hierarchical clustering, and k-means clustering of rows respectively
"none","hclust", or "k-means" for no clustering, hierarchical clustering, and k-means clustering of columnsrespectively
vector of pre-determined row cluster assignment
vector of pre-determined column cluster assignment
number of clusters for rows, needed if cluster_rows is kmeans or optional if hclust
number of clusters for columns, needed if cluster_rows is kmeans or optional if hclust
distance function to use for row clustering if hierarchical clustering
distance function to use for column clustering if hierarchical clustering
Name for colorbar
scale matrix by rows, cols or none
what method to use for scaling, either none, standardize, center, normalize
name of RColorBrewer palette or vector of colors for main heatmap
colors for col clusters annotation heatmap
name for col clusters colorbar
colors for row clusters annotation heatmap
name for row clusters colorbar
show the colorbar for row clusters?
show the colorbar for column clusters?
row annotation data.frame
column annotation data.frame
list of colors for row annotations heatmap
list of colors for col annotations heatmap
axis labels for y axis
axis labels for x axis
x axis title
y axis title
colorbar grid parameters, should be result from
setup_colorbar_grid
list of layout attributes to pass to plotly, eg. list(font = list(size = 15))
source name for use with shiny
additional argument to iheatmap
Alicia Schep
By default, no scaling is done of rows or columns. This can be changed by specifying the 'scale' argument. There are three options for scaling methods. "standardize" subtracts the mean and divides by standard deviation, "center" just subtracts the mean, and "normalize" divides by the sum of the values. "normalize" should only be used for data that is all positive! If alternative scaling is desired, the scaling should be done prior to calling the iheatmap function.
iheatmap
, add_iheatmap
,
to_widget
mat <- matrix(rnorm(24), nrow = 6)
annotation = data.frame(gender = c(rep("M", 3),rep("F",3)),
age = c(20,34,27,19,23,30))
hm <- iheatmap(mat,
cluster_rows = "hclust",
cluster_cols = "kmeans",
col_k = 3,
row_annotation = annotation)
# Print heatmap if interactive session
if (interactive()) hm
Run the code above in your browser using DataLab