I am plotting heatmap by pheatmap
package in r.
I applied the display_numbers
function to display the values in a matrix into the heatmap, and I got:
I got so many NA in my matrix and I would like to hide them in the heatmap, how can I do that?
First off, it is a lot easier for people to help you if you were to provide reproducible and minimal sample data. Please consider reviewing how to provide a minimal reproducible example/attempt for future posts.
As to your question:
Let's generate some sampe data
set.seed(2018)
mat <- matrix(runif(20), 4, 5)
We use a second matrix to display values via the argument display_numbers
of pheatmap
. Here we simply copy the original matrix and randomly generate some NA
values:
mat2 <- mat
mat2[mat2 < 0.5] <- NA
We now replace NA
values with empty strings.
mat2[is.na(mat2)] <- ""
Let's show the heatmap
pheatmap(mat, display_numbers = mat2)