heatmap annotation
1
0
Entering edit mode
2.4 years ago
j_weld ▴ 10

How to make pheatmap annotation in R, if I have cancer type and corresponding color for that? And also, the unique cancer types are 36 if it helps.

pheatmap R • 1.3k views
ADD COMMENT
1
Entering edit mode
2.4 years ago
seidel 11k

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.

### Draw a heat map with Custom Color Annotations
library(pheatmap)

# create some data
dat <- matrix(rnorm(180), nrow=10, ncol=18)

# label rows
rownames(dat) <- paste0("g", 1:10)

# label columns
colnames(dat) <- paste0("e", 1:18)

# make up a table of cancer classifications, for the columns
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)

# Specify custom colors for our cancer types
ann_colors = list(
  CancerType=c(CLL="#FF0000", BLCA="#FF2A00", LUAD="#FF5500", 
                           PRAD="#FF8000", STAD="#FFAA00", GBM="#FFD500") 
)

# draw the heatmap with column annotations, and custom annotation colors
pheatmap(dat, annotation_col=cancer_types, annotation_colors=ann_colors, 
         main="toy heat map")

enter image description here

ADD COMMENT

Login before adding your answer.

Traffic: 2243 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6