美文网首页ggplot集锦
批量产生gmt,批量使用gmt进行GSVA

批量产生gmt,批量使用gmt进行GSVA

作者: 一只小脑斧 | 来源:发表于2022-05-17 18:19 被阅读0次

setwd("C:/Users/86156/Desktop/gogogogo/fun/pro")

#先看一下例子

go <- fread("pancre.t.n.go.result (1).csv",data.table = F)#go的富集结果

go <- go[,c(3,9)]

item<-c("response to oxidative stress",

      "fatty acid metabolic process",

)

go <- go[go$Description %in% item,]

for(i in go$Description){

 # i<-"fatty acid metabolic process"

  data<-go[go$Description %in% i,]$geneID

  #按/分割

  a <- strsplit(data,split = "/") %>% as.data.frame()

  gset <- c(i,"NA",a[,1])

  gset <- gset%>%

    as.data.frame() %>%

    t()

  #将i中" "替换为"."

  i<-gsub(" ",".",i,fixed = T)

  #输出文件名

  outFile=paste0(i, ".gmt")

  #输出

  write.table(gset,file = outFile,sep = "\t",row.names = F,col.names = F,quote = F)

}

##########################################循环体应用算GSVA----

name<-c(

        "/data/ff/ref/list/Lipid and atherosclerosis.gmt",

        "/data/ff/ref/list/fatty acid metabolic process.gmt")

gsva.exp=data.frame()

library(GSEABase)

for(i in name){

  #i="/data/ff/ref/list/Cuproptosis.gmt"

  geneset <- GSEABase::getGmt(i)

  data <- gsva(pro, geneset)

  gsva.exp=rbind(gsva.exp,data)

}

write.csv(gsva.exp,"pro.gsva.exp.csv",row.names = TRUE)

相关文章

网友评论

    本文标题:批量产生gmt,批量使用gmt进行GSVA

    本文链接:https://www.haomeiwen.com/subject/dvmnurtx.html