從富集的結(jié)果中導(dǎo)出富集在通路中的基因
ExportPathwayGene <- function(pathway_result){
fram <- data.frame()
for (i in seq(length(pathway_result$Description))){
try(fram_1 <- data.frame(Description=pathway_result$Description[i],ENTREZID=strsplit(pathway_result$geneID[i],split="/")[[1]],pvalue=pathway_result$pvalue[i]))
try(fram <- rbind(fram,fram_1))
}
transformID <- bitr(fram$ENTREZID,toType="SYMBOL",fromType="ENTREZID",OrgDb="org.Mm.eg.db")
symbol <- transformID$SYMBOL[match(fram$ENTREZID,transformID$ENTREZID)]
fram <- cbind(fram,symbol)#通路中基因的datafram
return(fram)
}
從GSEA富集的結(jié)果中導(dǎo)出富集在通路中的基因
ExportPathwayGene <- function(GSEA_pathway_result){
fram <- data.frame()
for (i in seq(length(GSEA_pathway_result[[1]]$Description))){
try(fram_1 <- data.frame(Description=GSEA_pathway_result[[1]]$Description[i],ENTREZID=strsplit(GSEA_pathway_result[[1]]$core_enrichment[i],split="/")[[1]]),pvalue=GSEA_pathway_result[[1]]$pvalue[i])
try(fram <- rbind(fram,fram_1))
}
transformID <- bitr(fram$ENTREZID,toType="SYMBOL",fromType="ENTREZID",OrgDb="org.Mm.eg.db")
symbol <- transformID$SYMBOL[match(fram$ENTREZID,transformID$ENTREZID)]
fram <- cbind(fram,symbol)#通路中基因的datafram
return(fram)
}
從富集的結(jié)果中導(dǎo)出富集在所有GO中的基因
ExportGOGene <- function(go.result){
fram <- data.frame()
for (i in seq(length(go.result$Description))){
try(fram_1 <- data.frame(Description=go.result$Description[i],ENSEMBL=strsplit(go.result$geneID[i],split="/")[[1]],pvalue=go.result$pvalue[i]))
try(fram <- rbind(fram,fram_1))
}
transformID <- bitr(fram$ENSEMBL,toType="SYMBOL",fromType="ENSEMBL",OrgDb="org.Mm.eg.db")
symbol <- transformID$SYMBOL[match(fram$ENSEMBL,transformID$ENSEMBL)]
fram <- cbind(fram,symbol)#通路中基因的datafram
return(fram)
}
導(dǎo)出某個(gè)GO item中的所有差異基因
ExtractGoGene <- function(enrich.result,description){
fram <- data.frame()
for (i in seq(length(enrich.result$Description))){
fram_1 <- cbind(enrich.result$Description[i],strsplit(enrich.result$geneID[i],split="/")[[1]])
fram <- rbind(fram,fram_1)
}
transformID <- bitr(fram$V2,toType="SYMBOL",fromType="ENSEMBL",OrgDb="org.Mm.eg.db")
symbol <- transformID$SYMBOL[match(fram$V2,transformID$ENSEMBL)]
fram <- cbind(fram,symbol)#通路中基因的datafram
keygenes <- fram$symbol[which(fram$V1==description)]
return(keygenes)
}
導(dǎo)出某個(gè)通路中的所有差異基因
ExtractKeggGene <- function(enrich.result,description){
fram <- data.frame()
for (i in seq(length(enrich.result$Description))){
fram_1 <- cbind(enrich.result$Description[i],strsplit(enrich.result$geneID[i],split="/")[[1]])
fram <- rbind(fram,fram_1)
}
transformID <- bitr(fram$V2,toType="SYMBOL",fromType="ENTREZID",OrgDb="org.Mm.eg.db")
symbol <- transformID$SYMBOL[match(fram$V2,transformID$ENTREZID)]
fram <- cbind(fram,symbol)#通路中基因的datafram
keygenes <- fram$symbol[which(fram$V1==description)]
return(keygenes)
}