jokergoo / ComplexHeatmap

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

Question about setting color function #1156

Open wbvguo opened 5 months ago

wbvguo commented 5 months ago

Dear Zuguang,

Thanks for maintaining this package. I am interested in the color setting in ComplexHeatmap. For example, I would like to use the brewer.pal(n = 7, name = "RdBu") as the color scale,

brewer.pal(n = 7, name = "RdBu")
# [1] "#B2182B" "#EF8A62" "#FDDBC7" "#F7F7F7" "#D1E5F0" "#67A9CF" "#2166AC"

and thus tried to set the color function as

col_fun = colorRamp2(c(0, 0.5, 1), brewer.pal(n = 7, name = "RdBu")[c(1,4,7)])
# take the first, middle, and last color as 3 break point color

However, I found col_fun doesn't necessarily give the original color (color code is similar e.g. "#B2182B" vs "#B2182BFF", but the color is different)

col_fun(seq(0, 1, length.out=3))
# [1] "#B2182BFF" "#F7F7F7FF" "#2166ACFF"

May I ask if how can we can configure col_fun to make the color scale the same as brewer.pal(n = 7, name = "RdBu")?

I also have another question about plotting heatmap with a huge matrix, for example the Hi-C contact matrix or the SNP-correlation matrix. With the number of features greater than 50k, It generally takes very very long to make a heatmaps in these settings. From some discussion on the github issue, it seems down-sampling is recommended to reduce the plotting time. But sometimes we might want to present the matrix as a whole, may I ask if you have any good suggestions/ideas for these high dimensional scenarios?

Thanks!