單細胞marker基因平均表達量熱圖

最近有小伙伴問道如下的文獻圖,簡單明了的一種細胞一列進行marker gene表達展示。這個圖其實就是展示了平均的細胞表達量而已。我們簡單做一下。此外,順便復現(xiàn)下基因注釋。
圖片

(reference:Dissecting the transcriptome landscape of the human fetal neural retina and retinal pigment epithelium by single-cell RNA-seq analysis)首先我們得到marker gene:


library(Seurat)
human_data <- readRDS("D:/KS/human_data.rds")
DefaultAssay(human_data) <- "RNA"
all.markers  <- FindAllMarkers(human_data, 
                               only.pos = TRUE, 
                               min.pct = 0.25, 
                               logfc.threshold = 0.75)

選擇需要的marker gene進行展示,平均表達量使用seurat自帶函數(shù)AverageExpression進行計算。熱圖使用Complexheatmap做即可。


#計算平均表達量
gene_cell_exp <- AverageExpression(human_data,
                                   features = gene,
                                   group.by = 'celltype',
                                   slot = 'data') 
gene_cell_exp <- as.data.frame(gene_cell_exp$RNA)

#complexheatmap作圖
library(ComplexHeatmap)
#頂部細胞類型注釋
df <- data.frame(colnames(gene_cell_exp))
colnames(df) <- 'class'
top_anno = HeatmapAnnotation(df = df,#細胞名/cluster
                             border = T,
                             show_annotation_name = F,
                             gp = gpar(col = 'black'),
                             col = list(class = c('Macrophage'="#9ECABE",
                                                     'T cell'="#F6F5B4",
                                                     'mDC'="#2F528F",
                                                     "Neutrophil"="#E3AD68",
                                                     "Mast"="#ACD45E")))#顏色設(shè)置
#數(shù)據(jù)標準化縮放一下
marker_exp <- t(scale(t(gene_cell_exp),scale = T,center = T))
Heatmap(marker_exp,
        cluster_rows = F,
        cluster_columns = F,
        show_column_names = F,
        show_row_names = T,
        column_title = NULL,
        heatmap_legend_param = list(
          title=' '),
        col = colorRampPalette(c("#0000EF","black","#FDFE00"))(100),
        border = 'black',
        rect_gp = gpar(col = "black", lwd = 1),
        row_names_gp = gpar(fontsize = 10),
        column_names_gp = gpar(fontsize = 10),
        top_annotation = top_anno)
圖片

重點知識來了,為熱圖行名添加分屏注釋:


col_cluster <- setNames(c(rep("#9ECABE",5), rep("#F6F5B4",6),
                          rep("#2F528F",5), rep("#E3AD68",5),
                          rep("#ACD45E",4)),
                        rownames(marker_exp))#設(shè)置對應標簽顏色

row_info = rowAnnotation(foo = anno_text(rownames(marker_exp), 
                              location = 0, 
                              just = "left",
                              gp = gpar(fill = col_cluster, 
                                        col = "black"),
                              width = max_text_width(rownames(marker_exp))*1.2))


Heatmap(marker_exp,
        cluster_rows = F,
        cluster_columns = F,
        show_column_names = F,
        show_row_names = T,
        column_title = NULL,
        heatmap_legend_param = list(
          title=' '),
        col = colorRampPalette(c("#0000EF","black","#FDFE00"))(100),
        border = 'black',
        rect_gp = gpar(col = "black", lwd = 1),
        row_names_gp = gpar(fontsize = 10),
        column_names_gp = gpar(fontsize = 10),
        top_annotation = top_anno)+row_info```
圖片

legend自己修飾一下就可以了。Complexheatmap真的很強大,有很多有用的功能,慢慢的我們探索。覺得分享有用的、點個贊、分享下再走唄!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容