R ComplexHeatmap - Dividing Column Annotation into Distinct Y-Axis Scales
0
0
Entering edit mode
3 months ago
TC_Chang ▴ 10

Hi,

I'm attempting to separate the final column from the others (as shown in the plot below) due to the significantly greater number of barplots it contains compared to the rest. Could I possibly divide them and create distinct y-axis scales for each group? Any suggestion will be greatly appreciated!

Please see the script below.

rownames(sig) = sig$Gene

sig_mat = as.matrix(sig[,2:9])

pdx = as.numeric(as.matrix(pdx_no[,2:9]))

cell_fun4 = function(j, i, x, y, width, height, fill) { grid.rect(x = x, y = y, width = width, height = height, gp = gpar(col = "gray", fill = fill)) if(sig_mat[i, j] != 0) { if(sig_mat[i, j] > 9) { grid.text(sig_mat[i, j], x, y, gp = gpar(col = "white")) } else { grid.text(sig_mat[i, j], x, y, gp = gpar(col = "black")) } } }

col_fun4 = colorRamp2(c(0, 2, 5, 10, 20), c("#FFFFFF", "#D3D3D3", "#808080", "#A9A9A9", "#000000"))

col_anno <- columnAnnotation(Pct_model = anno_barplot(pdx, bar_width = 0.3, gp = gpar(fill= c("#E64B35","#00A087","#3C5488", "#F39B7F","#8491B4","#8e0152", "#7E6148","#B09C85")), add_numbers = TRUE, height = unit(2, "cm"), numbers_rot = 0, numbers_gp = gpar(fontsize = 12), border = TRUE, name=NULL ))

hm4 <- Heatmap(sig_mat, name = "#_of_LOE_Sig", cluster_rows = FALSE, cluster_columns = FALSE, show_row_names = TRUE, show_column_names = FALSE, column_names_side = "top", row_names_side = "left", column_names_gp = gpar(fontsize=13,fontface="bold"), row_names_gp = gpar(fontsize=10,fontface="bold"), cell_fun = cell_fun4, col = col_fun4, bottom_annotation = col_anno, show_heatmap_legend = FALSE )

hm4

enter image description here

R complexheatmap • 423 views
ADD COMMENT
0
Entering edit mode

I'm not totally clear on what you hope to achieve, but have you considered using a list of heatmaps? See https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html for more details

ADD REPLY
0
Entering edit mode

Hi jv,

Thank you for your reply. Basically, I'm trying to generate the figure shown below with two different y-axis scales.

Any suggestions?

enter image description here

ADD REPLY
1
Entering edit mode

Ok. My suggestion is to make two heatmaps, one with data for the first 7 columns (left-to-right) and a second heatmap with the 8th column of data, then combine and plot together as a horizontal list of heatmaps. This will produce a small gap between the two heatmaps but you can modify as needed.

ADD REPLY

Login before adding your answer.

Traffic: 2245 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6