Newer
Older
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
CARNIVAL for causal integration of Phospho and transcriptomics data
after SARS-CoV-2 infection
================
Alberto Valdeolivas: <alberto.valdeolivas@bioquant.uni-heidelberg.de>;
Date:
09/07/2020
### License Info
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
Please check <http://www.gnu.org/licenses/>.
## Introduction
The present script computes TF activity from transcriptomics data on the
A549 human lung derived cell line after SARS-CoV-2 infection. It also
takes kinase activity derived from phosphoproteomics data in the same
cell line. Both experiments were conducted 24 hours after SARS-CoV-2
infection, but they come from two different independent publications
(see references)
## Getting the inputs for CARNIPHAL
We first load the required libraries and define a function to export
CARNIVAL results to cytoscape.
``` r
library(readr)
library(DESeq2)
library(CARNIVAL)
library(OmnipathR)
library(progeny)
library(dorothea)
library(dplyr)
library(readr)
library(tidyr)
library(tibble)
library(ggplot2)
## We also define a function to format the CARNIVAL output to cytoscape
OutputCyto <- function(CarnivalResults, outputFile) {
CarnivalNetwork <-
as.data.frame(CarnivalResults$weightedSIF, stringsAsFactors = FALSE) %>%
dplyr::mutate(Sign = as.numeric(Sign), Weight = as.numeric(Weight)) %>%
dplyr::mutate(Weight = Sign * Weight) %>%
dplyr::select(Node1, Weight, Node2)
CarnivalNetworkNodes <-
unique(c(CarnivalNetwork$Node1,CarnivalNetwork$Node2))
CarnivalAttributes <- CarnivalResults$nodesAttributes %>%
as.data.frame() %>%
dplyr::filter(Node %in% CarnivalNetworkNodes) %>%
dplyr::mutate(NodeType = as.character(NodeType)) %>%
dplyr::mutate(NodeType=if_else(NodeType =="", "I", NodeType))
nameOutputNetwork <- paste0(outputFile, "Network.sif")
nameOutputAttributes <- paste0(outputFile, "Attributes.txt")
write.table(CarnivalNetwork, file = nameOutputNetwork,
quote = FALSE, row.names = FALSE, col.names = FALSE, sep = " ")
write.table(CarnivalAttributes, file = nameOutputAttributes,
quote = FALSE, row.names = FALSE, col.names = TRUE, sep = "\t")
}
```
### Differential expression analysis on the transcriptomics data
We take the series 5 from the following dataset (A549 mock treated
versus SARS-CoV-2 infected):
<https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE147507>
which is related to the following publication:
<https://www.cell.com/cell/pdf/S0092-8674(20)30489-X.pdf?_returnURL=https%3A%2F%2Flinkinghub.elsevier.com%2Fretrieve%2Fpii%2FS009286742030489X%3Fshowall%3Dtrue>
``` r
## Raw counts table
GSE147507_raw_counts <-
read.csv("TranscriptomicsData/GSE147507_RawReadCounts_Human.tsv", sep = "\t")
count_A549vsCOV2_df <- GSE147507_raw_counts[,c(22:27)]
row.names(count_A549vsCOV2_df) <- GSE147507_raw_counts$X
## Define conditions
targets_A549vsCOV2 <-
as.data.frame(matrix(NA,length(names(count_A549vsCOV2_df)),1))
names(targets_A549vsCOV2) <- c("condition")
row.names(targets_A549vsCOV2) <- names(count_A549vsCOV2_df)
targets_A549vsCOV2$condition <-
gsub("Series5_", "", row.names(targets_A549vsCOV2))
targets_A549vsCOV2$condition <-
factor(gsub("_[1-3]$", "", targets_A549vsCOV2$condition))
targets_A549vsCOV2
```
## condition
## Series5_A549_Mock_1 A549_Mock
## Series5_A549_Mock_2 A549_Mock
## Series5_A549_Mock_3 A549_Mock
## Series5_A549_SARS.CoV.2_1 A549_SARS.CoV.2
## Series5_A549_SARS.CoV.2_2 A549_SARS.CoV.2
## Series5_A549_SARS.CoV.2_3 A549_SARS.CoV.2
``` r
## Create deseq2 object
dds_A549vsCOV2 <-
DESeqDataSetFromMatrix(countData = as.matrix(count_A549vsCOV2_df),
colData = targets_A549vsCOV2, design = ~ condition)
## Set control
dds_A549vsCOV2$condition <- relevel(dds_A549vsCOV2$condition,
ref = levels(targets_A549vsCOV2$condition)[1])
## Carry out diff exp
dds_A549vsCOV2 <- DESeq(dds_A549vsCOV2)
## See the comparisons carried out
comparison_A549vsCOV2 <- resultsNames(dds_A549vsCOV2)
## Get results table
results_A549vsCOV2 <-
results(dds_A549vsCOV2, name=comparison_A549vsCOV2[2])
```
### Pathway activity estimation using Progeny
We first estimate the pathway activity using the Progeny package. In
particular, we compute the normalised enriched score (NEs) of the
different pathways by running Progeny using the statistic from the
differential express analysis.
``` r
dds_A549vsCOV2_df <- as.data.frame(results_A549vsCOV2) %>%
rownames_to_column(var = "GeneID") %>%
dplyr::select(GeneID, stat) %>%
dplyr::filter(!is.na(stat)) %>%
column_to_rownames(var = "GeneID")
pathways_A549vsCOV2_zscore <- t(progeny(as.matrix(dds_A549vsCOV2_df),
scale=TRUE, organism="Human", top = 100, perm = 10000, z_scores = TRUE))
colnames(pathways_A549vsCOV2_zscore) <- "NES"
## I also need to run progeny in such a way to have values between 1 and -1 to
## use as CARNIVAL input
pathways_A549vsCOV2_zscore_inputCarnival <-
t(progeny(as.matrix(dds_A549vsCOV2_df),
scale=TRUE, organism="Human", top = 100, perm = 10000, z_scores = FALSE))
colnames(pathways_A549vsCOV2_zscore_inputCarnival) <- "Activity"
```
We now display the normalized enrichment scores (NES) in a bar plot.
``` r
pathways_A549vsCOV2_zscore_df <- as.data.frame(pathways_A549vsCOV2_zscore) %>%
rownames_to_column(var = "Pathway") %>%
dplyr::arrange(NES) %>%
dplyr::mutate(Pathway = factor(Pathway))
ggplot(pathways_A549vsCOV2_zscore_df,aes(x = reorder(Pathway, NES), y = NES)) +
geom_bar(aes(fill = NES), stat = "identity") +
scale_fill_gradient2(low = "darkblue", high = "indianred",
mid = "whitesmoke", midpoint = 0) +
theme_minimal() +
theme(axis.title = element_text(face = "bold", size = 12),
axis.text.x =
element_text(angle = 45, hjust = 1, size =10, face= "bold"),
axis.text.y = element_text(size =10, face= "bold"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
xlab("Pathways")
```
<!-- -->
### Transcription Factor activity with Dorothea and Viper
Now, we estimate the transcription factor (TF) activity using the
dorothea package. We select Dorothea interactions with confidence level
A, B and C.
``` r
## We load Dorothea Regulons
data(dorothea_hs, package = "dorothea")
regulons <- dorothea_hs %>%
dplyr::filter(confidence %in% c("A", "B","C"))
```
We run Viper using the statistic from the different expression analysis.
``` r
dds_A549vsCOV2_stat <- as.data.frame(results_A549vsCOV2) %>%
rownames_to_column(var = "GeneID") %>%
dplyr::select(GeneID, stat) %>%
dplyr::filter(!is.na(stat)) %>%
column_to_rownames(var = "GeneID") %>%
as.matrix()
tf_activities_A549vsCOV2_stat <-
dorothea::run_viper(as.matrix(dds_A549vsCOV2_stat), regulons,
options = list(minsize = 5, eset.filter = FALSE,
cores = 1, verbose = FALSE, nes = TRUE))
```
We now display the top 25 normalized enrichment scores (NES) for the TF
in a bar plot.
``` r
tf_activities_A549vsCOV2_top25 <- tf_activities_A549vsCOV2_stat %>%
as.data.frame() %>%
rownames_to_column(var = "GeneID") %>%
dplyr::rename(NES = "stat") %>%
dplyr::top_n(25, wt = abs(NES)) %>%
dplyr::arrange(NES) %>%
dplyr::mutate(GeneID = factor(GeneID))
ggplot(tf_activities_A549vsCOV2_top25,aes(x = reorder(GeneID, NES), y = NES)) +
geom_bar(aes(fill = NES), stat = "identity") +
scale_fill_gradient2(low = "darkblue", high = "indianred",
mid = "whitesmoke", midpoint = 0) +
theme_minimal() +
theme(axis.title = element_text(face = "bold", size = 12),
axis.text.x =
element_text(angle = 45, hjust = 1, size =10, face= "bold"),
axis.text.y = element_text(size =10, face= "bold"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
xlab("Transcription Factors")
```
<!-- -->
### Reading Kinase Activity
We here read the kinase activity computed by Danish Memon
<memon@ebi.ac.uk> from the phosphoproteomics data extracted from the
following publication:
<https://www.biorxiv.org/content/10.1101/2020.06.17.156455v1>
``` r
## We take the kinase activity after 24 hours to be in line with the transcriptomics
## data
DIA_kinase_activity <- read_csv("Mann/diaCovidKinaseActMat.csv") %>%
dplyr::rename(kinase = "X1") %>%
dplyr::select(kinase, `24h`)
```
## Warning: Missing column names filled in: 'X1' [1]
### Generating the Prior Knowledge Network from Omnipath
We use the OmnipathR package to fetch the Omnipath database and generate
the prior knowledge network. We take the signed and directed
protein-protein interactions.
``` r
ia_omnipath <- import_omnipath_interactions() %>% as_tibble()
```
## Downloaded 36684 interactions.
``` r
ia_pwextra <- import_pathwayextra_interactions() %>% as_tibble()
```
## Downloaded 44955 interactions.
``` r
ia_kinaseextra <- import_kinaseextra_interactions() %>% as_tibble()
```
## Downloaded 22338 interactions.
``` r
## We bind the datasets
interactions <- as_tibble(
bind_rows(
ia_omnipath %>% mutate(type = 'ppi'),
ia_pwextra %>% mutate(type = 'ppi'),
ia_kinaseextra %>% mutate(type = 'ppi')))
signed_directed_interactions <-
dplyr::filter(interactions, consensus_direction==1) %>%
filter(consensus_stimulation == 1 | consensus_inhibition == 1) %>%
dplyr::mutate(sign = if_else(consensus_stimulation==1,1,-1)) %>%
dplyr::select(source_genesymbol, sign, target_genesymbol) %>%
dplyr::rename(source ="source_genesymbol", target ="target_genesymbol")
carnival_pkn <- signed_directed_interactions %>%
dplyr::distinct(source, target, .keep_all = TRUE)
all_source_nodes <- unique(carnival_pkn$source)
all_target_nodes <- unique(carnival_pkn$target)
all_nodes_network <- unique(c(all_source_nodes,all_target_nodes))
```
## Results
We are going to run CARNIVAL twice using the TF activity as the CARNIVAL
measurements and the kinase activities as perturbations. In the second
run, we will additionally use pathway scores from progeny as weights for
the network. For these runs, we are going to select the top 30 TFs and
the top 10 kinases.
``` r
top_10_kinases <- DIA_kinase_activity %>%
dplyr::filter(kinase %in% all_source_nodes) %>%
dplyr::top_n(10,abs(`24h`)) %>%
tibble::column_to_rownames(var = "kinase") %>%
t() %>% sign() %>% as.data.frame()
top_30_tf <- tf_activities_A549vsCOV2_stat %>%
as.data.frame() %>%
rownames_to_column(var = "GeneID") %>%
dplyr::filter(GeneID %in% all_nodes_network) %>%
dplyr::arrange(desc(abs(stat))) %>%
dplyr::top_n(30, wt = abs(stat)) %>%
column_to_rownames(var = "GeneID") %>%
t() %>% as.data.frame()
progeny_weigths <- pathways_A549vsCOV2_zscore_inputCarnival %>%
as.data.frame() %>% t()
```
### CARNIVAL without progeny weights
``` r
carnival_results_noprogeny <-runCARNIVAL(
solverPath="/opt/ibm/ILOG/CPLEX_Studio129/cplex/bin/x86-64_linux/cplex",
netObj=carnival_pkn,
measObj=top_30_tf,
inputObj = top_10_kinases,
# dir_name="Carnival_Results",
# weightObj=as.data.frame(t(Kin_activity_LNCaP_noInhib_t1_EGF)),
# nodeID = 'gene',
timelimit = 900,
solver = "cplex")
saveRDS(carnival_results_noprogeny,
file = "Carnival_Results/carnival_results_noprogeny.rds")
OutputCyto(carnival_results_noprogeny,
outputFile="Carnival_Results/carnival_results_noprogeny")
```
Network with the results: Rectangles are the most active transcription
factors after infection and the inverse triangles are the most active
kinases. Ellipses are signaling intermediates proteins linking those
kinsases and TFs. Red means positive activity or overphosphorylation
after infection and blue the opposite.
<br><br> 
<br><br>
### CARNIVAL with progeny weights
``` r
carnival_results_withprogeny <-runCARNIVAL(
solverPath="/opt/ibm/ILOG/CPLEX_Studio129/cplex/bin/x86-64_linux/cplex",
netObj=carnival_pkn,
measObj=top_30_tf,
inputObj = top_10_kinases,
# dir_name="Carnival_Results",
weightObj=progeny_weigths,
# nodeID = 'gene',
timelimit = 900,
solver = "cplex")
saveRDS(carnival_results_withprogeny,
file = "Carnival_Results/carnival_results_withprogeny.rds")
OutputCyto(carnival_results_withprogeny,
outputFile="Carnival_Results/carnival_results_withprogeny")
```
<br><br>

