Hi jv,
this is what I want. Thanks a lot.
Also could you tell me how can I change the font size of "adj_P" ?
I tried to gp = gpar(fontsize = ) in anno_barplot() or rowAnnotation() but did not change.
Hi, I created heatmap with complexheatmap package. I tried to replace the annotation name position of "adj_P" from bottom to top by annotation_names_side function, but still "adj_P" is at bottom by following script. How should I fix it? Thanks in advance.
left_ha = rowAnnotation(adj_P = anno_barplot(df_heat_1$negative_log10_of_adjusted_p_value,
axis_param = list(side = "top", labels_rot = 0),
annotation_name_side = "top",
annotation_name_rot = 90),
foo = anno_block(gp = gpar(fill = c(myCol_ano[4], myCol_ano[5], myCol_ano[7])),
width = unit(0.5, "cm"),
labels = c("BP", "CC", "MF"),
labels_gp = gpar(col = "white", fontsize = 10)))
Heatmap(df_heat_1_mat,
heatmap_width = unit(13, "cm"),heatmap_height = unit(11, "cm"),
col = myCol, na_col = "Gray",
row_split = df_heat_1$source, row_gap = unit(3, "mm"), border = TRUE, border_gp = gpar(col = "black", lwd = 1),
rect_gp = gpar(col = "white", lwd = 2),
column_names_gp = gpar(fontsize = 10), row_names_gp = gpar(fontsize = 10),
show_heatmap_legend = FALSE,
column_title = "DEP at Day80", column_title_gp = gpar(fontsize = 10, fontface = "bold"),
column_title_side = "top", column_names_side = "top", row_names_side = "left",
column_names_rot = 90,
show_column_names = TRUE, show_row_names = TRUE,
cluster_rows = FALSE, cluster_columns = FALSE, row_title = NULL,
left_annotation = left_ha)
1 answer
I think you may be using this parameter incorrectly and should instead define annotation_name_side for each of the two annotations you are makding as part of the rowAnnotation function call. What happens if you try the following:
left_ha = rowAnnotation(adj_P = anno_barplot(df_heat_1$negative_log10_of_adjusted_p_value,
axis_param = list(side = "top", labels_rot = 0),
foo = anno_block(gp = gpar(fill = c(myCol_ano[4], myCol_ano[5], myCol_ano[7])),
width = unit(0.5, "cm"),
labels = c("BP", "CC", "MF"),
labels_gp = gpar(col = "white", fontsize = 10)),
annotation_name_side = c("top", "top"),
annotation_name_rot = c(90, 90))
Where annotation_name_side = c("top", "top") is defining the annotation name side as "top" for adj_P and then foo. If you don't want foo labeled in the annotation you should be able to control that behavior with show_annotation_name = c(TRUE, FALSE)
if my answer resolved your issue, please accept the answer and upvote.
As described in the usage information for anno_barplot, the gp argument controls the graphic parameters for points and thus would not be the way to change the fontsize of your annotation label. Instead, as described in the usage for HeatmapAnnotation the annotation_name_gp argument is how you define parameters for the annotation names, as demonstrated below:
left_ha = rowAnnotation(adj_P = anno_barplot(df_heat_1$negative_log10_of_adjusted_p_value,
axis_param = list(side = "top", labels_rot = 0),
foo = anno_block(gp = gpar(fill = c(myCol_ano[4], myCol_ano[5], myCol_ano[7])),
width = unit(0.5, "cm"),
labels = c("BP", "CC", "MF"),
labels_gp = gpar(col = "white", fontsize = 10)),
annotation_name_side = c("top", "top"),
annotation_name_rot = c(90, 90),
annotation_name_gp = gpar(fontsize = 12))
I'm not entirely sure how to define different parameters for each annotation or if more than one fontsize needs to be defined if more than one annotation label exists, so it may take some trail and error to get it right
Thank you so much. I could solve it.
Log in to answer this question.