其他
doplot可视化多个单细胞亚群的多个标记基因(2021公开课配套笔记)
新课发布在B站了,马上有热心的粉丝看完后写了配套笔记:
依旧seurat 官方教程为例
rm(list = ls())
library(Seurat)
library(ggplot2)
library(patchwork)
library(dplyr)
load(file = 'basic.sce.pbmc.Rdata')
sce=pbmc
首先寻找每个细胞亚群的Mark基因
features= c('IL7R', 'CCR7','CD14', 'LYZ', 'IL7R', 'S100A4',"MS4A1", "CD8A",'FOXP3',
'FCGR3A', 'MS4A7', 'GNLY', 'NKG7',
'FCER1A', 'CST3','PPBP')
DotPlot(sce, features = unique(features)) + RotatedAxis()
sce.markers <- FindAllMarkers(object = sce, only.pos = TRUE,
min.pct = 0.25,
thresh.use = 0.25)
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
))
这个函数不仅仅是接受一个向量,还可以接受一个列表,示例如下:
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
))
文末友情推荐
与十万人一起学生信,你值得拥有下面的学习班: