jokergoo / ComplexHeatmap

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

vertical white lines #621

Closed ccshao closed 3 years ago

ccshao commented 3 years ago

Hello,

When saving the heatmap to pdf/png files, the plots show vertical white lines, more in png files. Input is a large matrix, 113 genes by 10154 cells.

Here is the codes for a pdf file, draw makes no difference.

pdf("net_heatmap.pdf", height = 10)
draw(
ComplexHeatmap::Heatmap(mtx,
                        name                      = "mat",
                        col                       = colfn,
                        top_annotation            = colanno,
                        show_column_name          = FALSE,
                        clustering_method_rows    = "ward.D2",
                        clustering_method_columns = "ward.D2",
                        row_names_gp              = grid::gpar(fontsize = 4))
)
dev.off()

Googled it but I don't get a clear answer. Any suggestions? Many thanks!

Saved pdf file Screenshot_2020-10-27_10-32-46

Saved png file

Screenshot_2020-10-27_10-32-58

jokergoo commented 3 years ago

Hi, can you update the package for GitHub to the newest version? I think I've fixed that bug (I hope!).

ccshao commented 3 years ago

Thanks, the lastest version solved the issue.

By the way, with magick package, the saved figure was blurry. An example is shown below. Screenshot_2020-10-28_14-16-35

mmfalco commented 3 years ago

Hi @jokergoo, I am using the l am trying to replicate the output plot from inferCNV package using a recent version of your package (2.7.6.1004).I'm trying to get some plot like this: infercnv

I'm having some white lines but in the row annotation color bars of the upper heatmap. In my casethere are ~7000 rows in the upper heatmap,so it's probable it is due to a raster problem, but even specifying the argument raster_device = "CairoPNG" there are some white lines appearing in the annotation bars of the plot. Also I don't know if it has something to do that, since it is a list of heatmaps, I'm using the draw() function to print the plot. But I think that's not the case because when I plot the upper heatmap alone I still have the lines Any suggestion? Thanks in advance

jokergoo commented 3 years ago

@mmfalco What version of ComplexHeatmap are you using?

mmfalco commented 3 years ago

@jokergoo I used ComplexHeatmap_2.7.6.1004. I replicated the plot with random data so you can see what I mean. The dim() for the upper heatmap is 6891 5863 and for the lower heatmap 2848 5863 random

And this is how I made the plot:


ht1<-Heatmap(imat,name = "ht1",
             cluster_rows = F,cluster_columns = F,show_row_names = F,show_column_names = F,#remove dendograms and name labels in col and row
             row_title = "Observations(Cells)",row_title_side = "left",
             col = col_fun,#custom legend
             left_annotation = subc_annot,
             right_annotation = sample_annotation,
             bottom_annotation = chr_labels,
             heatmap_legend_param = list(title="Modified Expression"),
             height = 0.75,raster_device = "CairoPNG"
)

ref_ht<-Heatmap(rmat,name = "ref_ht",
             cluster_rows = F,cluster_columns = F,show_row_names = F,show_column_names = F,#remove dendograms and name labels in col and row
             row_title = "Reference(Cells)",row_title_side = "left",
             show_heatmap_legend = F,
             col = col_fun,#custom legend
             right_annotation = ref_annotation,
             height = 0.25,raster_device = "CairoPNG"

)

draw(ref_ht %v% ht1, merge_legends=T,ht_gap = unit(0.8, "cm"),
     legend_title_gp=gpar(fontsize = 16),legend_labels_gp=gpar(fontsize = 14))
#add cluster and chr lines for Observations
decorate_heatmap_body("ht1", {
  eval(parse(text =chr_lines ))
  eval(parse(text =clus_lines ))

})
#add  lines for ref
decorate_heatmap_body("ref_ht", {
  eval(parse(text =chr_lines ))
  eval(parse(text = ref_clus_lines))

})
ATpoint commented 2 years ago

Same issue here, what worked for me was to install the magick package.

prinkessbambi commented 2 years ago

@ATpoint Hi, I have the same problem but with the oncoprint() function. I've installed magick 2.7.3, but I don't see an improvement. Do you have any tips? Did you use something specific from the magick package?

ATpoint commented 2 years ago

@prinkessbambi I have no additional advise, sorry. It really just was installing that packing, restarting the session and done.

jokergoo commented 2 years ago

@prinkessbambi If you can provide your code, your plot and your session info, I can help you with it.

avishai987 commented 4 months ago

For me, use_raster = F in Heatmap function solved it.