This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to adjust font size of row_split labels in ComplexHeatmap R package

Hi,

I am working with a dataset, and would like to represent the results through a heatmap via ComplexHeatmap R package. How do I adjust/decrease the size of the row_split label names (as shown in the figure below). I have many labels to adjust in the data.matrix, and some of them get overlapped making it difficult to read the labels. Please assist.

print(new.df_v3)
                       Feature   Compound         E0       P0         R0
Feature_5_Compound_1 Feature_5 Compound_1  0.6594924 4.735091 -0.2830820
Feature_1_Compound_3 Feature_1 Compound_3 -1.0881433 2.082646 -0.4150097
Feature_2_Compound_3 Feature_2 Compound_3 -0.2826396 2.708727  0.0895918
Feature_7_Compound_1 Feature_7 Compound_1  0.3080215 2.872283  0.3606701
Feature_5_Compound_2 Feature_5 Compound_2  2.4923434 4.986943  2.8683555
Feature_6_Compound_2 Feature_6 Compound_2  0.5945302 1.496006 -1.0255425
Feature_3_Compound_1 Feature_3 Compound_1 -0.1334314 2.078446  0.5095870

library(ComplexHeatmap)
row_ha = rowAnnotation(df = data.frame(Compounds = new.df_v3$Compound),
                       show_annotation_name = TRUE,
                       col = list(Compounds = c("Compound_1" ="forestgreen","Compound_2" ="orange", "Compound_3" = "cyan")))


library(ComplexHeatmap)
pdf("Test.pdf",height = 7, width = 7)
Heatmap(new.df_v3[, -c(1:2)], 
        name = "log2FC",
        col = circlize::colorRamp2(c(-4, 0, 4), c("blue", "white", "red")),
        na_col = "grey",
        cluster_rows = F,
        cluster_columns = F,
        left_annotation = row_ha,
        row_split = new.df_v3$Compound,
        column_title = "Test", 
        column_title_side = "top",
        row_labels = new.df_v3$Feature,
        row_names_side = c("right"),
        row_names_max_width = unit(10,"in"),
        row_title_gp = gpar(fontsize = 15),
        column_title_gp = gpar(fontsize = 20, fontface = "bold"),
        column_names_gp = gpar(fontsize =15),
        row_names_gp = gpar(fontsize = 8),
        show_column_names = T)
dev.off()

Best Regards,

Toufiq

heatmap complexheatmap r labels

1 answer

change row_title_gp = gpar(fontsize = 15) to row_title_gp = gpar(fontsize = 8) for font size 15 to 8 change.

cpad0112 This fixed the issue. Thank you so much. Somehow, It slipped from my mind to test this code argument.

Log in to answer this question.