You simply have to put your custom colors in a List, and hand it to the pheatmap()
function. It's explained pretty clearly in the help for pheatmap (type: ?pheatmap at your R prompt). There's an example below. 36 colors will be impossible to distinguish. You can see that starting with just a few from your table, some of the types can't be distinguished.
library(pheatmap)
dat <- matrix(rnorm(180), nrow=10, ncol=18)
rownames(dat) <- paste0("g", 1:10)
colnames(dat) <- paste0("e", 1:18)
cancer_types <- data.frame(CancerType=c(rep("CLL", 3), rep("BLCA", 3), rep("LUAD", 3),
rep("PRAD", 3), rep("STAD", 3), rep("GBM", 3)))
rownames(cancer_types) <- colnames(dat)
ann_colors = list(
CancerType=c(CLL="#FF0000", BLCA="#FF2A00", LUAD="#FF5500",
PRAD="#FF8000", STAD="#FFAA00", GBM="#FFD500")
)
pheatmap(dat, annotation_col=cancer_types, annotation_colors=ann_colors,
main="toy heat map")
