jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.29k stars 225 forks source link

Too slow to save plot to pdf #1189

Open MaoxuWang opened 3 months ago

MaoxuWang commented 3 months ago

Hi, Thanks for your amazing tool! It really helps. However, I encountered a problem when saving my plot to pdf. My matrix is about (7, 10000) and my code is as follow:

p <- Heatmap(
    mtx,
    cluster_rows = FALSE,
    cluster_columns = FALSE,
    col = colorRamp2(breaks, parula(n = length(breaks))),
    show_row_names = TRUE, 
    top_annotation = topanno,
    show_column_names = FALSE, 
    left_annotation = left_anno,
    column_split= annotation_col,
    column_gap = unit(0, "mm"),
    use_raster=TRUE,
    raster_quality = 10,
   )

And then I saved this plot by:

pdf("plot/rasterized.heatmap.pdf", width = 36, height = 12)
print(p)

dev.off()

But this is running for very long time (almost 1 hour) but still with no pdf file, could you please give me some advice? I tried pheatmap() using the same annotation data and matrix, and it worked. But I still want to use ComplexHeatmap to rasterize my plot.

Thank you!

Yunuuuu commented 3 months ago

You could use ht_opt(verbose = TRUE) to see what the hanging process is.