ComplexHeatmap icon indicating copy to clipboard operation
ComplexHeatmap copied to clipboard

anno_link() align_to wrong shifted

Open mligerhe opened this issue 2 years ago • 4 comments

Using the R version 4.1.3 (2022-03-10) and the Complex Heatmap 2.10.0, following the example from https://jokergoo.github.io/ComplexHeatmap-reference/book/heatmap-annotations.html#zoom-annotation

set.seed(123)
m = matrix(rnorm(100*10), nrow = 100)
subgroup = sample(letters[1:3], 100, replace = TRUE, prob = c(1, 5, 10))
rg = range(m)
panel_fun = function(index, nm) {
    pushViewport(viewport(xscale = rg, yscale = c(0, 2)))
    grid.rect()
    grid.xaxis(gp = gpar(fontsize = 8))
    grid.boxplot(m[index, ], pos = 1, direction = "horizontal")
    popViewport()
}
anno = anno_link(align_to = subgroup, which = "row", panel_fun = panel_fun, 
    size = unit(2, "cm"), gap = unit(1, "cm"), width = unit(4, "cm"))
Heatmap(m, name = "mat", right_annotation = rowAnnotation(foo = anno), row_split = subgroup)

it should plot the following heatmap: image

However, I obtained shifted boxes for the annotation boxplot. See following image remaked in red where the boxes are shifted: examplenotworking

mligerhe avatar May 13 '22 16:05 mligerhe

FYI. I found out that when you save it in .svg, it automatically aligns correctly.

mligerhe avatar May 13 '22 16:05 mligerhe

Did you see any information from the terminal? Or did you manually change the graphical window size, e.g. by dragging it?

jokergoo avatar May 14 '22 20:05 jokergoo