<br><br>
## Session Info Details
## R version 4.0.1 (2020-06-06)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 19.10
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.3.7.so
##
## locale:
## [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
## [5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
## [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] parallel stats4 stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] ggplot2_3.3.1 tibble_3.0.1
## [3] tidyr_1.1.0 dplyr_1.0.0
## [5] dorothea_1.0.0 progeny_1.11.1
## [7] OmnipathR_1.3.2 jsonlite_1.6.1
## [9] igraph_1.2.5 CARNIVAL_1.0.1
## [11] DESeq2_1.28.1 SummarizedExperiment_1.18.1
## [13] DelayedArray_0.14.0 matrixStats_0.56.0
## [15] Biobase_2.48.0 GenomicRanges_1.40.0
## [17] GenomeInfoDb_1.24.0 IRanges_2.22.2
## [19] S4Vectors_0.26.1 BiocGenerics_0.34.0
## [21] readr_1.3.1
##
## loaded via a namespace (and not attached):
## [1] segmented_1.1-0 Category_2.54.0 bitops_1.0-6
## [4] bit64_0.9-7 doParallel_1.0.15 RColorBrewer_1.1-2
## [7] httr_1.4.1 tools_4.0.1 R6_2.4.1
## [10] KernSmooth_2.23-17 DBI_1.1.0 colorspace_1.4-1
## [13] withr_2.2.0 gridExtra_2.3 tidyselect_1.1.0
## [16] bit_1.1-15.2 curl_4.3 compiler_4.0.1
## [19] graph_1.66.0 labeling_0.3 scales_1.1.1
## [22] genefilter_1.70.0 RBGL_1.64.0 rappdirs_0.3.1
## [25] stringr_1.4.0 digest_0.6.25 mixtools_1.2.0
## [28] rmarkdown_2.2 XVector_0.28.0 pkgconfig_2.0.3
## [31] htmltools_0.4.0 bcellViper_1.24.0 dbplyr_1.4.4
## [34] rlang_0.4.6 RSQLite_2.2.0 farver_2.0.3
## [37] generics_0.0.2 BiocParallel_1.22.0 viper_1.22.0
## [40] RCurl_1.98-1.2 magrittr_1.5 GenomeInfoDbData_1.2.3
## [43] Matrix_1.2-18 Rcpp_1.0.4.6 munsell_0.5.0
## [46] lifecycle_0.2.0 stringi_1.4.6 yaml_2.2.1
## [49] UniProt.ws_2.28.0 MASS_7.3-51.6 zlibbioc_1.34.0
## [52] BiocFileCache_1.12.0 grid_4.0.1 blob_1.2.1
## [55] ggrepel_0.8.2 crayon_1.3.4 lattice_0.20-41
## [58] splines_4.0.1 annotate_1.66.0 hms_0.5.3
## [61] locfit_1.5-9.4 knitr_1.28 pillar_1.4.4
## [64] geneplotter_1.66.0 codetools_0.2-16 lpSolve_5.6.15
## [67] XML_3.99-0.3 glue_1.4.1 evaluate_0.14
## [70] vctrs_0.3.1 foreach_1.5.0 gtable_0.3.0
## [73] purrr_0.3.4 kernlab_0.9-29 assertthat_0.2.1
## [76] xfun_0.14 xtable_1.8-4 e1071_1.7-3
## [79] class_7.3-17 survival_3.1-12 iterators_1.0.12
## [82] AnnotationDbi_1.50.0 memoise_1.1.0 ellipsis_0.3.1
## [85] GSEABase_1.50.1