Home Data exploration in R: display heatmap of large matrix, quickly?
Reply: 0

Data exploration in R: display heatmap of large matrix, quickly?

user1385 Published in May 27, 2018, 3:35 am

How do I quickly visualize large matrices in R?

I sometimes work with large-ish numeric matrices (e.g. 3000 x 3000), and quickly visualizing them is a very helpful quality control step. This was very easy and fast in Matlab, my previous language of choice. For example, it takes 0.5 seconds to display a 1000x1000 matrix:

rand_matrix = rand(1000,1000);
>> Elapsed time is 0.463903 seconds.

I'd like the same powers in R, but unfortunately visualizing matrices seems very slow in R. For example, using image.plot() the same random matrix takes more than 10 seconds to display:

mm = 1000
nn = 1000
rand.matrix = matrix(runif(mm*nn), ncol=mm, nrow=nn)
tic("Visualizing matrix")
> Visualizing matrix: 11.744 sec elapsed

The problem gets worse as the matrices get bigger. For example, a 3000x3000 matrix takes minutes to visualize in R, compared to seconds in Matlab. This obviously doesn't really work for data exploration. I've tried ggplot, and melting + geom_raster() can still take up to a minute.

What am I doing wrong? Is there a fast way to visualize matrices in R? An ideal solution would take one or two lines.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.32948 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO