ComplexHeatmap icon indicating copy to clipboard operation
ComplexHeatmap copied to clipboard

Oncoprint - color top, center and bottom third of rectange

Open shahmj opened this issue 1 year ago • 2 comments

Please provide example datasets and the code you use. It will help me to understand your problem and help you!

Hi, I am trying to generate an oncoprint like below. How can I color each third of the rectangle, should I be using grid.polygon? I know how to conditionally color, just need to figure out how to draw the smaller rectanges.

image

Thanks, MS

shahmj avatar Mar 31 '23 14:03 shahmj

When you define the alter_fun, you can do:

alter_fun = list(
    some_name = function(x, y, w, h) {
        # y - 0.5*h corresponds to the bottom of each cell
        # 1/3*h is the height which is 1/3 of the cell height
        # `just` controls how to draw the small rectangles
        grid.rect(x, y - 0.5*h, width = w, height = 1/3*h, just = "bottom", gp = gpar(fill = "blue")
    },
    ....
)

jokergoo avatar Apr 03 '23 10:04 jokergoo

Great, thank you, that works perfectly.

shahmj avatar Apr 03 '23 15:04 shahmj