-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathXGR_Enrichment.Rmd
99 lines (73 loc) · 2.53 KB
/
XGR_Enrichment.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
title: "Enrichment"
output:
html_document:
code_folding: hide
---
```{r, include=FALSE}
source('functions.R')
library(Pi)
library(DT)
knitr::opts_chunk$set(cache=TRUE, warning=FALSE, message=FALSE, error=FALSE, results='asis')
```
# Reactome
```{r,warning=FALSE,message=FALSE,error=FALSE}
files <- Sys.glob("results/*sig.csv")
for (i in files) {
name <- gsub(".csv","",i)
name <- gsub("results/","",name)
sig <- read.csv(file=as.character(i))
ontology <- "MsigdbC2REACTOME"
res <- gsub("_sig.csv","",i)
res <- paste0(res, "_res.csv")
background <- as.vector(toupper(read.csv(res)$SYMBOL))
data <- as.vector(toupper(read.csv(i)$SYMBOL))
eTerm <- xEnricherGenes(data=data, background=background, ontology=ontology)
dir.create(file.path("enrichment_XGR"), showWarnings = FALSE)
dir.create(file.path("enrichment_XGR", ontology), showWarnings = FALSE)
output <- paste0("enrichment_XGR","/", ontology, "/", name, ".csv")
write.csv(file=as.character(output), as.data.frame(xEnrichViewer(eTerm)))
assign(paste("eTerm", i, sep = "."), eTerm)
}
```
### Bar plot of the enrichment {.tabset .tabset-fade}
```{r,echo=FALSE,warning=FALSE,message=FALSE,error=FALSE}
for (i in files) {
eTerm <- get(gsub("SAMPLE_FILE",i , "eTerm.SAMPLE_FILE"))
bp <- xEnrichBarplot(eTerm, top_num="auto", displayBy="adjp")
name <- gsub(".csv","",i)
cat("#### ",name,"\n")
print(bp)
cat('\n\n')
}
```
## KEGG
```{r,warning=FALSE,message=FALSE,error=FALSE}
files <- Sys.glob("results/*sig.csv")
for (i in files) {
name <- gsub(".csv","",i)
name <- gsub("results/","",name)
sig <- read.csv(file=as.character(i))
ontology <- "MsigdbC2KEGG"
res <- gsub("_sig.csv","",i)
res <- paste0(res, "_res.csv")
background <- as.vector(toupper(read.csv(res)$SYMBOL))
data <- as.vector(toupper(read.csv(i)$SYMBOL))
eTerm <- xEnricherGenes(data=data, background=background, ontology=ontology)
dir.create(file.path("enrichment_XGR", ontology), showWarnings = FALSE)
output <- paste0("enrichment_XGR","/", ontology, "/", name, ".csv")
write.csv(file=as.character(output), as.data.frame(xEnrichViewer(eTerm)))
assign(paste("eTerm", i, sep = "."), eTerm)
}
```
### Bar plot of the enrichment {.tabset .tabset-fade}
```{r,echo=FALSE,warning=FALSE,message=FALSE,error=FALSE, results='asis'}
for (i in files) {
eTerm <- get(gsub("SAMPLE_FILE",i , "eTerm.SAMPLE_FILE"))
bp <- xEnrichBarplot(eTerm, top_num="auto", displayBy="adjp")
name <- gsub(".csv","",i)
cat("####",name,"\n")
print(bp)
cat('\n\n')
}
```