查看原文
其他

单细胞转录组基础分析七:差异基因富集分析

Kinesin 生信会客厅 2022-06-07
单细胞测序技术是近年最大的生命科学突破之一,相关文章频繁发表于各大顶级期刊,然而单细胞数据的分析依然是大家普遍面临的障碍。本专题将针对10X Genomics单细胞转录组数据演示各种主流分析,包括基于Seurat的基础分析、以及基于clusterProfiler、Monocle、SingleR等R包的延伸分析。不足之处请大家批评指正,欢迎添加Kinesin微信交流探讨!(扫描文末二维码)


此前的分析我们按转录特征把细胞分成了很多类别,例如seurat聚类分析得到的按cluster分类,singleR分析得到的按细胞类型分类,monocle分析得到的按拟时状态(state)分类。不同的细胞类型之间,有哪些表达差异基因呢,这些差异基因有特别的意义吗?


基因差异表达分析

library(Seurat)library(tidyverse)library(patchwork)library(monocle)library(clusterProfiler)library(org.Hs.eg.db)rm(list=ls())dir.create("enrich")scRNA <- readRDS("scRNA.rds")mycds <- readRDS("mycds.rds")#比较cluster0和cluster1的差异表达基因dge.cluster <- FindMarkers(scRNA,ident.1 = 0,ident.2 = 1)sig_dge.cluster <- subset(dge.cluster, p_val_adj<0.01&abs(avg_logFC)>1)#比较B_cell和T_cells的差异表达基因dge.celltype <- FindMarkers(scRNA, ident.1 = 'B_cell', ident.2 = 'T_cells', group.by = 'celltype')sig_dge.celltype <- subset(dge.celltype, p_val_adj<0.01&abs(avg_logFC)>1)#比较拟时State1和State3的差异表达基因p_data <- subset(pData(mycds),select='State')scRNAsub <- subset(scRNA, cells=row.names(p_data))scRNAsub <- AddMetaData(scRNAsub,p_data,col.name = 'State')dge.State <- FindMarkers(scRNAsub, ident.1 = 1, ident.2 = 3, group.by = 'State')sig_dge.State <- subset(dge.State, p_val_adj<0.01&abs(avg_logFC)>1)

差异基因GO富集分析

#差异基因GO富集分析ego_ALL <- enrichGO(gene = row.names(sig_dge.celltype), #universe = row.names(dge.celltype), OrgDb = 'org.Hs.eg.db', keyType = 'SYMBOL', ont = "ALL", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05)ego_all <- data.frame(ego_ALL)write.csv(ego_all,'enrich/enrichGO.csv') ego_CC <- enrichGO(gene = row.names(sig_dge.celltype), #universe = row.names(dge.celltype), OrgDb = 'org.Hs.eg.db', keyType = 'SYMBOL', ont = "CC", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05)ego_MF <- enrichGO(gene = row.names(sig_dge.celltype), #universe = row.names(dge.celltype), OrgDb = 'org.Hs.eg.db', keyType = 'SYMBOL', ont = "MF", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05)ego_BP <- enrichGO(gene = row.names(sig_dge.celltype), #universe = row.names(dge.celltype), OrgDb = 'org.Hs.eg.db', keyType = 'SYMBOL', ont = "BP", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05) ego_CC@result$Description <- substring(ego_CC@result$Description,1,70)ego_MF@result$Description <- substring(ego_MF@result$Description,1,70)ego_BP@result$Description <- substring(ego_BP@result$Description,1,70)p_BP <- barplot(ego_BP,showCategory = 10) + ggtitle("barplot for Biological process")p_CC <- barplot(ego_CC,showCategory = 10) + ggtitle("barplot for Cellular component")p_MF <- barplot(ego_MF,showCategory = 10) + ggtitle("barplot for Molecular function")plotc <- p_BP/p_CC/p_MFggsave('enrich/enrichGO.png', plotc, width = 12,height = 10)

差异基因kegg富集分析

genelist <- bitr(row.names(sig_dge.celltype), fromType="SYMBOL", toType="ENTREZID", OrgDb='org.Hs.eg.db')genelist <- pull(genelist,ENTREZID) ekegg <- enrichKEGG(gene = genelist, organism = 'hsa')p1 <- barplot(ekegg, showCategory=20)p2 <- dotplot(ekegg, showCategory=20)plotc = p1/p2ggsave("enrich/enrichKEGG.png", plot = plotc, width = 12, height = 10)

获取帮助

本教程的目的在于把常用的单细胞分析流程串起来,适合有一定R语言基础的朋友参考。分析原理和代码我没有详细解释,官网有详细的教程和权威的解释,翻译好的中文教程也有多个版本,有兴趣的可以搜索一下。如果您学习本教程有一定困难,可以分享此篇文章到朋友圈,截图微信发给Kinesin(文末二维码),我会抽时间组群直播讲解单细胞数据分析的全过程。本专题所用的软件、数据、代码脚本和中间结果,我打包放在了百度云上,需要的朋友添加Kinesin微信索取。



您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存