热图不再过多介绍了,参考之前的内容(热图系列大全)。单细胞基因可视化中热图也是比较受欢迎的,在分析完每群的marker基因之后,可以挑选显著的gene用seurat自带函数DoHeatmap可视化。当然也可以选任意自己想展示的基因进行可视化。
首选选择基因,将其转化为列表,然后比对到原数据。
markers <- c("ACKR1","RAMP2","SELE","VWF","PECAM1",
"LUM","COL3A1","DCN","COL1A1","CFD",
"KRT14","KRT5","S100A2","CSTA","SPRR1B",
"CD69","CD52","CXCR4","PTPRC","HCST")
markers <- as.data.frame(markers)
markerdata <- ScaleData(scedata, features = as.character(unique(markers$markers)), assay = "RNA")
然后用默认函数绘图。这就是一张很普通的热图,小编发现很多文章中已经不再使用这种热图了,可能作者们都嫌弃颜色太丑。需要进行改造。
DoHeatmap(markerdata,
features = as.character(unique(markers$markers)),
group.by = "celltype",
assay = 'RNA')
图片
首先对热图颜色进行该咋,就在原图基础上,使用ggplot2即可。不仅可以修改热图颜色,上面分组的颜色也可以自定义。色彩可以根据自己文章整体的色条进行调整。
DoHeatmap(markerdata,
features = as.character(unique(markers$markers)),
group.by = "celltype",
assay = 'RNA',
group.colors = c("#00BFC4","#AB82FF","#00CD00","#C77CFF"))+
scale_fill_gradientn(colors = c("white","grey","firebrick3"))
图片
除了颜色的调整,还可以调整分组的顺序,自定义排序。
markerdata$celltype <- factor(x=markerdata$celltype,
levels = c("Endothelial","Fibroblast","Epithelial","Immune","Other"))
DoHeatmap(markerdata,
features = as.character(unique(markers$markers)),
group.by = "celltype",
assay = 'RNA',
group.colors = c("#00BFC4","#AB82FF","#00CD00","#C77CFF"))+
scale_fill_gradientn(colors = c("white","grey","firebrick3"))
图片
调整之后的热图看起来也更加顺眼了。好了,今天的分享就到这里了,下节我们说说更深入的热图改造,将热图数据导出,用ComplexHeatmap做更加个性化的热图!
更多精彩请关注我的公众号---《KS科研分享与服务》
网友评论