jokergoo / ComplexHeatmap

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

row_names_gp can't use gpar(fontface = "italic") and pct wrong #1147

Open rstubbins opened 6 months ago

rstubbins commented 6 months ago

Hi, I'm trying to create an oncoPrint with the rownames italicized and the percentage of alterations listed to the left. I define alter_fun_list as such;

#Specify vectors
alter_fun_list = list(
    Yes = function(x, y, w, h) {
        grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = "orangered1", col = NA))
    },
    No = function(x, y, w, h) {
        grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = "gray70", col = NA))
    }
)

col = c(Yes = "orangered1", No = "gray70")
#Specify vectors
alter_fun_list = list(
    Yes = function(x, y, w, h) {
        grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = "orangered1", col = NA))
    },
    No = function(x, y, w, h) {
        grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = "gray70", col = NA))
    }
)

col = c(Yes = "orangered1", No = "gray70")

then I pass this into oncoPrint as such:

oncomol_print <- oncoPrint(onco_mol,
          alter_fun = alter_fun_list, col = col,
          alter_fun_is_vectorized = TRUE,
          show_column_names = TRUE,
          show_pct = TRUE,
          row_names_gp = gpar(fontface = "italic"),
          remove_empty_rows = TRUE,
          bottom_annotation = ha,
          top_annotation = NULL,
          )

And yet, I always end up with all the percentages showing as "100%" and none of the rownames are in italics. I've also tried using fontface = 3, but this also doesn't work.

Strangely, I am able to modify the font size with the row_names_gp argument, but not the fontface (the only one I want...)