I have a selected group of genes I would like to plot which I have renamed. But when plotting them I also get the NAs for the non-selected. How could I remove the NAs only plotting my selected genes?
library(pheatmap)
set.seed(2020)
mat = matrix(rnorm(200),20,10)
rownames(mat) = paste0("g",1:20)
rownames(mat)[rownames(mat) == "g2"] <- "abc"
rownames(mat)[rownames(mat) == "g4"] <- "pqr"
rownames(mat)[rownames(mat) == "g6"] <- "zzz"
selected_genes <- c("abc","pqr", "zzz")
obj = pheatmap(mat,cluster_rows = T, scale = 'row', show_rownames = T, labels_row = selected_genes)
I have seen you can also do something like:
labRow <- c(row.names(mat)[1], rep('', length(row.names(mat))-2)) # Selected row2 as example
pheatmap(mat,cluster_rows = T, scale = 'row', show_rownames = T, labels_row = labRow)