knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
Gvmap is an R package that can integrate multiple heatmap and legend figures.
Gvmap depends on several R packages. They are configr, dendextend, matrixStats, easySVG, rsvg, and stringr.
You can install gvmap through github or source code.
``` {r echo = TRUE, eval = FALSE}
devtools::install_github("ytdai/easySVG")
install.packages("configr") install.packages("dendextend") install.packages("matrixStats") install.packages("rsvg") install.packages("stringr")
devtools::install_github("ytdai/gvmap")
### Source code ``` {r echo = TRUE, eval = FALSE} install.packages("gvmap_0.1.5.tar.gz")
library(openxlsx) library(dendextend) library(matrixStats) library(easySVG) library(configr) library(gvmap) library(rsvg)
The heatmap data must be a list or a matrix, and the name of the list must like this form: heatmap_1, heatmap_2 and so on.
The colnames of each single heatmap data must be the sample, and the rownames can be genes.
ATTENTION: heatmap_1 is the main heatmap. This setting is default and there is ONLY ONE main heatmap in this figure.
heatmap_file <- system.file("extdata", "heatmap.txt", package = "gvmap") heatmap_data_1 <- read.table(heatmap_file, header = T) rownames(heatmap_data_1) <- heatmap_data_1$X heatmap_data_1 <- heatmap_data_1[, -1] head(heatmap_data_1) heatmap_data_2 <- heatmap_data_1[20:50, ] heatmap_data_3 <- heatmap_data_1[80:100, ] # if you have multiple heatmaps, the heatmap data must be a list # heatmap_1 is the main heatmap heatmap_data_mtp <- list(heatmap_1 = heatmap_data_1, heatmap_2 = heatmap_data_2, heatmap_3 = heatmap_data_3) # if you only have one heatmap, the heatmap data can be a matrix or a list # matrix heatmap_data_sig <- heatmap_data_1 # list heatmap_data_sig <- list(heatmap_1 = heatmap_data_1)
The legend is the supplement, annotation and explanation of heatmap samples. The rownames of legend data must be the sample, and the colnames must be the attributes.
legend_file <- system.file("extdata", "legend.txt", package = "gvmap") legend_data <- read.table(legend_file, header = T) row.names(legend_data) <- legend_data$SampleName legend_data
The config file must be a YAML format. SEE SECTION Config paramters
config_file <- system.file("extdata", "config.sig.yaml", package = "gvmap") config_file_content <- read.config(config_file) str(config_file_content)
# run by default paramter config_file <- system.file("extdata", "config.mtp.yaml", package = "gvmap") output_svg_name <- paste0(tempdir(), "/o1.svg") gvmap(legend_data = legend_data, heatmap_data = heatmap_data_mtp, config_file = config_file, output_svg_name = output_svg_name, plot_width = 800, plot_height = 1200)
# run by default paramter config_file <- system.file("extdata", "config.sig.yaml", package = "gvmap") output_svg_name <- paste0(tempdir(), "/o2.svg") gvmap(legend_data = legend_data, heatmap_data = heatmap_data_sig, config_file = config_file, output_svg_name = output_svg_name, plot_width = 800, plot_height = 1200)
# only legend data config_file <- system.file("extdata", "config.leg.yaml", package = "gvmap") output_svg_name <- paste0(tempdir(), "/o3.svg") gvmap(legend_data = legend_data, config_file = config_file, output_svg_name = output_svg_name, plot_width = 800, plot_height = 1200)
# add sample span and heatmap span config_file <- system.file("extdata/config.mtp.yaml", package = "gvmap") output_svg_name <- paste0(tempdir(), "/o4.svg") gvmap(legend_data = legend_data, heatmap_data = heatmap_data_mtp, config_file = config_file, output_svg_name = output_svg_name, sample_span = 5, heatmap_row_span = 4, plot_width = 800, plot_height = 1200)
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.