How can I make it so R plots the dendrogram scale (so that the height of each dendrogram can be interpreted) along with the heatmap when calling NMF package aheatmap
or heatmap.2
? These dendrograms show the scale: http://gastonsanchez.com/blog/how-to/2012/10/03/Dendrograms.html This is the default behavior of doing plot(hclust(...))
and I'd like to emulate that but not sure how to do it via heatmap
functions.
The issue here is how heatmap.2
plots a dendrogram
object. heatmap.2
uses the code plot(ddr, horiz = TRUE, axes = TRUE, yaxs = "i", leaflab = "none")
, where ddr
is the dendrogram. You want the axes
argument to be FALSE
. As a workaround, I created a modified version of the heatmap.2
function. See ?plot.dendrogram
for more information.
x = matrix( rnorm(25), ncol=5 )
f = gplots:::heatmap.2
# Edit the appropriate lines of the heatmap.2 function
print(body(f)[[75]]) # The line to edit
# if (dendrogram %in% c("both", "row")) {
# plot(ddr, horiz = TRUE, axes = FALSE, yaxs = "i", leaflab = "none")
# } else plot.new()
body(f)[[75]][[3]][[2]][[4]] = TRUE
print(body(f)[[77]])
# if (dendrogram %in% c("both", "column")) {
# plot(ddc, axes = FALSE, xaxs = "i", leaflab = "none")
# } else plot.new()
body(f)[[77]][[3]][[2]][[3]] = TRUE
f(x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.