## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----echo = FALSE, eval = TRUE------------------------------------------------ library(HeatmapR) ## ----eval = FALSE------------------------------------------------------------- # library(HeatmapR) # heat_map(mtcars) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-1.png", # height = 7, # width = 9, # res = 500 # ) # heat_map(mtcars) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-1.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # cell_shape = "circle" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-3.png", # height = 11, # width = 7, # res = 500 # ) # heat_map( # mtcars, # cell_shape = "circle" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-3.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # cell_shape = "diamond" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-4.png", # height = 11, # width = 7, # res = 500 # ) # heat_map( # mtcars, # cell_shape = "diamond" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-4.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # cell_shape = "circle", # cell_size = TRUE # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-5.png", # height = 11, # width = 7, # res = 500 # ) # heat_map( # mtcars, # cell_shape = "circle", # cell_size = TRUE, # legend_size = 1.5 # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-5.png') ## ----eval = TRUE, echo = FALSE------------------------------------------------ set.seed(2022) ## ----eval = FALSE------------------------------------------------------------- # # Modified subset of iris dataset with missing values # iris_sub <- iris[sample(1:nrow(iris), 25), ] # iris_sub[c(2, 19, 14, 7), 2] <- NA # iris_sub[c(4, 9, 17, 25), 3] <- NA # # # Build heatmap # heat_map( # iris_sub, # cell_text = TRUE, # cell_col_empty = "grey40", # cell_col_scale = c( # "yellow", # "orange", # "red", # "black" # ), # cell_col_palette = c( # "magenta", # "blue", # "green3" # ), # cell_col_alpha = 1 # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-2.png", # height = 7, # width = 7, # res = 500 # ) # iris_sub <- iris[sample(1:nrow(iris), 25), ] # iris_sub[c(2, 19, 14, 7), 2] <- NA # iris_sub[c(4, 9, 17, 25), 3] <- NA # heat_map( # iris_sub, # cell_text = TRUE, # cell_col_empty = "grey40", # cell_col_scale = c( # "yellow", # "orange", # "red", # "black" # ), # cell_col_palette = c( # "magenta", # "blue", # "green3" # ), # cell_col_alpha = 1 # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-2.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # cell_border_line_type = 3, # cell_border_line_width = 2, # cell_border_line_col = "red", # cell_border_line_col_alpha = 1 # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-6.png", # height = 11, # width = 7, # res = 500 # ) # heat_map( # mtcars, # cell_border_line_type = 3, # cell_border_line_width = 2, # cell_border_line_col = "red", # cell_border_line_col_alpha = 1 # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-6.png') ## ----eval = FALSE------------------------------------------------------------- # # Create a mask to highlight high values # border_mask <- mtcars > median(unlist(mtcars)) # # heat_map( # mtcars, # cell_border_line_width = 2, # cell_border_line_col = "red", # cell_border_mask = border_mask, # title = "Border Masking Example" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-6b.png", # height = 11, # width = 7, # res = 500 # ) # # Create a mask to highlight high values # border_mask <- mtcars > median(unlist(mtcars)) # # heat_map( # mtcars, # cell_border_line_width = 2, # cell_border_line_col = "red", # cell_border_mask = border_mask, # title = "Border Masking Example", # cell_text = TRUE # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-6b.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # cell_text = TRUE, # cell_text_size = 1, # cell_text_font = 2, # cell_text_col = "black", # cell_text_col_alpha = 1, # title = "mtcars" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-7.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # cell_text = TRUE, # cell_text_size = 1, # cell_text_font = 2, # cell_text_col = "black", # cell_text_col_alpha = 1, # cell_col_alpha = 0.9, # title = "mtcars" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-7.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # scale = "column", # scale_method = "range", # title = "mtcars scaled columns" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-8.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # scale = "column", # scale_method = "range", # title = "mtcars scaled columns" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-8.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # scale = "row", # scale_method = "zscore", # title = "mtcars scaled rows" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-9.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # scale = "row", # scale_method = "zscore", # title = "mtcars scaled rows" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-9.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # bar_values_x = 1:ncol(mtcars), # bar_size_x = 0.5, # bar_fill_x = rainbow(ncol(mtcars)), # bar_line_col_x = "black", # bar_values_y = 1:nrow(mtcars), # bar_size_y = 0.8, # bar_fill_y = rainbow(ncol(mtcars)), # bar_line_col_y = "black", # title = "heatmap with bar plots" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-10.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # bar_values_x = 1:ncol(mtcars), # bar_size_x = 0.5, # bar_fill_x = rainbow(ncol(mtcars)), # bar_line_col_x = "black", # bar_values_y = 1:nrow(mtcars), # bar_size_y = 0.8, # bar_fill_y = rainbow(nrow(mtcars)), # bar_line_col_y = "black", # title = "heatmap with bar plots" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-10.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # scale = "column", # dist_method = "euclidean", # clust_method = "complete", # tree_x = TRUE, # tree_size_x = 0.4, # tree_y = TRUE, # tree_size_y = 0.8, # title = "Dendrograms" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-11.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # scale = "column", # dist_method = "euclidean", # clust_method = "complete", # tree_x = TRUE, # tree_size_x = 0.4, # tree_scale_x = TRUE, # tree_y = TRUE, # tree_size_y = 0.8, # title = "Dendrograms" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-11.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # scale = "column", # dist_method = "cosine", # clust_method = "complete", # tree_x = TRUE, # tree_size_x = 0.4, # tree_y = TRUE, # tree_size_y = 0.8, # title = "Cosine Distance Clustering" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-11b.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # scale = "column", # dist_method = "cosine", # clust_method = "complete", # tree_x = TRUE, # tree_size_x = 0.4, # tree_scale_x = TRUE, # tree_y = TRUE, # tree_size_y = 0.8, # title = "Cosine Distance Clustering" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-11b.png') ## ----eval = FALSE------------------------------------------------------------- # # Cut at absolute cosine distance of 0.5 # heat_map( # mtcars, # scale = "column", # dist_method = "cosine", # tree_x = TRUE, # tree_cut_x = 0.5, # tree_split_x = 1, # title = "Cosine Distance with Absolute Threshold" # ) ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # scale = "column", # dist_method = "euclidean", # clust_method = "complete", # tree_x = TRUE, # tree_size_x = 0.4, # tree_cut_x = 4, # tree_split_x = 1, # tree_y = TRUE, # tree_size_y = 0.8, # tree_cut_y = 5, # tree_split_y = 1, # title = "Hierarchical Clustering" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-12.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # scale = "column", # dist_method = "euclidean", # clust_method = "complete", # tree_x = TRUE, # tree_size_x = 0.4, # tree_cut_x = 4, # tree_split_x = 1, # tree_y = TRUE, # tree_size_y = 0.8, # tree_cut_y = 5, # tree_split_y = 1, # title = "Hierarchical Clustering" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-12.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # scale = "column", # tree_size_x = 0.4, # tree_cut_x = 4, # tree_split_x = 1, # tree_label_x = TRUE, # tree_label_size_x = 1.4, # tree_label_text_x = c(1:4), # tree_label_col_x = c( # "red", # "blue", # "green", # "magenta" # ), # tree_y = TRUE, # tree_size_y = 0.8, # tree_cut_y = 5, # tree_split_y = 1, # tree_label_y = TRUE, # tree_label_size_y = 1, # tree_label_text_y = c(1:5), # tree_label_col_y = c( # "red", # "blue", # "green", # "magenta", # "orange" # ), # title = "Cluster Labels" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-13.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # scale = "column", # tree_size_x = 0.4, # tree_cut_x = 4, # tree_split_x = 1, # tree_label_x = TRUE, # tree_label_size_x = 1.4, # tree_label_text_x = c(1:4), # tree_label_col_x = c( # "red", # "blue", # "green", # "magenta" # ), # tree_y = TRUE, # tree_size_y = 0.8, # tree_cut_y = 5, # tree_split_y = 1, # tree_label_y = TRUE, # tree_label_size_y = 1, # tree_label_text_y = c(1:5), # tree_label_col_y = c( # "red", # "blue", # "green", # "magenta", # "orange" # ), # title = "Cluster Labels" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-13.png') ## ----eval = FALSE------------------------------------------------------------- # # Manual clustering by specifying cluster sizes # # Create 3 clusters: 4 columns, 3 columns, 4 columns # heat_map( # mtcars, # scale = "column", # tree_cut_x = c(4, 3, 4), # tree_split_x = 1, # tree_label_x = TRUE, # tree_label_text_x = c("Group A", "Group B", "Group C"), # title = "Manual Clustering by Size" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-13b.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # scale = "column", # tree_cut_x = c(4, 3, 4), # tree_split_x = 1, # tree_label_x = TRUE, # tree_label_text_x = c("Group A", "Group B", "Group C"), # tree_label_size_x = 1.2, # tree_label_col_x = "white", # title = "Manual Clustering by Size" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-13b.png') ## ----eval = FALSE------------------------------------------------------------- # # Manual clustering by assigning cluster indices # # Assign each of the 11 columns to specific clusters # cluster_indices <- c(1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3) # # heat_map( # mtcars, # scale = "column", # tree_cut_x = cluster_indices, # tree_split_x = 1, # tree_label_x = TRUE, # tree_label_text_x = c("Low", "Medium", "High"), # tree_label_col_x = c("blue", "yellow", "red"), # title = "Manual Clustering by Index" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-13c.png", # height = 11, # width = 8, # res = 500 # ) # # Manual clustering by assigning cluster indices # cluster_indices <- c(1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3) # # heat_map( # mtcars, # scale = "column", # tree_cut_x = cluster_indices, # tree_split_x = 1, # tree_label_x = TRUE, # tree_label_text_x = c("Low", "Medium", "High"), # tree_label_size_x = 1.2, # tree_label_col_x = c("blue", "yellow", "red"), # title = "Manual Clustering by Index" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-13c.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map( # mtcars, # scale = TRUE, # tree_x = TRUE, # tree_y = TRUE, # cell_shape = "circle", # cell_size = TRUE, # legend = TRUE, # legend_size = 1.5, # legend_col_scale_size = 1.2, # legend_title = c("colour", "size"), # title = "Legends" # ) ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-17.png", # height = 11, # width = 8, # res = 500 # ) # heat_map( # mtcars, # scale = TRUE, # tree_x = TRUE, # tree_size_x = 0.6, # tree_y = TRUE, # cell_shape = "circle", # cell_size = TRUE, # legend = TRUE, # legend_size = 1.5, # legend_col_scale_size = 1.2, # legend_title = c("colour", "size"), # title = "Legends" # ) ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-17.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map_custom( # popup = TRUE, # popup_size = c(10, 15), # layout = matrix( # c(1,1,2,2,1,1,3,3), # ncol = 4, # nrow = 2, # byrow = TRUE # ) # ) # heat_map( # mtcars[grepl("Merc", rownames(mtcars)),], # title = "Mercedes" # ) # heat_map( # mtcars[grepl("Mazda|Toyota", rownames(mtcars)),], # title = "Mazda | Toyota" # ) # heat_map( # mtcars[grepl("Hornet|Datsun|Volvo", rownames(mtcars)),], # title = "Hornet | Datsun | Volvo" # ) # heat_map_complete() ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-14.png", # height = 5, # width = 12, # res = 500, # layout = matrix( # c(1,1,2,2,1,1,3,3), # ncol = 4, # nrow = 2, # byrow = TRUE # ) # ) # heat_map( # mtcars[grepl("Merc", rownames(mtcars)),], # title = "Mercedes" # ) # heat_map( # mtcars[grepl("Mazda|Toyota", rownames(mtcars)),], # title = "Mazda | Toyota" # ) # heat_map( # mtcars[grepl("Hornet|Datsun|Volvo", rownames(mtcars)),], # title = "Hornet | Datsun | Volvo" # ) # heat_map_complete() ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-14.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map_custom( # popup = TRUE, # popup_size = c(10, 15), # layout = matrix( # c(1,1,2,2,1,1,3,3), # ncol = 4, # nrow = 2, # byrow = TRUE # ) # ) # heat_map( # mtcars, # title = "mtcars" # ) # plot( # mtcars[, c("disp", "hp")], # xlab = "Displacement", # ylab = "Horsepower", # main = "mtcars: Displacement vs Horsepower", # pch = 16, # col = "black" # ) # boxplot( # mtcars[, "disp"], # main = "Displacement", # xlab = "Displacement (cu.in.)", # horizontal = TRUE # ) # heat_map_complete() ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-15.png", # height = 8, # width = 10, # res = 500, # layout = matrix( # c(1,1,2,2,1,1,3, 3), # ncol = 4, # nrow = 2, # byrow = TRUE # ) # ) # heat_map( # mtcars, # scale = "column", # cell_size = TRUE, # legend_size = 1.5, # title = "mtcars" # ) # plot( # mtcars[, c("disp", "hp")], # xlab = "Displacement", # ylab = "Horsepower", # main = "mtcars: Displacement vs Horsepower", # pch = 16, # col = "black" # ) # abline( # lm(hp ~ disp, data = mtcars), # col = "red", # lty = 2 # ) # boxplot( # mtcars[, "disp"], # main = "Displacement", # xlab = "Displacement (cu.in.)", # horizontal = TRUE # ) # heat_map_complete() ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-15.png') ## ----eval = FALSE------------------------------------------------------------- # heat_map_save( # "mtcars.png", # height = 9.5, # width = 5.7, # res = 500 # ) # heat_map( # mtcars, # scale = "column", # scale_method = "range", # tree_x = TRUE, # tree_y = TRUE, # tree_cut_x = 4, # tree_cut_y = 12, # cell_size = TRUE, # cell_shape = "circle", # title = "mtcars" # ) # heat_map_complete() ## ----eval = FALSE, echo = FALSE----------------------------------------------- # heat_map_save( # "vignettes/HeatmapR/HeatmapR-16.png", # height = 9.5, # width = 5.7, # res = 500 # ) # heat_map( # mtcars, # scale = "column", # scale_method = "range", # tree_x = TRUE, # tree_y = TRUE, # tree_cut_x = 4, # tree_cut_y = 12, # tree_size_x = 0.6, # cell_size = TRUE, # cell_shape = "circle", # title = "mtcars" # ) # heat_map_complete() ## ----echo = FALSE, out.width = '95%', fig.align="center"---------------------- knitr::include_graphics('https://raw.githubusercontent.com/DillonHammill/HeatmapR/refs/heads/master/vignettes/HeatmapR/HeatmapR-16.png')