I am trying to use the Oncoprint functionality of your package (version: ComplexHeatmap_2.18.0) to display a list of matrices that contain continuous values and zeros. So instead of assigning a discrete color in alter_fun for each alteration, I would like to display a continuous color scale for each list entry (not an alteration, basically a Heatmap() with subdivided elements). Find a minimal reproducible example below that should showcase what I mean.
I would be thankful for any pointers and help. Apologies if this has been addressed somewhere and I missed it.
Thanks in advance!
Lasse
# Generate a matrix with random numbers between 0 and 1
mat <- matrix(runif(6*6), nrow = 6, ncol = 6)
mat_1 <- matrix(runif(6*6), nrow = 6, ncol = 6)
# Set some of the elements to 0
cur_zero <- sample(1:36, 6, replace = FALSE)
cur_zero_1 <- sample(1:36, 6, replace = FALSE)
mat[cur_zero] <- 0
mat_1[cur_zero_1] <- 0
# Create a list
mat_list <- list(mat, mat_1)
names(mat_list) <- c("mat","mat_1")
# Create discrete color vector (TO BE CHANGED)
viz_col <- setNames(c("#E41A1C","#377EB8"),
c("mat","mat_1"))
# Alter-fun (TO BE CHANGED)
viz_fun <- list(
background = function(x, y, w, h) grid.rect(x, y, w, h,
gp = gpar(fill = "white", col = "black")),
mat = function(x, y, w, h) grid.rect(x - 0.25*w, y, w*0.5, h,
gp = gpar(fill = viz_col["mat"], col = "black")),
mat_1 = function(x, y, w, h) grid.rect(x + 0.25*w, y, w*0.5, h,
gp = gpar(fill = viz_col["mat_1"], col = "black"))
)
# Print oncoprint
onco_out <- oncoPrint(mat_list, alter_fun = viz_fun, col = viz_col)
draw(onco_out)
Hi @jokergoo,
thanks a lot for the fantastic package!
I am trying to use the
Oncoprint
functionality of your package (version: ComplexHeatmap_2.18.0) to display a list of matrices that contain continuous values and zeros. So instead of assigning a discrete color inalter_fun
for each alteration, I would like to display a continuous color scale for each list entry (not an alteration, basically aHeatmap()
with subdivided elements). Find a minimal reproducible example below that should showcase what I mean.I would be thankful for any pointers and help. Apologies if this has been addressed somewhere and I missed it.
Thanks in advance! Lasse