-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDissertation_KG_Chapter_1.5.Rmd
286 lines (246 loc) · 9.6 KB
/
Dissertation_KG_Chapter_1.5.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
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
---
title: "Role of Piwi-piRNA pathway in somatic and cancer cells"
author: "__Konstantinos Geles__"
date: "Thu Jun 30 2022, Last Update: `r format(Sys.Date(), '%a %b %d %Y')`"
output:
html_document:
toc: yes
toc_depth: 3
df_print: paged
pdf_document:
toc: yes
toc_depth: 3
html_notebook: null
editor_options:
chunk_output_type: console
subtitle: UMG PhD Programme of Molecular and Translational Oncology - Circle XXXIV
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, eval = FALSE)
```
This project contains the scripting part of the Doctoral Dissertation of **Konstantinos Geles** with doi:
# CHAPTER 1: Role of the PIWI-piRNA pathway in Colorectal Cancer (CRC)
## 1.5 Evaluation of piRNA in RIP-seq
### piRNA identified inside PIWIL1
For this analysis we have use SPORTS 1.0 to perform all the preprocessing, alignment and quantification steps as shown in the ... GitHub Repository.
Using TMM normalization and transforming to CPM we arrive to a table
Import Libraries
```{r}
library(vroom)
library(dplyr)
library(tibble)
library(tidyr)
library(purrr)
library(stringr)
library(ggplot2)
library(scales)
library(ggpmisc)
library(ComplexHeatmap)
library(circlize)
library(limma)
library(ggvenn)
```
Import the voom and get the comparisons
```{r}
voom_IPP <- readRDS("Chapter_1_5/3_IPP_PIWIL1_all_DBs/vfit_x1_voomTMM.rds")
#IPP_C_vs_INPUT
topIPP_C_vs_INPUT <- topTable(voom_IPP, coef = "IPP_C_vs_INPUT",
number = nrow(voom_IPP),
adjust.method = "fdr",
sort.by = "p") %>%
as_tibble(rownames = "smallRNA") %>%
filter(adj.P.Val< 0.01, logFC > 2)
#IPP_N_vs_INPUT
topIPP_N_vs_INPUT <- topTable(voom_IPP, coef = "IPP_N_vs_INPUT",
number = nrow(voom_IPP),
adjust.method = "fdr",
sort.by = "p") %>%
as_tibble(rownames = "smallRNA") %>%
filter(adj.P.Val< 0.01, logFC > 2)
#IPP_INPUT_vs_noAb
topIPP_INPUT_vs_noAb <- topTable(voom_IPP, coef = "IPP_INPUT_vs_noAb",
number = nrow(voom_IPP),
adjust.method = "fdr",
sort.by = "p") %>%
as_tibble(rownames = "smallRNA") %>%
filter(adj.P.Val< 0.01, logFC < (-2))
```
find the enriched
```{r}
enriched_C_IPP <- topIPP_C_vs_INPUT %>%
filter(!smallRNA %in% topIPP_INPUT_vs_noAb$smallRNA) %>%
separate(col = smallRNA, into = c("Class", "sncRNA"),sep = "_match_" )
enriched_C_IPP %>% count(Class)
enriched_N_IPP <- topIPP_N_vs_INPUT %>%
filter(!smallRNA %in% topIPP_INPUT_vs_noAb$smallRNA) %>%
separate(col = smallRNA, into = c("Class", "sncRNA"),sep = "_match_" )
enriched_N_IPP %>% count(Class)
enriched_IPP_common <- bind_rows("N_ab_LFC" = topIPP_N_vs_INPUT,
"C_ab_LFC" = topIPP_C_vs_INPUT, .id = "ab") %>%
filter(!smallRNA %in% topIPP_INPUT_vs_noAb$smallRNA) %>%
select(ab:logFC) %>%
pivot_wider(names_from = ab, values_from = logFC) %>%
drop_na() %>%
separate(col = smallRNA, into = c("Class", "sncRNA"),sep = "_match_" )
enriched_IPP_common %>% count(Class)
```
PhD theme for plots
```{r}
wes_cols <- c(wesanderson::wes_palettes$BottleRocket2[2:5])
PhD_theme <-
list(
scale_fill_brewer(palette = "Set1"),
theme_bw() +
theme(
panel.border = element_blank(),
strip.background = element_blank(),
strip.text = element_text(size = 20, colour = "black"),
axis.line = element_line(),
panel.grid.major = element_line(size = 0.2),
panel.grid.minor = element_line(size = 0.1),
text = element_text(size = 20),
axis.title.x = element_text(margin = margin(t = 10, r = 10, b = 10, l = 10),
colour = "black"),
axis.title.y = element_text(margin = margin(t = 10, r = 10, b = 10, l = 10),
colour = "black"),
axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 20),
axis.text.y = element_text(size = 20, colour = "black"),
plot.title = element_text(hjust = 0.5, colour = "black")
)
)
```
make df of union
```{r}
enriched_IPP_union <- bind_rows("IPP_Ab1" = enriched_C_IPP,
"IPP_Ab2" = enriched_N_IPP, .id = "ab")
```
plot the enriched
```{r}
plot_enri_un <- enriched_IPP_union %>%
ggplot(aes(x = Class, fill = Class)) +
geom_bar(stat = "count")+
stat_count(geom = "text", colour = "black", size = 7.5,
aes(label = ..count..), position = position_fill(vjust = 850)) +
facet_wrap(facets = "ab", ncol = 2) +
xlab("sncRNA Class") +
ggtitle("Amount of sncRNAs found enriched in RIP-seq\n for COLO205 cell-line") +
PhD_theme
tiff(filename = file.path("FIG_21_IPP_1_2_COLO205.tiff"),
compression = "none", height = 12, width = 16, units = 'in', res = 600)
plot_enri_un
dev.off()
```
### Heatmap of common piRNAs enriched with both Ab in IPP
import the lcpm
```{r}
sncRNA_IPP_lCPM <- vroom("Chapter_1_5/3_IPP_PIWIL1_all_DBs/IPP_PIWIL_TMM_logcpm_counts.txt") %>%
separate(col = smallRNA, into = c("Class", "sncRNA"),sep = "_match_" ) %>%
filter(sncRNA %in% enriched_IPP_common$sncRNA, Class == "piRNA") %>%
select(-Class, -contains("noAb")) %>%
rename_with(.cols = contains("COLO205"),
.fn = ~ str_remove(.x, "COLO205_IPP_") %>%
str_replace("C_", "1_") %>%
str_replace("N_", "2_")) %>%
column_to_rownames("sncRNA") %>%
as.matrix()
```
Scale the matrix for the heatmap
```{r}
# make the matrices for the heatmap -----
sc_mat <- sncRNA_IPP_lCPM %>% t() %>% scale() %>% t()
sc_mat %>% dim()
sc_mat %>% head()
hist(sc_mat)
```
make the heatmap
```{r}
f <- colorRamp2(c(-1, 0 ,1),c("#53868B", "#8B8878", "#FFD700"))
ha_1 <- HeatmapAnnotation(Samples = colnames(sc_mat),
col = list(Samples =
rep(wesanderson::wes_palettes$Cavalcanti1[2:4],
each = 3) %>%
set_names(colnames(sc_mat))),
annotation_legend_param = list(
Samples = list(
title_gp = gpar( fontsize = 20, fontface = "bold"),
labels_gp = gpar(fontsize = 20)))
)
ht_1 <- Heatmap(matrix = sc_mat, #data
top_annotation = ha_1, #annot
col = f, #colors data
row_title_gp = gpar(fontsize = 20),
column_title_gp = gpar(fontsize = 20),
column_names_gp = gpar(fontsize = 20),
column_names_rot = 45,
heatmap_legend_param = list(
title_gp = gpar(fontsize = 15, fontface = "bold"),
labels_gp = gpar(fontsize = 15)),
show_row_dend = TRUE,
show_row_names = FALSE,
show_column_names = TRUE,
name = "z-score \nabundance",
clustering_distance_columns = "spearman",
clustering_method_columns = "median",
clustering_method_rows = "median",
clustering_distance_rows = "spearman",
row_dend_reorder = TRUE,
row_title = "piRNAs",
column_title = str_glue("Heatmap of {nrow(sc_mat)} common piRNAs\nfound enriched between Ab1 and Ab2"),
)
tiff(filename = file.path("FIG_22_piRNA_common_AB1_AB2_Colo205.tiff"),
compression = "none", height = 10, width = 14, units = 'in', res = 600)
ht_1
dev.off()
```
PhD theme for plots
```{r}
wes_cols <- c(wesanderson::wes_palettes$BottleRocket2[2:5])
PhD_theme <-
list(
scale_fill_brewer(palette = "Set1"),
theme_bw() +
theme(
panel.border = element_blank(),
strip.background = element_blank(),
strip.text = element_text(size = 20, colour = "black"),
axis.line = element_line(),
panel.grid.major = element_line(size = 0.2),
panel.grid.minor = element_line(size = 0.1),
text = element_text(size = 20),
axis.title.x = element_text(margin = margin(t = 10, r = 10, b = 10, l = 10),
colour = "black"),
axis.title.y = element_text(margin = margin(t = 10, r = 10, b = 10, l = 10),
colour = "black"),
axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 20),
axis.text.y = element_text(size = 20, colour = "black"),
plot.title = element_text(hjust = 0.5, colour = "black")
)
)
```
### Methylated and immunoprecipitated piRNA
```{r}
# We import the table made from previous chapter with methylated sncRNAs
dge_contrasts_treat <- vroom("Chap_1_4_dge_contrasts_treat_Enriched_methylate_sncRNAs_Cytr_Nuc.txt")
Treat_cyt <- dge_contrasts_treat %>%
separate(col = smallRNA, into = c("Class", "sncRNA"),sep = "_match_" ) %>%
filter(comparison == "TrevsUntCyt", Class == "piRNA")
Treat_nuc <- dge_contrasts_treat %>%
separate(col = smallRNA, into = c("Class", "sncRNA"),sep = "_match_" ) %>%
filter(comparison == "TrevsUntNuc", Class == "piRNA")
#IPP piRNAs by both Antibodies
IPP_piRNA <- enriched_IPP_common %>%
filter(Class == "piRNA")
venn_list <- list(`piRNAs Methylated in Cytosol` = Treat_cyt$sncRNA,
`piRNAs Methylated in Nucleus` = Treat_nuc$sncRNA,
`piRNAs in RIP-seq` = IPP_piRNA$sncRNA
)
venn_piRNA <- ggvenn(venn_list, show_percentage = FALSE) +
ggtitle("Common piRNAs between Treated Nucleus/Cytosolic and Rip-seq samples")+
PhD_theme +
theme_void() +
coord_fixed()
tiff(filename = file.path("FIG_23_piRNA_common_AB1_AB2_Meth_Cyt_Nuc.tiff"),
compression = "none", height = 10, width = 14, units = 'in', res = 600)
venn_piRNA
dev.off()
```