-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoanalysis.R
266 lines (227 loc) · 10.5 KB
/
Goanalysis.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
BiocManager::install("AnnotationDbi")
BiocManager::install("org.At.tair.db")
BiocManager::install("clusterProfiler")
BiocManager::install("enrichplot")
library("AnnotationDbi")
library("clusterProfiler")
library("org.At.tair.db")
library("dplyr")
library("pathview")
##############################################################################################################################################
HDLmerge_entrez <- HDL_annot$geneId
# Return the gene symbol for the set of Entrez IDs
HDLmerge_annot_db <- AnnotationDbi::select(org.At.tair.db,
keys = HDLmerge_entrez,
columns = c("GENENAME"),
keytype = "TAIR")
# Change IDs to character type to merge
HDLmerge_annot_db$TAIR <- as.character(HDLmerge_annot_db$TAIR)
# Write to file
HDL_annot %>% left_join(HDLmerge_annot_db, by=c("geneId"="TAIR")) %>% write.table(file="HDLmerge_GO.txt", sep="\t", quote=F, row.names=F)
# Run GO enrichment analysis: BP
HDLmerge_ego <- enrichGO(gene = HDLmerge_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "BP",
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
HDLmerge_cluster_summary <- data.frame(HDLmerge_ego)
write.csv(HDLmerge_cluster_summary, "HDLmerge_BP.csv")
# Dotplot visualization
dotplot(HDLmerge_ego, x = "Count",
color = "qvalue",
showCategory = 20,
font.size = 10)
help(enrichGO)
# Run GO enrichment analysis: ALL
HDLmerge_all <- enrichGO(gene = HDLmerge_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "ALL",
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
HDLmerge_cluster_summary_ALL <- data.frame(HDLmerge_all)
write.csv(HDLmerge_cluster_summary_ALL, "HDLmerge_ALL.csv")
# Dotplot visualization
dotplot(HDLmerge_all, x = "Count",
color = "qvalue",
showCategory = 10,
font.size = 8, split="ONTOLOGY") + facet_grid(ONTOLOGY~., scale="free")
#################################################################################################################################
# Get the entrez IDs
mhd_wt_entrez <- mhd_wt_bamcommon_annot$geneId
# Return the gene symbol for the set of Entrez IDs
mhd_wt_annot_db <- AnnotationDbi::select(org.At.tair.db,
keys = mhd_wt_entrez,
columns = c("GENENAME"),
keytype = "TAIR")
View(mhd_wt_annot_db)
# Change IDs to character type to merge
mhd_wt_annot_db$TAIR <- as.character(mhd_wt_annot_db$TAIR)
# Write to file
mhd_wt_bamcommon_annot %>% left_join(mhd_wt_annot_db, by=c("geneId"="TAIR")) %>% write.table(file="mhd_wt_bamcommon_GO.txt", sep="\t", quote=F, row.names=F)
# Run GO enrichment analysis: BH refers to the Benjamini-Hochberg method
mhd_wt_bamcommon_ego <- enrichGO(gene = mhd_wt_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "ALL",
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
mhd_wt_bamcommon_cluster_summary <- data.frame(mhd_wt_bamcommon_ego)
write.csv(mhd_wt_bamcommon_cluster_summary, "mhd_wt_bamcommon_ALL.csv")
# Dotplot visualization
dotplot(mhd_wt_bamcommon_ego, x = "Count",
color = "qvalue",
showCategory = 50,
font.size = 5)
##############################################################################################################################################
# Get the entrez IDs
wtmerge_entrez <- wtmerge_in2_peaks_annot$geneId
# Return the gene symbol for the set of Entrez IDs
wtmerge_annot_db <- AnnotationDbi::select(org.At.tair.db,
keys = wtmerge_entrez,
columns = c("GENENAME"),
keytype = "TAIR")
# Change IDs to character type to merge
wtmerge_annot_db$TAIR <- as.character(wtmerge_annot_db$TAIR)
# Write to file
wtmerge_in2_peaks_annot %>% left_join(wtmerge_annot_db, by=c("geneId"="TAIR")) %>% write.table(file="wtmerge_GO.txt", sep="\t", quote=F, row.names=F)
# Run GO enrichment analysis: BP
wtmerge_ego <- enrichGO(gene = wtmerge_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "BP",
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
wtmerge_cluster_summary <- data.frame(wtmerge_ego)
write.csv(wtmerge_cluster_summary, "wtmerge_BP.csv")
goplot(wtmerge_ego, font.size = 1, showCategory = 10,
color = "qvalue",
layout = "sugiyama",
geom = "label")
# Dotplot visualization
dotplot(wtmerge_ego, x = "Count",
color = "qvalue",
showCategory = 20,
font.size = 10)
# Run GO enrichment analysis: ALL
wtmerge_all <- enrichGO(gene = wtmerge_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "ALL",
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
wtmerge_cluster_summary_all <- data.frame(wtmerge_all)
write.csv(wtmerge_cluster_summary_all, "wtmerge_ALL.csv")
# Dotplot visualization
wt<-dotplot(wtmerge_all, x = "Count",
color = "qvalue",
showCategory = 10,
font.size = 10, split="ONTOLOGY") + facet_grid(ONTOLOGY~., scale="free")
##############################################################################################################################################
# Get the entrez IDs
mhdmerge_entrez <- mhdmerge_in2_peaks_annot$geneId
# Return the gene symbol for the set of Entrez IDs
mhdmerge_annot_db <- AnnotationDbi::select(org.At.tair.db,
keys = mhdmerge_entrez,
columns = c("GENENAME"),
keytype = "TAIR")
# Change IDs to character type to merge
mhdmerge_annot_db$TAIR <- as.character(mhdmerge_annot_db$TAIR)
# Write to file
mhdmerge_in2_peaks_annot %>% left_join(mhdmerge_annot_db, by=c("geneId"="TAIR")) %>% write.table(file="mhdmerge_GO.txt", sep="\t", quote=F, row.names=F)
# Run GO enrichment analysis: BP
mhdmerge_ego <- enrichGO(gene = mhdmerge_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "BP",
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
mhdmerge_cluster_summary <- data.frame(mhdmerge_ego)
write.csv(mhdmerge_cluster_summary, "mhdmerge_BP.csv")
# Dotplot visualization
dotplot(mhdmerge_ego, x = "Count",
color = "qvalue",
showCategory = 20,
font.size = 10)
help(enrichGO)
# Run GO enrichment analysis: ALL
mhdmerge_all <- enrichGO(gene = mhdmerge_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "ALL",
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
mhdmerge_cluster_summary_ALL <- data.frame(mhdmerge_all)
write.csv(mhdmerge_cluster_summary_ALL, "mhdmerge_ALL.csv")
# Dotplot visualization
mhd<-dotplot(mhdmerge_all, x = "Count",
color = "qvalue",
showCategory = 20,
font.size = 10, split="ONTOLOGY") + facet_grid(ONTOLOGY~., scale="free")
###################################################################FDR#########################################################################
setwd('/data/2023_DAPseq/HDL_DAP-seq/11chipseeker/bammerge/FDR')
# Get the entrez IDs
mhdmerge_entrez <- mhdmerge_in2_peaks_annot$geneId
# Return the gene symbol for the set of Entrez IDs
mhdmerge_annot_db <- AnnotationDbi::select(org.At.tair.db,
keys = mhdmerge_entrez,
columns = c("GENENAME"),
keytype = "TAIR")
# Change IDs to character type to merge
mhdmerge_annot_db$TAIR <- as.character(mhdmerge_annot_db$TAIR)
# Write to file
mhdmerge_in2_peaks_annot %>% left_join(mhdmerge_annot_db, by=c("geneId"="TAIR")) %>% write.table(file="mhdmerge_GO.txt", sep="\t", quote=F, row.names=F)
# Run GO enrichment analysis: BP
mhdmerge_ego <- enrichGO(gene = mhdmerge_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "BP",
pAdjustMethod = "fdr",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
mhdmerge_cluster_summary <- data.frame(mhdmerge_ego)
write.csv(mhdmerge_cluster_summary, "mhdmerge_BP.csv")
# Dotplot visualization
dotplot(mhdmerge_ego, x = "Count",
color = "p.adjust",
showCategory = 20,
font.size = 10)
help(enrichGO)
# Run GO enrichment analysis: ALL
mhdmerge_all <- enrichGO(gene = mhdmerge_entrez,
keyType = "TAIR",
OrgDb = org.At.tair.db,
ont = "ALL",
pAdjustMethod = "fdr",
qvalueCutoff = 0.05,
readable = TRUE)
# Output results from GO analysis to a table
mhdmerge_cluster_summary_ALL <- data.frame(mhdmerge_all)
write.csv(mhdmerge_cluster_summary_ALL, "mhdmerge_ALL.csv")
# Dotplot visualization
dotplot(mhdmerge_all, x = "Count",
color = "p.adjust",
showCategory = 20,
font.size = 10)
##############################################################################################################################################
# Dotplot visualization: combined
dotplot(mhdmerge_all, x = "Count",
color = "qvalue",
showCategory = 20,
font.size = 10, split="ONTOLOGY")