-
Notifications
You must be signed in to change notification settings - Fork 0
/
TP53.Rmd
265 lines (205 loc) · 7.47 KB
/
TP53.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
---
title: "TP53"
author: "almut"
date: "16 Juni 2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## TP53 signature
# Differentially expressed genes
### 1. Differential expression analysis
load packages
```{r packages, warning=FALSE, message=FALSE}
library(DESeq2)
library(tidyverse)
library(ggsci)
library(matrixStats)
library(piano)
library(reshape2)
library(genefilter)
library(Biobase)
library(ComplexHeatmap)
library(ggplot2)
library(gtable)
library(grid)
library(circlize)
library(gridExtra)
library(ggpubr)
library(RColorBrewer)
library(here)
```
load data
```{r datasets}
data_dir <- here("data")
output_dir <- here("output")
figure_dir <- here("output/figures")
#dds data set. gene expression data + patmetadata
load(paste0(data_dir, "/ddsrnaCLL_150218.RData"))
variant <- "TP53"
#filter for patients without NA in variant
ddsCLL <- ddsCLL[, !is.na(colData(ddsCLL)[,variant])]
#differentially expressed genes between TP53 groups (see differential expression.html)
diff_all <- read.csv(file=paste0(output_dir, "/diff_genes/", variant, "_diffGenes.csv"))
rownames(diff_all) <- diff_all$X
diff_all <- diff_all[which(diff_all$padj < 0.01 ),-1]
diff <- diff_all
mutStatus <- data.frame(colData(ddsCLL)) %>% arrange(TP53)
colnames(ddsCLL) <-colData(ddsCLL)$PatID
ddsCLL <- ddsCLL[, mutStatus$PatID]
#expression data
ddsCLL <- estimateSizeFactors(ddsCLL)
RNAnorm <- varianceStabilizingTransformation(ddsCLL, blind = T)
```
Expression matrix
```{r var gene expression}
#filter for sign. genes in variant
exprMat <- assay(RNAnorm)
exprVariant <- exprMat[rownames(diff),]
colnames(exprVariant) <- colData(ddsCLL)$PatID
exprVariant.new <- log2(exprVariant)
exprVariant.new <- t(scale(t(exprVariant.new)))
exprVariant.new[exprVariant.new > 4] <- 4
exprVariant.new[exprVariant.new < -4] <- -4
rownames(exprVariant.new) <- rowData(RNAnorm[rownames(diff),])$symbol
```
## Expression signature
```{r complex heatmap, fig.width= 22, fig.height=25}
#colors
colors = colorRamp2(c(-4,-2,0,2,4), c("#2166ac","#4393c3", "#f7f7f7", "#d6604d","#b2182b"))
annocol <- get_palette("jco", 10)
annocolor <- list(TP53 = c("1" = annocol[8], "0" = annocol[9]))
rowcolors <-colorRampPalette(brewer.pal(5, "Set1"))(5)
rowcolors[6] <- "white"
feature <- as.data.frame(colData(ddsCLL)[,c(variant)])
colnames(feature) <- c(variant)
rownames(feature) <- colnames(RNAnorm)
ha_col <- HeatmapAnnotation(df = feature, col = annocolor, annotation_height = unit(c(rep(1.9, 1)), "cm"), annotation_legend_param = list(title_gp = gpar(fontsize = 50), labels_gp = gpar(fontsize = 45), grid_height = unit(1.9, "cm"), grid_width = unit(1.9, "cm")))
h1 <- Heatmap(exprVariant.new ,
km = 2,
gap = unit(0.5, "cm"),
cluster_columns = F,
clustering_distance_rows = "pearson",
clustering_method_rows = "ward.D2",
column_title = paste0("Gene signature: ", variant),
col = colors,
column_title_gp = gpar(fontsize = 60, fontface = "bold"),
heatmap_legend_param = list(title = "expr",
title_gp = gpar(fontsize = 50),
grid_height = unit(1.9, "cm"),
grid_width = unit(1.9, "cm"),
gap = unit(2, "cm"),
labels_gp = gpar(fontsize = 45)),
column_dend_height = unit(2.5, "cm"),
show_row_dend = FALSE,
show_column_names = FALSE ,
show_row_names = TRUE,
row_names_gp = gpar(fontsize = 20),
top_annotation = ha_col)
#svg(filename=paste0(figure_dir, "/", variant, "_gene_expr.svg"), width=30, height=45)
#pdf(file=paste0(figure_dir, "/", variant, "_gene_expr.pdf"), width=22, height=25)
draw(h1 )
#dev.off()
#draw(h1)
```
# Sample and gene specific expression - top genes
```{r single gene counts, fig.width=6, fig.height=5}
#function to create stripchart plots for specific genes
gene_count <- function(gene_nam){
geneEnsID <- rownames(ddsCLL)[which(rowData(ddsCLL)$symbol %in% gene_nam)]
geneNum <- counts(ddsCLL)[geneEnsID,]
mutPat <- as.data.frame(colData(ddsCLL)[, c(variant)])
colnames(mutPat) <- c("genotype")
geneDat <- cbind(mutPat, geneNum)
colnames(geneDat) <- c("genotype", "counts")
p <- ggstripchart(geneDat, x = "genotype", y = "counts",
color = "genotype",
palette = "jco",
add = "mean_sd",
title = paste(gene_nam),
font.x = 18, font.y = 18, font.legend = 16,
ylab = "counts") + font("xy.text", size = 15) + font("title", size = 20, face = "bold")
#ggsave(file=paste0(figure_dir, "/tri12/genetic_interaction_", gene_nam, ".svg"), plot=p, width=6, height=5)
p
}
diff <- diff_all[which(abs(diff_all$stat) > 4.5),]
geneList <- as.character(diff$Symbol)
geneList <- geneList[-which(geneList %in% "")]
lapply(geneList, gene_count)
```
# Interesting top genes
A list of genes, with manual checked expression differences:
Downregulated in **Del11q22**:
+ FLII
+ NUP88
+ DRG2
+ SPAG7
+ SMG6
+ RABEP1
+ ELAC2
+ TOP3A
+ MAP2K4
+ RNF167
+ PANK4
+ MED11
+ PELP1
+ MPDU1
+ CTDNEP1
+ SGF29
+ FXR2
Upregulated in **Del11q22**:
+ HYPK
# Gene set enrichment analysis
Gene sets
```{r gene sets}
#load gene set collection
#Hallmark
gsc <- loadGSC("/home/almut/Dokumente/masterarbeit/data/h.all.v6.0.symbols.gmt", type="gmt")
#Kegg
gsc_Kegg <- loadGSC("/home/almut/Dokumente/masterarbeit/data/c2.cp.kegg.v6.0.symbols.gmt", type="gmt")
```
Run piano
```{r piano, fig.width=16, fig.height=7}
gmtFile <- gsc
diff_res <- diff_all
diff_res$chromosome <- rowData(RNAnorm)[rownames(diff_res),]$chromosome
diff_res <- diff_res[-which(diff_res$Symbol %in% c("", NA)),]
geneNam <- diff_res$Symbol
pVal <- diff_res$padj
logFold <- diff_res$log2FoldChange
stat <- diff_res$stat
gsTab <- data.frame(gene = geneNam, stat = stat, logFold = logFold)
gsaTab <- data.frame(row.names = gsTab$gene, stat = gsTab$stat)
res <- runGSA(geneLevelStats = gsaTab,
geneSetStat = "gsea",
adjMethod = "fdr", gsc=gmtFile,
signifMethod = "geneSampling",
nPerm = 50000,
gsSizeLim=c(1, Inf))
Res_up <- arrange(GSAsummaryTable(res), `p adj (dist.dir.up)`)
Res_dn <- arrange(GSAsummaryTable(res), `p adj (dist.dir.dn)`)
#Plot
resPlot <- Res_up[, c(1:3,5,8,9)]
resPlot_dn <- Res_dn[, c(1:3,7,8,9)]
colnames(resPlot) <- c("pathway", "gene_number", "stat", "p.adj","genes_up" , "genes_dn")
colnames(resPlot_dn) <- c("pathway", "gene_number", "stat", "p.adj","genes_up" , "genes_dn")
enrichPlot <- resPlot_dn[c(1:5),] %>% mutate(log10Padj = -log10(p.adj))
#plot
p <- ggbarplot(enrichPlot, x = "pathway", y = "log10Padj",
fill = "gene_number",
color = "white",
palette = "gsea",
sort.val = "asc",
sort.by.groups = FALSE,
ylab = "-log10(padj)",
legend.title = "#diff.genes",
rotate = TRUE,
font.x = 20, font.y = 20, font.legend = 20, legend = "right",
title = "TP53 - Hallmark",
ggtheme = theme_pubr()) +
font("xy.text", size = 16) +
font("title", size = 20, face = "bold")
#ggsave(file=paste0(figure_dir,"/GSEA_", variant, "_Kegg.svg"), plot=p, width=14, height=7)
p
```