当前位置:   article > 正文

UCell:单细胞评分分析R包及可视化应用_ucell r语言

ucell r语言

****单细胞评分我们之前说过AUCell和seurat自带的打分函数
跟着Cell学单细胞转录组分析(十一):单细胞基因评分|AUCell评分
我们之前讲过单细胞评分,一个是Seurat自带的打分函AddModuleScore()。一个是AUcell包。最近看到一个评分R包,感觉还是挺好的这里分享一下。Ucell是基于Mann-Whitney U统计的单细胞评分R包,灵感来源于SUCell,使用起来稳定性较好,且与其他的方式相比较,Ucell计算所需的时间和耗费的内存更小。即使在计算能力有限的机器上也可以在几分钟内处理大型数据集。UCell可以应用于任何单细胞数据矩阵,可直接与Seurat对象交互。Ucell在高分SCI文章的应用还是挺多的,我们在自己的分析中也可以视情况选择使用。原始文献参考: https://www.sciencedirect.com/science/article/pii/S2001037021002816?via%3Dihub这里我们使用seurat单细胞对象进行演示。首先对单细胞marker基因的评分,这个有利于细胞分群的鉴定。

  1. setwd('D:/KS项目/公众号文章/Ucell单细胞评分')
  2. library(Seurat)
  3. BiocManager::install("UCell")
  4. library(UCell)
  5. uterus <- readRDS("D:/KS项目/公众号文章/uterus.rds")
  6. DimPlot(uterus,label = T)+NoLegend()
  7. #UCell评分函数AddModuleScore_UCell可以提供方seurat对象
  8. #评分基因set是以list的形式提供
  9. markers <- list()
  10. markers$SM <- c("ACTA2", "RGS5")
  11. markers$Marc <- c("MS4A6A", "CD68","LYZ")
  12. markers$Ly <- c("CCL5", "STK17B","PTPRC")
  13. markers$SF <- c("DCN", "COL6A3", "LUM")
  14. markers$Endo <- c("PECAM1","PCDH17", "VWF")
  15. markers$unEP <- c("EPCAM", "CDH1")
  16. markers$cEP <- c("FOXJ1","CDHR3","DYDC2")
  17. #评分计算
  18. marker_score <- AddModuleScore_UCell(uterus,
  19. features=markers)
  20. #可视化是Ucell score
  21. library(stringr)
  22. library(ggplot2)
  23. library(viridis)
  24. a <- colnames(marker_score@meta.data) %>% str_subset("_UCell")
  25. FeaturePlot(marker_score,features = a,order = T, ncol = 4, cols = viridis(256))

image.png

第二个是对于通路的评分,并进行可视化,参考这篇文章:

image.png

(reference:A reference single-cell regulomic and transcriptomic map of cynomolgus monkeys)

  1. library(clusterProfiler)
  2. metabolism <- read.gmt("KEGG_metabolism_nc.gmt")
  3. unique(metabolism$term)
  4. #我们选择其中一条通路进行评分
  5. Oxidative <- subset(metabolism, term=="Oxidative phosphorylation")
  6. Oxidative <- list(Oxidative$gene)#将基因整成list
  7. names(Oxidative)[1] <- 'Oxidative'
  8. DefaultAssay(uterus) <- 'RNA'
  9. metabolism_score <- AddModuleScore_UCell(uterus,
  10. features=Oxidative,
  11. name="_metabolism_score")
  12. #可视化所有细胞
  13. FeaturePlot(metabolism_score,features = "Oxidative_metabolism_score",
  14. order = T,cols = viridis(256))
  15. FeaturePlot(metabolism_score,features = "Oxidative_metabolism_score",
  16. order = T,cols = viridis(256), split.by = 'orig.ident')

image.png

箱线图

  1. library(ggrastr)
  2. library(dplyr)
  3. data<- FetchData(metabolism_score,vars = c("celltype","Oxidative_metabolism_score"))
  4. data$cellid <- case_when(data$celltype ==unique(data$celltype)[1] ~ "SMC",
  5. data$celltype ==unique(data$celltype)[2] ~ 'Ly',
  6. data$celltype ==unique(data$celltype)[3] ~ 'unEP',
  7. data$celltype ==unique(data$celltype)[4] ~ 'SF',
  8. data$celltype ==unique(data$celltype)[5] ~ 'cEP',
  9. data$celltype ==unique(data$celltype)[6] ~ 'Endo',
  10. data$celltype ==unique(data$celltype)[7] ~ 'Macro')
  11. colors <- c('#507BA8','#F38D37','#5D9F53','#B5972D','#48998E','#E05758','#F1CE60')
  12. ggplot(data, aes(x=cellid,y=Oxidative_metabolism_score,fill=cellid,color=cellid)) +
  13. theme_bw()+RotatedAxis()+
  14. theme(panel.grid = element_blank(),
  15. axis.text.x=element_text(size=12),
  16. axis.text.y = element_text(size=10),
  17. plot.title = element_text(hjust = 0.5),
  18. legend.position = 'none')+
  19. labs(x=NULL,y=NULL,title = "Oxidative_metabolism_score")+
  20. geom_jitter_rast(col="#00000033", pch=19,cex=2, position = position_jitter(0.2))+
  21. geom_boxplot(position=position_dodge(0))+
  22. scale_fill_manual(values = colors)+
  23. geom_boxplot(position=position_dodge(0),color='black',
  24. outlier.colour = NA,outlier.fill=NA,outlier.shape=NA)

image.png

这里卖个关子,我们做了那么多的ggplot可视化,给大家思考一下,细胞数是如何添加上的(纯代码,简单的方式)。

image.png

第三种应用是对于基因集的评分。看看这些评分在我们样本之间的差异。

  1. #做基因集评分
  2. genes <- list(c("PTEN","PIK3CA","KRAS","ARID1A","RCA1","WNT5A"))
  3. names(genes) <- 'gene'
  4. gene_score <- AddModuleScore_UCell(uterus,features=genes,name="_score")
  5. #提取数据
  6. library(ggpubr)
  7. df<- FetchData(gene_score,vars = c("orig.ident","gene_score"))
  8. df$orig.ident <- factor(df$orig.ident,levels = c("HC","EEC","AEH"))#设置顺序
  9. #设置比较组
  10. my_comparisons1 <- list(c("HC", "EEC"))
  11. my_comparisons2 <- list(c("AEH", "EEC"))
  12. my_comparisons3 <- list(c("HC", "AEH"))
  13. #做小提琴图
  14. ggplot(df,aes(x=orig.ident,y=gene_score,fill=orig.ident))+
  15. geom_violin(color='black',size=1)+#小提琴
  16. theme_classic() +
  17. theme(text = element_text(size=10, colour = "black")) +
  18. theme(plot.title = element_text(hjust = 0.5, size = 15),
  19. axis.text.x = element_text(colour = "black", size = 12),
  20. axis.text.y = element_text(colour = "black", size = 10),
  21. axis.title.y = element_text(color = 'black', size = 12),
  22. axis.line = element_line(size = 1))+
  23. theme(legend.position="none") +
  24. geom_boxplot(width=0.1, fill="white", outlier.shape = NA) +#箱线图
  25. stat_compare_means(method="t.test",hide.ns = F,
  26. comparisons =c(my_comparisons1,my_comparisons2,my_comparisons3),
  27. label="p.signif",
  28. bracket.size=0.8,
  29. size=6)#添加显著性比较

image.png

这个方法用在自己的数据集研究中还是挺有用的,觉得分享有用的点个赞,点一下分享再走呗!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/882335
推荐阅读
相关标签
  

闽ICP备14008679号