Hello,
I know it is possible to generate a heatmap with row annotations using pheatmap, but is it possible to generate it when a row falls into 2 categories?
For example, in the code bellow, how can I add the side bar showing that tomato is both a fruit and used in a salad?
thanks in advance! :-)
library(pheatmap)
x = matrix(1:16, nrow = 4,
dimnames = list(c("banana","lime","carrot","tomato"), c("A1","A2","B1","B2")))
x
col_ann = data.frame(cbind(c("A1","A2","B1","B2"),c("A","A","B","B")))
colnames(col_ann)=c("sample","category1")
rownames(col_ann)=col_ann$sample
col_ann$sample<-NULL
row_ann = data.frame(cbind(c("banana","lime","carrot","tomato","tomato"),
c("fruit","fruit","salad","fruit","salad")))
colnames(row_ann)=c("food","category2")
ann_color = list("category1"=c("A"="yellow","B"="blue"),
"category2"=c("fruit"="red","salad"="green"))
pheatmap(x,
cluster_rows = T,show_rownames = T, show_colnames=F,
border_color=NA, scale='row',
annotation_col = col_ann,
annotation_row = row_ann,
annotation_colors = ann_color )
Just create a separate category and colour for those that are both a fruit and salad? Otherwise, you may have to draw out how exactly you are visualising this should appear in your mind.