Hello,
I have some column annotations in a heatmap (generated with pheatmap), which correspond to species that i want to be in italics.
I have read through the pheatmap documentation and I can't find anything. I have also tried to find and adapt solutions online (for example), but most tutorials and posts refer to italicising the row or column names, not the annotations in the legend. I have tried to apply some of these techniques to my script but with no luck.
Is anyone able to suggest a solution? I have seen lots of posts about complex heatmaps, but from what I can work out it is not so easy to do with that either. Surely having species or genes in the annotations, which should technically be italicised, is common?
Here is what I have so far:
#Create a list containing the colours we want to use for the annotations.
ann_colours = list(
Race= c("Race 1" = "orange2", "Race 4" = "blue"),
"Forma_specialis" = c("apii" = "lightskyblue", "cepae" = "purple", "conglutinans" = "orange", "coriandrii" = "pink", "cubense" = "khaki1", "lactucae" = "green3", "lini" = "indianred", "lycopersici" = "red", "matthiolae" = "blue", "narcissus" = "yellow", "niveum" = "brown", "rapae" = "dark green", "rocket" = "light green", "vasinfectum" = "greenyellow", "non-pathogenic" = "black"),
newnames_rows <- lapply(
colnames(HeatmapData_Binary),
function(x) bquote(italic(.(x)))) #This works perfectly for the rows of course - but it's not what I need!
#Try to apply to the annotations
newnames <- lapply(
list(ann_colours),
function(x) bquote(italic(.(x))))
If I print newnames:
italic(list(Race = c(`Race 1` = "orange2", `Race 4` = "blue"),
Forma_specialis = c(apii = "lightskyblue", cepae = "purple",
conglutinans = "orange", coriandrii = "pink", cubense = "khaki1",
lactucae = "green3", lini = "indianred", lycopersici = "red",
matthiolae = "blue", narcissus = "yellow", niveum = "brown",
rapae = "dark green", rocket = "light green", vasinfectum = "greenyellow",
`non-pathogenic` = "black"), Lactucae_Distribution = c(`Race 1 Specific` = "tan1",
`Race 4 Specific` = "skyblue3", Shared = "green", `Not Race Specific` = "grey"
)))
I imagine the issue is because I am not trying to italicise the information in the df, but instead the 'ann_colours' list?
Here is my pheatmap script:
HeatmapData_Binary %>%
pheatmap(color = colorRampPalette(c("grey90", "firebrick"))(2),
legend = T,
legend_breaks = c(0.75, 0.25),
legend_labels = c("Present", "Absent"),
drop_levels = F,
cluster_rows = CEC_Clustering,
cluster_cols = Fsp_Clustering,
cellheight = 5.5,
cellwidth = 60,
annotation_row = RowAnnotations,
annotation_col = ColAnnotations,
annotation_colors = newnames,
fontsize_row = 2.5,
fontsize = 24,
treeheight_row = 10,
angle_col = 90,
cutree_cols = 14,
show_rownames = F,
na_col = "white",
border_color = "grey90",
labels_col = Isolist,
filename = "./FolaEffectorsHeatmap-Draft1.pdf",
height = 30,
width = 25)
Pheatmap which does not contain italicised annotations:
I am so close to having this figure finished! This has been plaguing me for days! Please help!
Thank you, Jamie!
I might be the party pooper but I generally think that these sorts of aesthetics should be done later in something like Inkscape. In R do the figure, in appropriate dimensions and font size and then do everything to make it look publication-ready later. No need to waste time trying to code up everything in R. You're producing dozens or hundreds of plots during a project, and only a few percent will make the paper, not worth losing too much time doing the beauty work on plots that will never again see any daylight.
@ATpoint Very true! I'm not so familiar with many image editing software and I wonder if it will be just as quick for me to try in R, but I think for some of the stuff I want to achieve with this figure that will be the best bet! Thank you (:
Inkscape you learn in a day, for basic image and figure manipulation it's really simple and a good skill to have. Highly recommended.