coloring specfic rownames in the heatmap

Hello Dears,
I want to give a different color for my heatmap's row names A and D. Is it possible to do using pheatmap or heatmap.2?
Below is my code

set.seed(22)
li.A <- matrix(rnorm(50), nrow = 10)
rownames(li.A) <- LETTERS[1:10]
colnames(li.A) <- paste0("S_", ncol = 1:5)
library(pheatmap)
pheatmap(li.A)

Thank you so much!

With pheatmap, not really. What you can do is add an annotation color bar:

annotation_df <- data.frame(ann = c(rep("Aa",5), rep("Bb",5)),
                            row.names = rownames(li.A))

pheatmap(li.A, annotation_row = annotation_df)

With heatmap.2, a quick look at the man page suggests colRow and colCol might do it, I've never tried.

Else, I can imagine complexHeatmap will let you do that.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.