jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.29k stars 225 forks source link

add hline anno_barplot HeatmapAnnotation #1006

Open yamihn opened 1 year ago

yamihn commented 1 year ago

Hello, could you help me to see how to set a abline to give a treshold for pvalues barplot? Thank you

 column_ha3= HeatmapAnnotation("-log adj p-value"= anno_barplot(-log(vector_pvalues_adj)), gp = gpar(fill = "red"), height =  unit(20, "mm"))

 Hc0d8= Heatmap(as.matrix(table_c0d8_all_filtered), cluster_rows = T, cluster_columns=F , show_row_names = T, col =c("#1A9850","white", "#D73027" ),
         border = "black", name = "common c0d8", column_names_gp = grid::gpar(fontsize = 12), row_names_gp = grid::gpar(fontsize=12), row_order = levels(paste("C", 1:18, sep = "")),
         rect_gp = gpar(col = "gray", lty = 1, lwd = 1), show_column_dend = F, show_row_dend = F, bottom_annotation = column_ha,
         top_annotation = c(**column_ha3**, column_ha1_c0d8),  heatmap_legend_param = list(at = c("1", "0", "-1"), labels = c("Up", "None", "Down")), right_annotation = column_ha2_c0d8) 

common_c0d8_pvalues

jokergoo commented 1 year ago

After the heatmap is drawn, use decorate_annotation():

decorate_annotation("-log adj p-value", {
    grid.lines(unit(c(0, 1), "npc"), unit(rep(-log(0.05), 2), "native"), lty = 2)
})