-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5c_circ.R
383 lines (335 loc) · 16.3 KB
/
5c_circ.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# set up ------------------------------------------------------------------
library(here)
library(tximport)
library(easystats)
library(data.table)
library(scales)
library(broom)
library(stringr)
library(ggtext)
library(ggrastr)
library(ragg)
library(ggVennDiagram)
library(ggrepel)
library(ggpmisc)
library(ggpubr)
library(ggside)
library(cowplot)
library(patchwork)
library(colorspace)
library(RColorBrewer)
library(MetBrewer)
library(DT)
library(clipr)
library(pROC)
library(fst)
library(DT)
library(gtsummary)
library(tidyverse)
library(furrr)
set.seed(1997)
# import common functions
source(here("combinedLinCirc/PD-RNA/functions.R"))
# set theme
theme_set(plot_theme)
# import ------------------------------------------------------------------
## metadata
meta.ppmi <- read_rds(here("circRNA/data/ppmi_metadata.rds"))
meta.icicle <- read_rds(here("circRNA/data/icicle_metadata.rds"))
interesting_columns <- c("id", "study", "condition", "age_at_consent", "sex", "batch", "pct_usable_bases", "pct_intronic_bases", "pct_coding_bases", "median_cv_coverage", "total_sequences", "salmon_mapped", "mapped_reads", "sum_bsj", "unique_bsj", "unique_hostBSJ", "sum_bsj_perMapped", "unique_bsj_perMapped", "unique_hostBSJ_perMapped")
meta.bound <- bind_rows(
meta.ppmi %>% select(all_of(interesting_columns)),
meta.icicle %>% select(all_of(interesting_columns))
) %>%
mutate(study = factor(study, levels = c("PPMI", "ICICLE-PD")))
# gene annotations
gene_anno <- read_delim(here("geneAnnotations_ensembl_v101.txt"))
# BSJ annotation info
junc_info <- read_fst(here("circRNA/data/bound_juncInfo.fst"))
# BSJ results
bsj_results.ppmi <- read_csv(here("circRNA/output/ppmi_BSJresults.csv")) %>%
mutate(study = "PPMI", type = "BSJ") %>%
rename(gene_symbol = gene_name)
bsj_results.icicle <- read_csv(here("circRNA/output/icicle_BSJresults.csv")) %>%
mutate(study = "ICICLE-PD", type = "BSJ") %>%
rename(gene_symbol = gene_name)
bsj_results.merged <- full_join(bsj_results.ppmi, bsj_results.icicle,
by = c("coord_id", "gene_id", "gene_symbol", "type"),
suffix = c(".ppmi", ".icicle")
)
bsj_results.bind <- bind_rows(bsj_results.ppmi, bsj_results.icicle) %>%
mutate(study = factor(study, levels = c("PPMI", "ICICLE-PD")))
# FSJ results
fsj_results.ppmi <- read_csv(here("circRNA/output/ppmi_FSJresults.csv")) %>%
mutate(study = "PPMI", type = "FSJ") %>%
rename(gene_symbol = gene_name)
fsj_results.icicle <- read_csv(here("circRNA/output/icicle_FSJresults.csv")) %>%
mutate(study = "ICICLE-PD", type = "FSJ") %>%
rename(gene_symbol = gene_name)
# import normalised counts
norm_linear_counts.ppmi <- read_csv(here("linear/data/ppmi_deseqFilteredNormalisedCounts.csv")) %>%
rename(gene_id = ensembl) %>%
pivot_longer(cols = !gene_id, names_to = "id", values_to = "norm_count") %>%
mutate(study = "PPMI")
norm_linear_counts.icicle <- read_csv(here("linear/data/icicle_deseqFilteredNormalisedCounts.csv")) %>%
rename(gene_id = ensembl) %>%
pivot_longer(cols = !gene_id, names_to = "id", values_to = "norm_count") %>%
mutate(study = "ICICLE-PD")
vst_linear_counts.ppmi <- read_csv(here("linear/data/ppmi_vstCounts.csv")) %>%
rename(gene_id = ensembl) %>%
pivot_longer(cols = !gene_id, names_to = "id", values_to = "vst_count") %>%
mutate(study = "PPMI")
vst_linear_counts.icicle <- read_csv(here("linear/data/icicle_vstCounts.csv")) %>%
rename(gene_id = ensembl) %>%
pivot_longer(cols = !gene_id, names_to = "id", values_to = "vst_count") %>%
mutate(study = "ICICLE-PD")
### vst counts
### add to junc info for ease
junc_info <- left_join(junc_info,
full_join(
bind_rows(
# PPMI BSJ VST
read_csv(here("circRNA/data/ppmi_vstBSJCounts.csv")) %>%
pivot_longer(cols = !coord_id, names_to = "id", values_to = "bsj_vst") %>%
mutate(study = "PPMI"),
# ICICLE-PD BSJ vst
read_csv(here("circRNA/data/icicle_vstBSJCounts.csv")) %>%
pivot_longer(cols = !coord_id, names_to = "id", values_to = "bsj_vst") %>%
mutate(study = "ICICLE-PD")
),
bind_rows(
# PPMI FSJ vst
read_csv(here("circRNA/data/ppmi_vstFSJCounts.csv")) %>%
pivot_longer(cols = !coord_id, names_to = "id", values_to = "fsj_vst") %>%
mutate(study = "PPMI"),
# ICICLE-PD FSJ vst
read_csv(here("circRNA/data/icicle_vstFSJCounts.csv")) %>%
pivot_longer(cols = !coord_id, names_to = "id", values_to = "fsj_vst") %>%
mutate(study = "ICICLE-PD")
),
by = c("coord_id", "id", "study")
),
by = c("coord_id", "id", "study")
) %>%
rename(gene_symbol = gene_name)
# detection ---------------------------------------------------------------
# How many BSJs detected in each cohort?
map(cohorts, function(study) {
junc_info %>%
filter(study == {{ study }}) %>%
pull(coord_id) %>%
unique() %>%
length()
})
# how many of the abundant BSJs overlap between cohorts?
round(length(intersect(bsj_results.ppmi$coord_id, bsj_results.icicle$coord_id)) / length(unique(c(bsj_results.ppmi$coord_id, bsj_results.icicle$coord_id)))*100, 2)
# abundant overenrichment -------------------------------------------------
# Import
abundant_bsj_enrich.ppmi <- read_rds(here("circRNA/output/ppmi_abundantBSJ_enrich.rds"))
abundant_bsj_enrich.ppmi <- abundant_bsj_enrich.ppmi@result
abundant_bsj_enrich.icicle <- read_rds(here("circRNA/output/icicle_abundantBSJ_enrich.rds"))
abundant_bsj_enrich.icicle <- abundant_bsj_enrich.icicle@result
# Any sig in PPMI?
filter(abundant_bsj_enrich.ppmi, p.adjust < 0.05)
# Any sig in ICICLE?
filter(abundant_bsj_enrich.icicle, p.adjust < 0.05)
# Output merged file for supp
abundant_bsj_enrich <- full_join(abundant_bsj_enrich.ppmi, abundant_bsj_enrich.icicle, by = c("ONTOLOGY", "ID", "Description"), suffix = c(".ppmi", ".icicle"))
# add a space infront of the ratios so excel doesn't change it to a date
abundant_bsj_enrich <- abundant_bsj_enrich %>%
mutate(GeneRatio.ppmi = paste0(" ", GeneRatio.ppmi),
GeneRatio.icicle = paste0(" ", GeneRatio.icicle),
BgRatio.ppmi = paste0(" ", BgRatio.ppmi),
BgRatio.icicle = paste0(" ", BgRatio.icicle))
write_csv(abundant_bsj_enrich, "combinedLinCirc/output/tables/merged_abundantBSJ_go_enrich.csv")
# differential expression ------------------------------------------------
# How many significant in PPMI?
sig_bsj_results.ppmi <- bsj_results.ppmi %>%
filter(
padj < 0.05,
log2FoldChange > 0.1 | log2FoldChange < -0.1
) %>%
mutate(direction = case_when(
log2FoldChange > 0.1 ~ "Increased",
log2FoldChange < -0.1 ~ "Decreased",
TRUE ~ "error"
))
nrow(sig_bsj_results.ppmi)
# Volcano plot
bsj_volcano.plot <- plotVolcano(bsj_results.bind, sig_bsj_results.ppmi) +
scale_x_continuous(limits = c(-0.8, 0.8)) +
scale_colour_manual(values = c("Not DE" = "gray70", "DE" = "#486de8")) +
guides(colour = guide_legend(title = "circRNA differential expression in PPMI")) +
theme(legend.position = "top") +
guides(colour = guide_legend(title.position = "top", title.hjust = 0.5))
bsj_volcano.plot
ggsave(here("combinedLinCirc/output/figures/individual/circ_volcano.png"),
height = 4, width = 6, dpi = 600, device = agg_png
)
### Replication in ICICLE-PD
# Do any replicate?
replicate_bsj <- sig_bsj_results.ppmi %>%
left_join(bsj_results.icicle,
by = c("coord_id", "gene_id", "gene_symbol"),
suffix = c(".ppmi", ".icicle")
) %>%
mutate(replicate_fdr = p.adjust(pvalue.icicle, method = "fdr")) %>%
select(-contains(c("study", "type", "Direction", "padj.icicle")))
# Plot fold changes of BSJs differentially expressed in PPMI
# log2 fold change and lfcSE to long format
# do it separately and then bind rows together as I can't figure out how to do it in pivot
plot.replicate_bsj <- full_join(replicate_bsj %>%
select(contains(c("coord_id", "log2FoldChange"))) %>%
pivot_longer(cols = !coord_id, names_to = "study", values_to = "log2FoldChange") %>%
mutate(study = gsub(study, pattern = "log2FoldChange.", replacement = "")),
replicate_bsj %>%
select(contains(c("coord_id", "lfcSE"))) %>%
pivot_longer(cols = !coord_id, names_to = "study", values_to = "lfcSE") %>%
mutate(study = gsub(study, pattern = "lfcSE.", replacement = ""))
, by = c("coord_id", "study")) %>%
# add gene name from annoation
left_join(unique(junc_info[, c("coord_id", "gene_symbol")]), by = "coord_id") %>%
# change cohort names to correct names + order for colours
mutate(study = case_match(study, "ppmi" ~ "PPMI","icicle" ~ "ICICLE-PD"),
study = factor(study, levels = c("ICICLE-PD", "PPMI")),
coord_label = paste0(coord_id, "\n",
"(circ", gene_symbol, ")")) %>%
# calculate 95% CIs
mutate(ci_lower = log2FoldChange - (qnorm(0.025) * lfcSE),
ci_higher = log2FoldChange + (qnorm(0.025) * lfcSE)) %>%
ggplot(aes(x = log2FoldChange, y = coord_label, colour = study)) +
geom_vline(xintercept = 0, alpha = 0.2, linetype = "dashed") +
geom_pointrange(aes(xmin = ci_lower, xmax = ci_higher),
position = position_dodge(width = 0.5), size = 0.3) +
scale_colour_manual(values = study_colours, breaks = c("PPMI", "ICICLE-PD")) +
xlim(-0.7, 0.7) +
labs(x = "log<sub>2</sub>(Fold Change)",
y = "BSJ position",
colour = "Cohort") +
guides(colour = guide_legend(title.position = "top", title.hjust = 0.5))
plot.replicate_bsj
# Output combined BSJ results table for supp
bsj_results.merged %>%
left_join(replicate_bsj[, c("coord_id", "replicate_fdr")], by = "coord_id") %>%
select(-contains(c("study", "type"))) %>%
write_csv(here("combinedLinCirc/output/tables/circRNA_DE.csv"))
## GO enrichment
sig_bsj_enrich.ppmi <- read_rds(here("circRNA/output/ppmi_sigBSJ_enrich.rds"))
sig_bsj_enrich.ppmi@result %>% filter(p.adjust < 0.05)
# prev reported PD circRNAs ----------------------------------------------
# get previously identified PD BSJs
circatlas <- read_delim(here("circRNA/data/circAtlas_circRNA_bed.txt"))
circatlas$format <- paste0(circatlas$Chro, ":", circatlas$Start, "|", circatlas$End)
circatlas$my_format <- paste0(circatlas$Chro, ":", circatlas$Start, "-", circatlas$End, ":", circatlas$Stand)
circatlas <- circatlas[, c("format", "my_format")]
prev_circs <- read_csv(here("circRNA/data/raw/manuallyCollatedPDcircs.csv")) %>%
rename(format = coords_GRCh38_circAtlas)
prev_circs <- left_join(prev_circs, circatlas, by = "format") %>%
separate(my_format, into = c("chr", "coords", "strand"), sep = ":") %>%
separate(coords, into = c("start", "end"), sep = "-") %>%
mutate(start = as.numeric(start) - 1) %>%
mutate(chr = gsub(chr, pattern = "chr", replacement = ""))
prev_circs$coord_id <- paste0(prev_circs$chr, ":", prev_circs$start, "-", prev_circs$end, ":", prev_circs$strand)
rm(circatlas)
# GET RESULTS OF PREV BSJS
prev_circs.table <- bsj_results.merged %>%
filter(coord_id %in% prev_circs$coord_id) %>%
full_join(prev_circs[, c("coord_id", "gene", "study", "direction")], by = "coord_id") %>%
mutate(
tissue = recode(study, "Ravanidis.etal2021" = "Blood", "Hanan.etal2020" = "Brain"),
direction = recode(direction, "down" = "Decreased in PD", "up" = "Increased in PD")
) %>%
arrange(pvalue.ppmi) %>%
select(
coord_id, gene, tissue, direction,
baseMean.ppmi, log2FoldChange.ppmi, lfcSE.ppmi, stat.ppmi, pvalue.ppmi,
baseMean.icicle, log2FoldChange.icicle, lfcSE.icicle, stat.icicle, pvalue.icicle
) %>%
mutate(
replicate_fdr.ppmi = p.adjust(pvalue.ppmi, method = "fdr"),
relicate_fdr.icicle = p.adjust(pvalue.icicle, method = "fdr")
)
# Attempting to replicate prev PD BSJs
prev_circs.table %>%
write_csv(here("combinedLinCirc/output/tables/replicate_prev_PD_bsj.csv"))
df.prev_circs <- prev_circs.table[, c("coord_id", "direction")] %>%
left_join(bsj_results.bind, by = "coord_id", multiple = "all") %>%
mutate(
direction = recode(direction,
"Decreased in PD" = "↓",
"Increased in PD" = "↑"
),
coord_id = paste(direction, coord_id, sep = " ")
)
# correlation of fold changes in both
prev_circs_cor <- df.prev_circs[, c("coord_id", "log2FoldChange", "study")] %>%
pivot_wider(id_cols = coord_id, names_from = study, values_from = log2FoldChange)
prev_circs_cor <- cor.test(prev_circs_cor$PPMI, prev_circs_cor$`ICICLE-PD`, method = "pearson") %>% tidy()
prev_circs_cor
# plot
plot.prev_circs <- df.prev_circs %>%
drop_na() %>%
mutate(study = factor(study, levels = c("ICICLE-PD", "PPMI")),
# add on gene symbol undernath coord id
coord_label = paste0(coord_id, "\n",
"(circ", gene_symbol, ")")) %>%
ggplot(aes(x = log2FoldChange, y = coord_label, colour = study)) +
#ggforestplot::geom_stripes(aes(colour = coord_id), odd = "white", even = "gray95") +
geom_vline(xintercept = 0, alpha = 0.2, linetype = "dashed") +
geom_pointrange(aes(xmin = log2FoldChange - (qnorm(0.025) * lfcSE), xmax = log2FoldChange + (qnorm(0.025) * lfcSE)), position = position_dodge(0.5), size = 0.3) +
scale_colour_manual(values = study_colours, breaks = c("PPMI", "ICICLE-PD")) +
xlim(-0.7, 0.7) +
labs(
x = "log<sub>2</sub>(Fold Change)",
y = "BSJ position",
colour = "Cohort"
) +
theme(legend.position = "top") +
guides(colour = guide_legend(title.position = "top", title.hjust = 0.5))
plot.prev_circs
ggsave(here("combinedLinCirc/output/figures/individual/prev_pd_bsj.png"),
height = 4, width = 5, dpi = 600, device = agg_png
)
# relate to previous work -------------------------------------------------
monogenicPD <- read_csv(here("combinedLinCirc/data/pdGenes_genomicsEnglandPanel.csv")) %>%
rename(gene_symbol = gene_name)
# monogenic
bsj_monogenicPD <- monogenicPD %>%
inner_join(bsj_results.merged, by = "gene_symbol") %>%
select(
gene_symbol, gene_id, coord_id, baseMean.ppmi, baseMean.icicle,
log2FoldChange.ppmi, log2FoldChange.icicle, pvalue.ppmi, pvalue.icicle
) %>%
mutate(
replicate_fdr.ppmi = p.adjust(pvalue.ppmi, method = "fdr"),
replicate_fdr.icicle = p.adjust(pvalue.icicle, method = "fdr")
)
bsj_monogenicPD %>%
write_csv(here("combinedLinCirc/output/bsj_monogenicPD_overlap.csv"))
# How many genes host BSJs?
length(unique(bsj_monogenicPD$gene_symbol))
# GWAS
gwas_genes <- read_csv(here("combinedLinCirc/data/nalls_et_al2019_META5_genes.csv")) %>%
janitor::clean_names() %>%
rename(gene_symbol = nearest_gene)
length(unique(gwas_genes$gene_symbol))
bsj_gwas <- gwas_genes %>%
inner_join(bsj_results.merged, by = "gene_symbol", multiple = "all") %>%
distinct() %>%
select(
gene_symbol, coord_id, baseMean.ppmi, baseMean.icicle,
log2FoldChange.ppmi, log2FoldChange.icicle, pvalue.ppmi, pvalue.icicle
) %>%
mutate(
new_pval.ppmi = p.adjust(pvalue.ppmi, method = "fdr"),
new_pval.icicle = p.adjust(pvalue.icicle, method = "fdr"),
) %>%
arrange(pvalue.ppmi)
bsj_gwas %>% datatable()
length(unique(bsj_gwas$gene_symbol)) # number of BSJ-hosting GWAS genes
bsj_gwas %>%
write_csv(here("combinedLinCirc/output/bsj_GWAS_overlap.csv"))
# figure panel ------------------------------------------------------------
(bsj_volcano.plot | (plot.replicate_bsj / plot.prev_circs) + plot_layout(guides = 'collect', heights = c(1.5, 2))) + plot_layout(widths = c(2, 1)) & theme(legend.position = 'top')
ggsave(here("combinedLinCirc/output/figures/panels/circ_DE.svg"),
height = 8, width = 9)