renozao / NMF

NMF: A Flexible R package for Nonnegative Matrix Factorization
137 stars 41 forks source link

Dendrogram tree not resizing on zoom in Rstudio #53

Open mdozmorov opened 9 years ago

mdozmorov commented 9 years ago

When using Rstudio, zooming the aheatmap using "Zoom" button on the "Plots" tab leads to zooming the plot but not the dendrogram. Snapshot attached. Resizing the window cripples the dendrogram even more.

Example: library(NMF) mat <- matrix(rnorm(900), ncol = 30) hclustergram <- hclust(as.dist(1 - cor(mat)), method="ward.D2") aheatmap(mat, Rowv=as.dendrogram(hclustergram), Colv=as.dendrogram(hclustergram))

Using the latest NMF: install_github('renozao/pkgmaker', ref = 'develop') install_github('renozao/NMF', ref = 'devel')

image

P.S. There is also some weird behavior of the 'fontsize', 'cexRow/Col' parameters. Trying to reproduce in another example.

renozao commented 9 years ago

Yes. There has always been an issue with RStudio zoomed view. Probably due to the fact that the dendrograms are drawn as base graphics (vs. grid). I will most likely need to use the grid resizing methods to solve this (https://ryouready.wordpress.com/2012/08/01/creating-a-text-grob-that-automatically-adjusts-to-viewport-size/).

I think the issue doesn't appears in another context though, does it?

mdozmorov commented 9 years ago

Makes sense. Resizing distortion a minor annoyance, in all other contexts (direct plotting, plotting to pdf) the aheatmap function works as expected. So, a workaround for large heatmaps is to print to pdf, and zoom the resulting document.

Not sure it writing the grid resizing method will be worth it - it adds another layer of complexity and it is hard to predict its behavior on different screen resolutions.

amackey commented 8 years ago

It also doesn't work if you use dev.copy2pdf() (i.e. the resizing of the dendrograms to the new PDF is wrong) -- so not just an RStudio zoom issue.