-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDissertation_KG_Chapter_1.3.Rmd
172 lines (144 loc) · 5.03 KB
/
Dissertation_KG_Chapter_1.3.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
---
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.3 Evaluation of piRNA expression in CRC cell lines and comparison to germline
Import Libraries
```{r}
library(readxl)
library(dplyr)
library(tibble)
library(tidyr)
library(ComplexHeatmap)
library(circlize)
library(purrr)
library(stringr)
library(ggplot2)
library(scales)
```
### piRNA expression in CRC cell lines and testis samples
For this analysis we have used 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 that is published in Sellitto et al as supplementary material.
At this stage we will create a Heatmap showing the expression values between samples.
Import the table
```{r}
piRNA_CRC_cells <- readxl::read_xlsx("Chapter_1_3/Table_S4_Sellitto_et_al.xlsx",
skip = 4)
```
find the most variant piRNAs and the the common expressed in all samples
```{r}
MVariant_piRNA <- piRNA_CRC_cells %>%
rowwise() %>%
mutate(mad_piRNA = mad(c_across(-smallRNA))) %>%
arrange(desc(mad_piRNA))
common_high_piRNA <- piRNA_CRC_cells %>%
pivot_longer(cols = -smallRNA) %>%
filter(value > 1 ) %>%
count(smallRNA) %>%
filter(n > 8 ) %>%
pull(smallRNA)
common_piRNA <- piRNA_CRC_cells %>%
filter(smallRNA %in% common_high_piRNA)
```
keep the 500 most variant piRNA
```{r}
MVariant_piRNA_500 <- MVariant_piRNA %>%
select(-mad_piRNA) %>%
head(500)
```
reshape the tables to matrices
```{r}
mat_v <- MVariant_piRNA_500 %>%
column_to_rownames("smallRNA") %>%
as.matrix()
mat_com <- common_piRNA %>%
filter(!smallRNA %in% MVariant_piRNA_500$smallRNA) %>%
column_to_rownames("smallRNA") %>%
as.matrix()
```
Scale the matrix for the heatmap
```{r}
# make the matrices for the heatmap -----
sc_mat <- mat_v %>% t() %>% scale() %>% t()
sc_mat %>% dim()
sc_mat %>% head()
hist(sc_mat)
sc_mat_c <- mat_com %>% t() %>% scale() %>% t()
sc_mat_c %>% dim()
sc_mat_c %>% head()
hist(sc_mat_c)
```
make the heatmap
```{r}
f <- colorRamp2(c(-1, 0 ,1),c("#53868B", "#8B8878", "#FFD700"))
ha_1 <- HeatmapAnnotation(Cell_lines = colnames(sc_mat),
col = list(Cell_lines =
c(wesanderson::wes_palettes$Rushmore[1:4],
wesanderson::wes_palettes$Darjeeling1) %>%
set_names(colnames(sc_mat))))
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 \nexpression",
clustering_distance_columns = "spearman",
clustering_method_columns = "ward.D2",
clustering_method_rows = "ward.D2",
clustering_distance_rows = "spearman",
row_dend_reorder = TRUE,
row_title = "piRNAs",
column_title = str_glue("Heatmap of {nrow(sc_mat)} most variant piRNAs\nbetween cell lines"),
)
ht_c <- Heatmap(matrix = sc_mat_c, #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 \nexpression",
clustering_distance_columns = "spearman",
clustering_method_columns = "ward.D2",
clustering_method_rows = "ward.D2",
clustering_distance_rows = "spearman",
row_dend_reorder = TRUE,
column_title = str_glue("Heatmap of {nrow(sc_mat_c)} common, most expressed piRNAs\nbetween cell lines")
)
tiff(filename = file.path("FIG_16_piRNA_most_var_CRC_lines_Testis.tiff"),
compression = "none", height = 10, width = 14, units = 'in', res = 600)
ht_1
dev.off()
```