Search code examples
rr-markdownheatmaply

Heatmaply not showing in R Viewer or Markdown, but does load when pressing "show in new window"


I have a heatmaply graph with almost 800 data points. When I run the plot, it will not show up in the R Viewer unless I click on "show in new window". Then it will display correctly in my browser. The plot also will not show in my markdown file after rendering with Knit.

I've been playing with the parameters, and found that the graph does seem to load when I set "showticklabels" to FALSE. However when I have it set to c(FALSE, TRUE), the graph fails to load. This is odd to me because I have it set to TRUE for showing only the labels for the two sample names, and FALSE for the 800 miRNAs, which in theory should make it load faster. I've checked this many times and I am certain they are in the right order because it loads correctly in "show new window".

Doesn't load:
HMly = heatmaply(MLH0_1HMmat, colors = mycolors, dendrogram = "column", xlab = "miRNAs", labRow = c("SW480", "HCT116 MLH1-2"), showticklabels = c(FALSE,TRUE))

Does load:
HMly = heatmaply(MLH0_1HMmat, colors = mycolors, dendrogram = "column", xlab = "miRNAs", labRow = c("SW480", "HCT116 MLH1-2"), showticklabels = FALSE

Any help would be greatly appreciated!


Solution

  • The problem seems to be solved by truncating the column labels to no more than 14 characters. In attempting to make a reproducible example, I found that the length of the names was the variable affecting whether the heatmaply plot would load or not. I hope this helps someone.

    stringr::str_trunc(colNames, 14)