下载gmt文档做GSEA

2022-02-14  本文已影响0人  找兔子的小萝卜
rm(list = ls())
options(stringsAsFactors = F)
library(msigdbr)
library(fgsea)
library(org.Mm.eg.db)
library(dplyr)
library(clusterProfiler)

#处理自己所要看的数据集(包含所有的基因)
hsc_vd<-deg
hsc_vdID<- bitr(hsc_vd$`Gene symbol`, fromType = "SYMBOL",
             toType="ENTREZID",
             OrgDb = org.Mm.eg.db)
hsc_vdall<-inner_join(hsc_vd,hsc_vdID,by=c("Gene symbol"="SYMBOL"))
write.csv(hsc_vdall,"hacvdall.csv",row.names = F)

## 1.而后对所要看hsc_vdall按照logFC进行排序
geneList1 <- hsc_vdall$logFC
## 2.命名
names(geneList1) = hsc_vdall$`Gene symbol`
## 3.排序很重要
geneList1 = sort(geneList1, decreasing = TRUE)
head(geneList1)
save(geneList1,file = "hscvd rank gens.Rdata")

##4读取gmt基因集下载于https://www.gsea-msigdb.org/gsea/downloads.jsp
kegmt<-read.gmt("MousePath_Metabolic_gmt (1).gmt") #读gmt文件
kegmt1=kegmt[2:67,]
kegmt1$GENE=tolower(kegmt1$gene)#小写
library(Hmisc)
kegmt1$GENE=capitalize(kegmt1$GENE)
kegmt3=kegmt1[,-2]



KEGG<-GSEA(geneList1,TERM2GENE = kegmt3,minGSSize = 1,
           maxGSSize = 500,
           pvalueCutoff =1) #GSEA分析


library(enrichplot)
gseaplot2(KEGG,1,color="red",pvalue_table = T)
上一篇下一篇

猜你喜欢

热点阅读