How can I make a heatmap with a large matrix?

前端 未结 6 1531
Happy的楠姐
Happy的楠姐 2020-12-14 03:56

I have a 1000*1000 matrix (which only includes integer 0 and 1), but when I tried to make a heatmap, an error occurs because it is too large.

How can I create a heat

6条回答
  •  庸人自扰
    2020-12-14 04:18

    I can believe that the heatmap is, at least, taking a long time, because heatmap does a lot of fancy stuff that takes extra time and memory. Using dat from @bill_080's example:

    ## basic command: 66 seconds
    t0 <- system.time(heatmap(dat))
    ## don't reorder rows & columns: 43 seconds
    t1 <- system.time(heatmap(dat,Rowv=NA))
    ## remove most fancy stuff (from ?heatmap): 14 seconds
    t2 <- system.time( heatmap(dat, Rowv = NA, Colv = NA, scale="column",
                 main = "heatmap(*, NA, NA) ~= image(t(x))"))
    ## image only: 13 seconds
    t3  <- system.time(image(dat))
    ## image using raster capability in R 2.13.0: 1.2 seconds
    t4 <- system.time(image(dat,useRaster=TRUE))
    

    You might want to consider what you really want out of the heatmap -- i.e., do you need the fancy dendrogram/reordering stuff?

提交回复
热议问题