I'm trying to make a heat map with dendrogram in R. I'm also trying to make it so that the color matrix is on the bottom of the heat map. i understand that I would have to change the value of lmat for this. So far I have something like this for lmat.
lmat=rbind(c(0,3,0), c(2,1,0), c(0,4,0)).
After I run it, it asks me to update the lhei and lwid values. After looking at the documentation, I understand that these are vectors for column width and row height. But I don't understand the multiple values needed for their values. For ex, when I set this , I get this error.
lhei must have length = nrow(lmat) = 3
I'm not sure what the three values for lhei would correspond to. This leads me to a broader question, what does each value in the vectors for lhei and lwid correspond to?
lhei
is the relative heights of the rows in the plot. Heatmaps in R are a bit screwy. The graphics device (think of a canvas you want to paint on) is divided into a grid where each element of the heatmap will be plotted: color key, dendrograms and the heatmap. This makes a 2x2 grid. when you add the colsideColors or rowsidecolors the grid expands by 1 in the appropriate dimension, (e.g. 1 more row when adding colsidecolors). When you add this extra row you need to tell R how much (relative) space it needs.
mat <- matrix(rnorm(200), nrow = 20)
colCols <- rep(c("red", "blue"), 5)
heatmap.2(mat, trace="none", ColSideColors = colCols,
lmat=rbind(c(5,4), c(3,2), c(0,1)),
lhei=c(2,4,0.2))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With