doplot可视化多个单细胞亚群的多个标记基因(2021公开课配套笔记)

2021-07-06 14:53:08 浏览数 (1)

下面是粉丝linbo的笔记投稿

依旧seurat 官方教程为例

代码语言:javascript复制
rm(list = ls())
library(Seurat)
library(ggplot2)
library(patchwork)
library(dplyr)
load(file = 'basic.sce.pbmc.Rdata')
sce=pbmc

参考可视化单细胞亚群的标记基因的5个方法

首先寻找每个细胞亚群的Mark基因

代码语言:javascript复制
features= c('IL7R', 'CCR7','CD14', 'LYZ',  'IL7R', 'S100A4',"MS4A1", "CD8A",'FOXP3',
            'FCGR3A', 'MS4A7', 'GNLY', 'NKG7',
            'FCER1A', 'CST3','PPBP')
DotPlot(sce, features = unique(features))   RotatedAxis()

image-20210607104517359

代码语言:javascript复制
sce.markers <- FindAllMarkers(object = sce, only.pos = TRUE,
                              min.pct = 0.25, 
                              thresh.use = 0.25)
代码语言:javascript复制
library(dplyr) 
## 健明老师视频中代码为avg_logFC,和我的seurat版本不一样,检查发现我对应的列名是avg_log2FC 
top5 <- sce.markers %>% group_by(cluster) %>% top_n(5, avg_log2FC)
DoHeatmap(sce,top5$gene,size=3)  
p <- DotPlot(sce,
  features = unique(top5$gene),
  assay = "RNA"
)   coord_flip()   
  theme(axis.text.x = element_text(
  angle = 45,
  vjust = 0.5, hjust = 0.5
  ))

image-20210607105215273

image-20210607104903421

这个函数不仅仅是接受一个向量,还可以接受一个列表,示例如下:

代码语言:javascript复制
head(top5)
top5=top5[!duplicated(top5$gene),]
select_genes_all=split(top5$gene,top5$cluster)
select_genes_all
DotPlot(
  object = sce,
  features = select_genes_all,
  assay = "RNA"
)  
  theme(axis.text.x = element_text(
    angle = 45,
    vjust = 0.5, hjust = 0.5
  ))

0 人点赞