#高级版的多个单细胞亚群的多个标记基因可视化
rm(list = ls())
library(Seurat)
library(SeuratData)
library(ggplot2)
library(patchwork)
library(dplyr)
load(file = 'basic.sce.pbmc.Rdata')
DimPlot(pbmc,
reduction = 'umap',
label = TRUE, pt.size = 0.5) + NoLegend()
sce=pbmc
features= c('IL7R', 'CCR7','CD14', 'LYZ', 'IL7R', 'S100A4',"MS4A1", "CD8A",'FOXP3',
'FCGR3A', 'MS4A7', 'GNLY', 'NKG7',
'FCER1A', 'CST3','PPBP')
DotPlot(sce,
features = unique(features)) + RotatedAxis()
if (file.exists('sce.markers.all_10_celltype.Rdata')) {
load('sce.markers.all_10_celltype.Rdata')
}else {
sce.markers <- FindAllMarkers(object = sce, only.pos = TRUE,
min.pct = 0.25,
thresh.use = 0.25)
save(sce.markers,file = 'sce.markers.all_10_celltype.Rdata')
}
DT::datatable(sce.markers)
library(dplyr)
#不同seurat版本的avg_logFC 不一样
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()
p+ 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))

图 高级版本的多个单细胞亚群的多个标记基因可视化
