I've read similar questions like Moving color key in R heatmap.2 (function of gplots package) and the handbook but it hasn't worked (/I haven't got it to work). Maybe it is a different command for a pheatmap. If it is, I can't find it.
This is my code:
# Make a data frame of gene IDs vs Names with type too
GeneName_df <- anno[anno$gene_id %in% rownames(plot_matrix[top20idx,]),]
# Re order (so same as plot_matrix[top20idx]) i.e. by gene_id
GeneName_df <- GeneName_df[order(GeneName_df$gene_id), ]
anno_df <- as.data.frame(colData(dds)[,c("condition","CellType")])
colnames(anno_df) <- c("Condition","CellType")
anno_colours = list(
CellType = c(TKO = "#00BFFF", WT = "#9A2EFE"),
Condition = c(treated = "#FE2E2E", untreated = "#F5A9A9")
)
top20matrix <- plot_matrix[top20idx,]
pheatmap(top20matrix, main = "Top 20 Differentially Expressed Genes",
fontsize = 8, color = pal(10), border_color = "Black", cellwidth = 26,
cellheight = 9, labels_row = GeneName_df[,2], annotation_col = anno_df,
annotation_colors = anno_colours, angle_col = "45", cutree_cols = 2,
annotation_names_col = FALSE)
Output: pheatmap
- I want to shift the colour key and column key along so they aren't squished together. Note that when I have been changing the parameters and size of the pheatmap the top and bottom kept cutting off. Apparently this is a problem that will be fixed in the next R update.
- Is there a way to reduce the length of the grouping lines at the top of the pheatmap? They're taking up a lot of room.