-
Notifications
You must be signed in to change notification settings - Fork 0
/
KEGG_pathway_analysis.R
164 lines (122 loc) · 6.08 KB
/
KEGG_pathway_analysis.R
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
# Load required libraries
library(readxl)
library(clusterProfiler)
library(enrichplot)
library(DOSE)
library(org.Hs.eg.db)
library(pathfindR)
# Read Hela gene IDs data from Excel file
hela_genes <- read_excel("hela_idmap.xlsx")
# Read PDAC gene IDs data from Excel file
pdac <- read_excel("idmap.xlsx")
# Read Melanoma gene IDs data from Excel file
melanoma_genes <- read_excel("melanoma_idmap.xlsx")
# Read Monocytes gene IDs data from Excel file
monocytes_genes <- read_excel("monocytes_idmap.xlsx")
################################################################################
# Perform KEGG pathway enrichment analysis for Hela cells
hela_kegg <- enrichKEGG(gene = hela_genes$entrezgene,
organism = 'hsa',
pvalueCutoff = 0.05,
qvalueCutoff = 0.3,
keyType = "kegg")
# Generate a dotplot to visualize the enriched pathways for Hela cells
hela_kegg_dot <- dotplot(hela_kegg)
# Calculate pairwise similarity between enriched terms
he <- pairwise_termsim(hela_kegg)
# Generate an enriched map plot to visualize the connectivity between enriched terms
he_map <- emapplot(he, showCategory=10)
# Convert the gene IDs in the enriched pathways to readable format using the org.Hs.eg.db package
hecenter <- setReadable(hela_kegg, OrgDb = "org.Hs.eg.db",
keyType = "ENTREZID")
# Generate a cnetplot to visualize the enriched pathways for Hela cells
hela_kegg_cnet <- cnetplot(hecenter, foldChange=hela_kegg,
circular = F, colorEdge = TRUE,
node_lable="all", showCategory = 5)
################################################################################
# Perform KEGG pathway enrichment analysis for PDAC cells
pdac_kegg <- enrichKEGG(gene = pdac$entrezgene,
organism = 'hsa',
pvalueCutoff = 0.05,
qvalueCutoff = 0.3)
# Generate a dotplot to visualize the enriched pathways for PDAC cells
pdac_kegg_dot <- dotplot(pdac_kegg)
# Calculate pairwise similarity between enriched terms
pdkegg <- pairwise_termsim(pdac_kegg)
# Generate an enriched map plot to visualize the connectivity between enriched terms
pd_map <- emapplot(pdkegg, showCategory=10)
# Convert the gene IDs in the enriched pathways to readable format using the org.Hs.eg.db package
pkcenter <- setReadable(pdac_kegg, OrgDb = "org.Hs.eg.db",
keyType = "ENTREZID")
# Generate a cnetplot to visualize the enriched pathways for PDAC cells
pdac_kegg_cnet <- cnetplot(pkcenter, foldChange=pdac_kegg,
circular = F, colorEdge = TRUE,
node_lable="all", showCategory = 5)
################################################################################
# Perform KEGG pathway enrichment analysis for Melanoma cells
melanoma_kegg <- enrichKEGG(gene = melanoma_genes$entrezgene,
organism = 'hsa',
pvalueCutoff = 0.05,
qvalueCutoff = 0.3)
# Generate a dotplot to visualize the enriched pathways for Melanoma cells
melanoma_kegg_dot <- dotplot(melanoma_kegg)
# Calculate pairwise similarity between enriched terms
mk <- pairwise_termsim(melanoma_kegg)
# Generate an enriched map plot to visualize the connectivity between enriched terms
mela_map <- emapplot(mk, showCategory=10)
# Convert the gene IDs in the enriched pathways to readable format using the org.Hs.eg.db package
mkcenter <- setReadable(melanoma_kegg, OrgDb = "org.Hs.eg.db",
keyType = "ENTREZID")
# Generate a cnetplot to visualize the enriched pathways for Melanoma cells
mela_kegg_cnet <- cnetplot(mkcenter, foldChange=melanoma_kegg,
circular = F, colorEdge = TRUE,
node_lable="all", showCategory = 5)
################################################################################
# Perform KEGG pathway enrichment analysis for Monocytes cells
monocytes_kegg <- enrichKEGG(gene = monocytes_genes$entrezgene,
organism = 'hsa',
pvalueCutoff = 0.05,
qvalueCutoff = 0.3)
# Generate a dotplot to visualize the enriched pathways for Monocytes cells
monocytes_kegg_dot <- dotplot(monocytes_kegg)
# Calculate pairwise similarity between enriched terms
mok <- pairwise_termsim(monocytes_kegg)
# Generate an enriched map plot to visualize the connectivity between enriched terms
mok_emap <- emapplot(mok, showCategory=10)
# Convert the gene IDs in the enriched pathways to readable format using the org.Hs.eg.db package
mokcenter <- setReadable(monocytes_kegg, OrgDb = "org.Hs.eg.db",
keyType = "ENTREZID")
# Generate a cnetplot to visualize the enriched pathways for Monocytes cells
mono_kegg_cnet <- cnetplot(mokcenter, foldChange=monocytes_kegg,
circular = F, colorEdge = TRUE,
node_lable="all", showCategory = 5)
################################################################################
# Save dotplots of KEGG pathway analysis to png file
res <- 300
w <- 16
h <- 12
png("kegg_dot.png", width = w*res, height = h*res, res = res)
cowplot::plot_grid(monocytes_kegg_dot, hela_kegg_dot,
melanoma_kegg_dot, pdac_kegg_dot,
ncol = 2, labels = c('A', 'B', 'C', 'D'),
label_size = 24)
dev.off()
#####
# Save E-Map plots of KEGG pathway analysis to png file
res <- 300
w <- 16
h <- 12
png("kegg_E-Map.png", width = w*res, height = h*res, res = res)
cowplot::plot_grid(mok_emap, he_map, mela_map, pd_map, ncol = 2,
labels = c('A', 'B', 'C', 'D'), label_size = 24)
dev.off()
#####
# Save C-net plots of KEGG pathway analysis to png file
res <- 250
w <- 20
h <- 15
png("kegg_Cnet2.png", width = w*res, height = h*res, res = res)
cowplot::plot_grid(mono_kegg_cnet, hela_kegg_cnet, mela_kegg_cnet,
pdac_kegg_cnet, ncol = 2, labels = c('A', 'B', 'C', 'D'),
label_size = 24)
dev.off()