R Markdown
差异基因的pheatmap绘图
library(dplyr)
library(pheatmap)
library(tibble)
de_result <- arrange(de_result, desc(abs(log2FoldChange)))
top_de_exp <- dplyr::slice(de_result,1:20)%>%
select(-c(2:12))%>%
column_to_rownames(var = 'id')
pheatmap(top_de_exp)
进行优化(类比想象:马云工资和普通人工资
对数据取log(对数)(基因与基因间的表达量,仍可进行比较
pheatmap(log10(top_de_exp + 1))#有些数值为0 ,不能取对数,报错,故+1
进行标准化(同一基因不同样本间,可进行比较。基因之间不能进相比较
pheatmap(top_de_exp,
scale = 'row',
)
上色,图裂开
pheatmap(log10(top_de_exp + 1),
#cluster_rows = F,
#cluster_cols = F,
show_colnames = F,#列名不显示
annotation_col = select(sample_info,stage),
cutree_rows = 3)
设置stage的颜色
cols <- list(stage = c(S1 = '#ADFF2F', S2 = '#FFFF00',S3 = '#FF6347',S4 = '#FF0000'))
pheatmap(log10(top_de_exp + 1),
color = colorRampPalette(c("#006400","white","#FF0000"))(100),
#cluster_rows = F,
#cluster_cols = F,
show_colnames = F,#列名不显示
annotation_col = select(sample_info,stage),
annotation_colors = cols,
cutree_rows = 3)