#' Plot a heatmap of GO terms
#'
#' @param heatmapData matrix generated by Humanzee::goHeatmapData, which contains
#' GO terms annotations and p-values of the enrichment analysis.
#'
#' @return hmp heatmap generated by heatmap.2 function.
#'
#' @export
#'
#' @examples
#' hmap <- plotHeatmap(heatmap_allgos,
#' labCol = c("Ribo > mRNA", "RNA > Ribo",
#' "Ribo > Protein", "Protein > Ribo"))
plotHeatmap <- function(heatmapData, mar = c(0, 0, 0, 0),
oma = c(0, 0, 0, 0), keysize = .5,
labCol = "" ) {
require(broman)
crayon <- brocolors("crayon")
cols = colorRampPalette(c("white", crayon["Banana Mania"],
crayon["Laser Lemon"],
crayon["Burnt Orange"], crayon["Orange Red"],
crayon["Plum"]))
par( mfrow = c(1,1), mar = mar, oma = oma )
require(gplots)
mat <- matrix(heatmapData[ , -c(1:2)], ncol = 1)
sepwidth <- c(.1, .01)
sepcol <- "grey30"
if (NCOL(mat) == 1) {
mat <- cbind(mat, mat)
sepwidth <- c(0, .01)
sepcol <- "white"
}
rownames(mat) <- heatmapData$Term
hmap <- heatmap.2(as.matrix(-log10(mat)), main = "",
labCol = labCol, cexCol = 1.2,
cexRow = 1.3,
sepcol = "white", sepwidth=sepwidth,
colsep = 1:ncol(mat), Colv = FALSE,
rowsep = 1:nrow(mat), dendrogram = "row",
srtCol = 0, adjCol = c(.5,NA), offsetCol = 1,
keysize = keysize, lwid = c(1.5, 7), lhei = c(.5, 5),
col = cols, trace ="none", key.title = "-log p-value" )
return(hmap)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.