data类似于heatmap.2输入数据
> annotation_col=data.frame(cell_type=factor(c("B36h","B36h","B36h","EpiLC","EpiLC","EpiLC","B12h","B12h","B12h","B24h","B24h","B24h")))
>rownames(annotation_col)=paste(factor(c("B36h_1","B36h_2","B36h_3","EpiLC_1","EpiLC_2","EpiLC_3","B12h_1","B12h_2","B12h_3","B24h_1","B24h_2","B24h_3")))
>pheatmap(data,cluster_rows = F,cluster_cols = F,display_numbers = matrix(ifelse(data > 0, "*", ""), nrow(data)),annotation_col = annotation_col ,cellwidth = 30,main = "heatmap",color = colorRampPalette(c("navy", "white", "firebrick3"))(50),gaps_row = c(11,34,43), angle_col = 0)
###修改x轴字体角度## 方法来自苏牧传媒
library("grid")
draw_colnames_45 <- function (coln, gaps, ...) {
coord <- pheatmap:::find_coordinates(length(coln), gaps)
x <- coord$coord - 0.5 * coord$size
res <- grid::textGrob(
coln, x = x, y = unit(1, "npc") - unit(3,"bigpts"),
vjust = 1, hjust = 0.8, rot = 30, gp = grid::gpar(...)
)
return(res)
}
# vjust hjust [0,1]
# 0 means left-justified(0表示左适应)
# 1 means right-justified(1表示右适应)
# hjust controls horizontal justification and vjust controls vertical justification.
#(hjust 控制水平横轴 , vjust控制垂直纵轴 )
assignInNamespace(
x = "draw_colnames",
value = "draw_colnames_45",
ns = asNamespace("pheatmap")
)