-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPathway Enrichment Analysis.Rmd
executable file
·196 lines (172 loc) · 4.68 KB
/
Pathway Enrichment Analysis.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
---
title: "Introduction to Bioinformatics Final Project 236523"
author: "Ben Filiarsky 207941287, Yotam Martin 308044296"
output:
html_notebook: default
---
# Load data
```{r message=FALSE, warning=FALSE}
library(R.utils);
library(tidyverse);
library(SummarizedExperiment);
# Load summary of the expression results
load("E-GEOD-78936-atlasExperimentSummary.Rdata")
# Get the coldata
coldata <- as.data.frame(colData(experimentSummary$rnaseq))
# One option to read is from the experimentSummary
# But this doesn't have the gene name
# countdata <- assay(experimentSummary$rnaseq)
# Second option is to read the raw counts from Atlas with the gene name
countdata <- read_tsv("E-GEOD-78936-raw-counts.tsv")
```
# Import libraries
```{r}
library(dplyr);
library(pathfindR);
```
# Read the results for exp1-6 significant genes (no normalization)
```{r}
# data for up, down regulated genes in experiments 1,3,5
# (1-6 but no significant genes in 2,4,6)
# (the only ones who have significant genes expression)
exp1_3_5_data <- read_csv('significant_genes_by_experiment_no_norm.csv')
# data separated by experiment
exp1_data <- exp1_3_5_data[which(exp1_3_5_data$Exp == 1), ]
exp3_data <- exp1_3_5_data[which(exp1_3_5_data$Exp == 3), ]
exp5_data <- exp1_3_5_data[which(exp1_3_5_data$Exp == 5), ]
```
# Run pathfindR analysis
```{r}
for (df in list(exp1_3_5_data, exp1_data, exp3_data, exp5_data)) {
data <-
as.data.frame(df %>% select('Gene.symbol', 'logFC', 'adj.P.Val'))
pathfindr_res <-
run_pathfindR(
data,
gene_sets = "KEGG",
output_dir = paste(
"pathfindR_Results_exp_",
paste(unique(as.data.frame(df)$Exp), collapse = '_'),
sep = ''
)
)
enrichment_chart(RA_clustered, plot_by_cluster = TRUE)
RA_clustered <- cluster_enriched_terms(pathfindr_res)
# Plot Enrichment Plot
plot_path <- paste(
paste(
"pathfindR_Results_exp_",
paste(unique(as.data.frame(df)$Exp), collapse = '_'),
sep = ''
),
"/enrichment_plot.tiff",
collapse = "",
sep = ""
)
tiff(
plot_path,
compression = "lzw",
res = 144,
width = 960,
height = 960
)
enrichment_plot <-
enrichment_chart(RA_clustered, plot_by_cluster = TRUE)
print(enrichment_plot)
dev.off()
term_plot <- term_gene_graph(result_df = pathfindr_res)
print(term_plot)
}
```
# Pathway enrichment analysis with general housekeeping genes
```{r}
# only exp1 got significant genes
exp1_general_data <- read_csv('significant_genes_by_experiment_general.csv')
df <- exp1_general_data
data <-
as.data.frame(df %>% select('Gene.symbol', 'logFC', 'adj.P.Val'))
pathfindr_res <-
run_pathfindR(
data,
gene_sets = "KEGG",
output_dir = paste(
"pathfindR_Results_exp_",
paste(unique(as.data.frame(df)$Exp), collapse = '_'),
"_general",
sep = ''
)
)
enrichment_chart(RA_clustered, plot_by_cluster = TRUE)
RA_clustered <- cluster_enriched_terms(pathfindr_res)
# Plot Enrichment Plot
plot_path <- paste(
paste(
"pathfindR_Results_exp_",
paste(unique(as.data.frame(df)$Exp), collapse = '_'),
"_general",
sep = ''
),
"/enrichment_plot.tiff",
collapse = "",
sep = ""
)
tiff(
plot_path,
compression = "lzw",
res = 144,
width = 960,
height = 960
)
enrichment_plot <-
enrichment_chart(RA_clustered, plot_by_cluster = TRUE)
print(enrichment_plot)
dev.off()
term_plot <- term_gene_graph(result_df = pathfindr_res)
print(term_plot)
```
# Pathway enrichment analysis with brain housekeeping genes
```{r}
# only exp1 got significant genes
exp1_brain_data <- read_csv('significant_genes_by_experiment_brain.csv')
df <- exp1_brain_data
data <-
as.data.frame(df %>% select('Gene.symbol', 'logFC', 'adj.P.Val'))
pathfindr_res <-
run_pathfindR(
data,
gene_sets = "KEGG",
output_dir = paste(
"pathfindR_Results_exp_",
paste(unique(as.data.frame(df)$Exp), collapse = '_'),
"_brain",
sep = ''
)
)
enrichment_chart(RA_clustered, plot_by_cluster = TRUE)
RA_clustered <- cluster_enriched_terms(pathfindr_res)
# Plot Enrichment Plot
plot_path <- paste(
paste(
"pathfindR_Results_exp_",
paste(unique(as.data.frame(df)$Exp), collapse = '_'),
"_brain",
sep = ''
),
"/enrichment_plot.tiff",
collapse = "",
sep = ""
)
tiff(
plot_path,
compression = "lzw",
res = 144,
width = 960,
height = 960
)
enrichment_plot <-
enrichment_chart(RA_clustered, plot_by_cluster = TRUE)
print(enrichment_plot)
dev.off()
term_plot <- term_gene_graph(result_df = pathfindr_res)
print(term_plot)
```