Entering edit mode
2.1 years ago
Fahmida Khanam
•
0
I am trying to generate a heatmap as the following figure. I have already tried pheatmap and the code is as follows:
breaks_2 <- seq(min(0), max(2), by = 0.1)
pheatmap::pheatmap(mat = data,
cluster_cols = F,
cluster_rows = F,
scale = "column",border_color = "white",
color = inferno(20),
show_colnames = TRUE,
show_rownames = FALSE,
breaks = breaks_2)
But this does not seem to work. So far I am understanding I am mistaking with defining break or have to use another package than pheatmap. Any suggestion will be really helpful.
It should be possible to get to something very close to that image with R, but what do you mean by "But this does not seem to work."? Do you get an error or is it just a bit different?
well, I get output, there is no error but I need a output like the file I attached. If you observe it, all values above 2 have daffodil color in inferno scale. So I set the breaks as seq(0,2) but my output is not like this. Now I am confused should I use another package other than pheatmap? or am I writing the code wrong?
Difficult to say what's not going as planned here. To find out, one would have to experiment with the data and settings. If you could also provide your data (or at least a representative sample), then we might figure something out. Otherwise, I see little chance.
Michael Dondrup My dataset looks like this: If I run the following code : library(pheatmap)
my output looks like this: but i need to create an output like this:
There are of course multiple differences, but I am not considering you mean the difference in layout or geometry. But you definitely should try to turn on row clustering:
cluster_rows = T,
because rows in the example are definitely ordered in some way. It would be easiest if you also had the plotting code for your model output. Also, you might consider scaling the data before plotting.Asides, I would like to question the motivation for replicating the image exactly, how does it make sense to aim at an exact replication if you don't have the exact same data?
But even the geometry might play a role in color perception, so before you compare the plots, make sure that they have about the same aspect ratio and similar number of rows in the heatmap.