-
Notifications
You must be signed in to change notification settings - Fork 2
/
functional_predictions_single_circRNA.Rmd
executable file
·3376 lines (2054 loc) · 113 KB
/
functional_predictions_single_circRNA.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
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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "CRAFT functional predictions"
author: "Please cite: _Dal Molin et al. CRAFT: a bioinformatics software for custom prediction of circular RNA functions_" #"Author: Anna Dal Molin"
date: "`r Sys.Date()`"
header-includes:
\usepackage{caption}
output:
rmdformats::readthedown:
html_document:
fig_caption: yes
number_sections: yes
toc: yes
toc_float: yes
pdf_document:
toc: yes
editor_options:
chunk_output_type: inline
params:
circ: ""
l: 50000
QUANTILE1: "FALSE"
thr1: 0.95
score_miRNA: 80
energy_miRNA: -15
QUANTILE2: "FALSE"
thr2: 0.95
dGduplex_miRNA: -15
dGopen_miRNA: -15
QUANTILE3: "FALSE"
thr3: 0.9
voteFrac_RBP: 0.15
orgdb: "org.Hs.eg.db"
meshdb: "MeSH.Hsa.eg.db"
symbol2eg: "org.Hs.egSYMBOL2EG"
eg2uniprot: "org.Hs.egUNIPROT"
org: "hsapiens"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE, error = TRUE, dpi = 600, root.dir = "/data/.scripts/")
```
```{r libraries, echo=FALSE, include=FALSE}
.libPaths( c( '/data/.R/lib', .libPaths()) )
# su "/usr/local/lib/R/site-library":
library("knitr")
library(BiocManager)
library(dplyr)
library(tibble)
library(data.table)
library(ggplot2)
library(RColorBrewer)
library(viridis)
library(reshape2)
library(DT)
library(gtable)
library(tidyverse)
library(cowplot)
library(plyr)
library(gt)
library(glue)
library(rmdformats)
library(ggrepel)
library(ggupset)
library(ggnewscale)
# su "/usr/lib/R/site-library":
library(AnnotationDbi)
#BiocManager::install(params$meshdb)
#library(params$meshdb, character.only = TRUE) # MeSH-related packages (MeSH.XXX.eg.db, MeSH.db, MeSH.AOR.db, and MeSH.PCR.db) were deprecated in Bioconductor 3.14
library(multiMiR)
library(topGO)
library(DOSE)
library(enrichplot)
if (!dir.exists(paste0("/data/.R/lib/", params$orgdb))) { BiocManager::install(params$orgdb, lib="/data/.R/lib") }
library(params$orgdb, character.only = TRUE)
library(clusterProfiler) # do not update "rvcheck"
library(ReactomePA)
library(meshes)
library(UniprotR)
```
```{r input, echo=FALSE, include=FALSE}
## Upload input files
# file of parameters
file_parameters <- "/data/params_R.txt"
parameters <- read.table(file_parameters, header=F)
parameters <- as.data.table(parameters)
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
# miRNA prediction
# miRanda
file_miRanda <- "/data/functional_predictions/miRNA_detection/miRanda/output_miRanda_per_R.txt"
miRanda_pred <- read.table(file_miRanda, header=T, sep="\t")
miRanda_pred <- as.data.table(miRanda_pred)
# PITA
file_PITA <- "/data/functional_predictions/miRNA_detection/PITA/pred_pita_results_per_R.txt"
PITA_pred <- read.table(file_PITA, header=T, sep="\t")
PITA_pred <- as.data.table(PITA_pred)
}
if (parameters[1] == "R" | parameters[1] == "MR" | parameters[1] == "RO" | parameters[1] == "MRO") {
# RBP predictions
file_beRBP <- "/data/functional_predictions/RBP_detection/beRBP/analysis_RBP/resultMatrix_b.txt"
beRBP_pred <- read.table(file_beRBP, header=T, sep="\t")
beRBP_pred <- as.data.table(beRBP_pred)
}
if (parameters[1] == "O" | parameters[1] == "MO" | parameters[1] == "RO" | parameters[1] == "MRO") {
# ORF prediction
file_ORFfinder <- "/data/functional_predictions/ORF_detection/ORFfinder/ORF_backsplice.txt"
ORFfinder_pred <- read.table(file_ORFfinder, header=T, sep="\t")
ORFfinder_pred <- as.data.table(ORFfinder_pred)
file_openORF <- "/data/functional_predictions/ORF_detection/ORFfinder/ORF_backsplice_open.txt"
openORF <- read.table(file_openORF, header=T, sep="\t")
openORF <- as.data.table(openORF)
file_list_CDS <- "/data/functional_predictions/ORF_detection/ORFfinder/result_list_CDS.txt"
list_CDS <- read.table(file_list_CDS, header=F, sep="\t")
list_CDS <- as.data.table(list_CDS)
file_list_ORF <- "/data/functional_predictions/ORF_detection/ORFfinder/result_list_ORF.txt"
list_ORF <- read.table(file_list_ORF, header=F, sep="\t")
list_ORF <- as.data.table(list_ORF)
}
# circRNA length
file_circ_length <- "/data/functional_predictions/backsplice_circRNA_length_1.txt"
circ_length <- read.table(file_circ_length, header=T, sep="\t")
circ_length <- as.data.table(circ_length)
# gene names
file_gene_names <- "/data/functional_predictions/backsplice_gene_name.txt"
gene_names <- read.table(file_gene_names, header=T, sep="\t")
gene_names <- as.data.table(gene_names)
```
```{r output, echo=FALSE, include=FALSE}
output_dir <- paste0("/data/graphical_output/", params$circ, "/")
```
```{r logo, echo=FALSE, include=TRUE}
htmltools::img(src = knitr::image_uri("/input/CRAFT_logo.png"),
alt = 'logo',
style = 'position:absolute; top: -25px; right: 700px; padding:12px; height:160px; width:160px')
#style = 'position:absolute; top:5px; right:50px; padding:10px; height:180px; width:180px') # theme cerulean
```
```{r, echo=FALSE, include=FALSE}
circ_name <- gene_names[circ_id %in% params$circ, gene_names]
```
---
subtitle: Circ`r circ_name` (`r params$circ`) functional predictions
---
# Summary
```{r, echo=FALSE, include=FALSE}
# remove circRNAs with length > "l"
circ_l <- circ_length[length < params$l, circ_id]
```
```{r miRanda, echo=FALSE, include=FALSE}
### miRNA predictions
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
## miRanda
# remove circRNAs with length > "l"
miRanda_pred_l <- miRanda_pred[circ_id %in% circ_l,]
# select the circRNA of interest
miRanda_pred_l_circ <- miRanda_pred_l[circ_id == params$circ,]
# filter on "score" ed "energy"
if (params$QUANTILE1 == "TRUE") {
score_miRNA <- quantile(miRanda_pred_l_circ$score, params$thr1)
energy_miRNA <- quantile(miRanda_pred_l_circ$energy, 1-params$thr1)
} else {
score_miRNA <- params$score_miRNA
energy_miRNA <- params$energy_miRNA
}
miRanda_pred_l_circ_sel <- miRanda_pred_l_circ[(score > score_miRNA & energy < energy_miRNA),]
}
```
```{r PITA, echo=FALSE, include=FALSE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
## PITA
# remove circRNAs with length > "l"
PITA_pred_l <- PITA_pred[circ_id %in% circ_l,]
# select the circRNA of interest
PITA_pred_l_circ <- PITA_pred_l[circ_id == params$circ,]
# filter on "dGduplex" and "dGopen"
if (params$QUANTILE2 == "TRUE") {
dGduplex_miRNA <- quantile(PITA_pred_l_circ$dGduplex, 1-params$thr2)
dGopen_miRNA <- quantile(PITA_pred_l_circ$dGopen, params$thr2)
} else {
dGduplex_miRNA <- params$dGduplex_miRNA
dGopen_miRNA <- params$dGopen_miRNA
}
PITA_pred_l_circ_sel <- PITA_pred_l_circ[(dGduplex < dGduplex_miRNA & dGopen > dGopen_miRNA),]
}
```
```{r miRNA_pred, echo=FALSE, include=FALSE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
# merge miRanda and PITA predictions
miRanda_pred_l_circ_sel$circ_miRNA_end_id <- paste0(miRanda_pred_l_circ_sel$circ_id, "__", miRanda_pred_l_circ_sel$miRNA_id, "__", miRanda_pred_l_circ_sel$circ_end)
PITA_pred_l_circ_sel$circ_miRNA_end_id <- paste0(PITA_pred_l_circ_sel$circ_id, "__", PITA_pred_l_circ_sel$miRNA_id, "__", PITA_pred_l_circ_sel$circ_end)
setkey(miRanda_pred_l_circ_sel, circ_miRNA_end_id)
setkey(PITA_pred_l_circ_sel, circ_miRNA_end_id)
miRNA_pred <- merge(miRanda_pred_l_circ_sel, PITA_pred_l_circ_sel, all=FALSE)
miRNA_pred <- data.table("circ_id" = miRNA_pred$circ_id.x, "miRNA_id" = miRNA_pred$miRNA_id.x, "putative_circ_start" = miRNA_pred$circ_end.x - 22, "circ_end" = miRNA_pred$circ_end.x, "miRanda_score" = miRNA_pred$score, "miRanda_energy" = miRNA_pred$energy, "circ_align_perc" = miRNA_pred$circ_align_perc, "miRNA_align_perc" = miRNA_pred$miRNA_align_perc, "dGduplex" = miRNA_pred$dGduplex, "dG5" = miRNA_pred$dG5, "dG3" = miRNA_pred$dG3, "dG0" = miRNA_pred$dG0, "dG1" = miRNA_pred$dG1, "dGopen" = miRNA_pred$dGopen, "ddG" = miRNA_pred$ddG)
}
```
```{r barM, echo=FALSE, include=FALSE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
barM <- miRNA_pred[, c("circ_id", "miRNA_id", "putative_circ_start", "circ_end")]
colnames(barM)[3] <- "circ_start"
barM$circ_miRNA_start_id <- paste0(barM$circ_id, "__", barM$miRNA_id, "__", barM$circ_start)
}
```
```{r RBP, echo=FALSE, include=FALSE}
## RBP binding sites predictions
if (parameters[1] == "R" | parameters[1] == "MR" | parameters[1] == "RO" | parameters[1] == "MRO") {
# beRBP
# remove circRNAs with length > "l"
beRBP_pred_l <- beRBP_pred[circ_id %in% circ_l,]
# select the circRNA of interest
beRBP_pred_l_circ <- beRBP_pred_l[circ_id == params$circ,]
# filter on "voteFrac"
if (params$QUANTILE3 == "TRUE") {
voteFrac_RBP <- quantile(beRBP_pred_l_circ$voteFrac, params$thr3)
} else {
voteFrac_RBP <- params$voteFrac_RBP
}
beRBP_pred_l_circ_sel <- beRBP_pred_l_circ[voteFrac >= voteFrac_RBP,]
}
```
```{r barP, echo=FALSE, include=FALSE}
if (parameters[1] == "R" | parameters[1] == "MR" | parameters[1] == "RO" | parameters[1] == "MRO") {
barP <- beRBP_pred_l_circ_sel
colnames(barP)[1] <- "circ_id"
colnames(barP)[5] <- "circ_start"
barP$circ_RBP_start_id <- paste0(barP$circ_id, "__", barP$RBP, "__", barP$circ_start)
}
```
```{r ORF, echo=FALSE, include=FALSE}
## ORF predictions
if (parameters[1] == "O" | parameters[1] == "MO" | parameters[1] == "RO" | parameters[1] == "MRO") {
# ORFfinder
# remove circRNAs with length > "l"
ORFfinder_pred_l <- ORFfinder_pred[circ_id %in% circ_l,]
openORF_l <- openORF[circ_id %in% circ_l,]
openORF_l[open == "open",]$open <- "T"
# select the circRNA of interest
ORFfinder_pred_l_circ <- ORFfinder_pred_l[circ_id == params$circ,]
openORF_l_circ <- openORF_l[circ_id == params$circ,]
# select only the longest ORF with a stop codon
l2 <- circ_length[circ_id == params$circ]$length
if (ORFfinder_pred_l_circ[, .N] >= 1) {
ORFfinder_pred_l_circ_best <- head(ORFfinder_pred_l_circ[order(-length_aa),], 1)
orf_start <- ORFfinder_pred_l_circ_best$start
orf_end <- l2 - (2*l2 - ORFfinder_pred_l_circ_best$end) # ORF crossing the bks
} else {
orf_start <- l2
orf_end <- 0
}
}
```
```{r circular_barplot_miRNA-RBP-ORF, echo=FALSE, include=TRUE, fig.width=11, fig.height=11}
if (parameters[1] == "MRO") {
# Create dataset
dataM <- data.table("circ_id" = barM$circ_id,
"binding" = barM$miRNA_id,
"circ_start" = barM$circ_start,
"label" = "miRNA"
)
dataP <- data.table("circ_id" = barP$circ_id,
"binding" = barP$RBP,
"circ_start" = barP$circ_start,
"label" = "RBP"
)
dataP <- unique(dataP)
data <- rbind(dataM, dataP)
data$label <- as.factor(data$label)
n <- max(data[, .N, by = circ_start]$N)
# Get the name and the y position of each label
label_data <- data
# calculate the ANGLE of the labels
number_of_bar <- l2
angle <- 90 - 360 * (label_data$circ_start-0.5) / number_of_bar
label_data$hjust <- ifelse(angle < -90, 1, 0)
# flip angle BY to make them readable
label_data$angle <- ifelse(angle < -90, angle+180, angle)
label_data[hjust == 1, "hjust"] <- 0
# Prepare a data frame for grid (scales)
grid_data <- data.table("start" = 0,
"end" = l2)
# Make the plot
circ_plot <- ggplot(data, aes(x = circ_start, y = 1, fill = label)) +
geom_bar(aes(x = circ_start, y = 1), stat="identity", alpha=0.5, width=l2*3/500) +
scale_fill_manual(values = c("#E65100", "#1565C0")) +
# Add lines
geom_segment(data=grid_data, aes(x = start+4, y = 0, xend = end-4, yend = 0), colour = "darkgrey", alpha=1, size=2.5, inherit.aes = FALSE ) +
geom_segment(data=grid_data, aes(x = end-4, y = 0, xend = end, yend = 0), colour = "black", alpha=1, size=2.5, inherit.aes = FALSE ) +
geom_segment(data=grid_data, aes(x = start, y = 0, xend = start+4, yend = 0), colour = "black", alpha=1, size=2.5, inherit.aes = FALSE ) +
geom_segment(data=grid_data, aes(x = orf_start, y = 0.1, xend = l2, yend = 0.15), colour = "darkred", alpha=1, size=1, inherit.aes = FALSE ) +
geom_segment(data=grid_data, aes(x = 0, y = 0.15, xend = orf_end, yend = 0.2), colour = "darkred", alpha=1, size=1, inherit.aes = FALSE ) +
# Add text
annotate("text", x = 0, y = 0.3, label = "ORF", color="darkred", size=3, angle=0, fontface="plain", hjust=1) +
annotate("text", x = 20, y = -0.12, label = "bks", color = "black", size = 3, fontface = "bold", hjust=1) +
ylim(-1, n+1.5) +
labs(fill = "Interaction") +
theme_minimal() +
theme(
legend.position = "right",
text = element_text(size=8),
axis.title = element_blank(),
axis.text.x = element_text(angle=0, hjust=1),
axis.text.y = element_text(angle=0, hjust=12.7, vjust=-0.3)
) +
coord_polar(start = 0) +
# Add labels on top of each bar
geom_text_repel(data = label_data, aes(x = circ_start, y = n+0.1, label = binding, hjust = hjust),
color="black",
fontface="bold",
alpha=0.6,
size=2.5,
angle=angle,
inherit.aes = FALSE,
max.overlaps = 50)
print(circ_plot)
# Save at png
ggsave(circ_plot, file=paste0(output_dir, "circplot_all_predictions.png"), width=11, height=11, dpi = 600)
}
```
# MiRNA binding sites predictions
```{r print_0, echo=FALSE, include=FALSE}
print_0 <- "Analysis not performed."
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
print_0 <- ""
}
```
`r print_0`
```{r circular_barplot_miRNA, echo=FALSE, include=TRUE, fig.width=10, fig.height=10}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
# Create dataset
data <- barM
n <- max(data[, .N, by = circ_start]$N)
l <- circ_length[circ_id == params$circ]$length
# Get the name and the y position of each label
label_data <- data
# calculate the ANGLE of the labels
number_of_bar <- l
angle <- 90 - 360 * (label_data$circ_start-0.5) / number_of_bar
label_data$hjust <- ifelse(angle < -90, 1, 0)
# flip angle BY to make them readable
label_data$angle <- ifelse(angle < -90, angle+180, angle)
label_data[hjust == 1, "hjust"] <- 0
# Prepare a data frame for grid (scales)
grid_data <- data.table("start" = 0,
"end" = l)
# Make the plot
circ_plot <- ggplot(data, aes(x = circ_start, y = 1)) +
geom_bar(aes(x = circ_start, y = 1), fill=alpha("#1565C0", 0.7), stat="identity", alpha=0.5, width=l*3/500) +
# Add lines
geom_segment(data=grid_data, aes(x = start+4, y = 0, xend = end-4, yend = 0), colour = "darkgrey", alpha=1, size=2.5, inherit.aes = FALSE ) +
geom_segment(data=grid_data, aes(x = end-4, y = 0, xend = end, yend = 0), colour = "black", alpha=1, size=2.5, inherit.aes = FALSE ) +
geom_segment(data=grid_data, aes(x = start, y = 0, xend = start+4, yend = 0), colour = "black", alpha=1, size=2.5, inherit.aes = FALSE ) +
#Add text
annotate("text", x = 20, y = -0.12, label = "bks", color = "black", size = 3, fontface = "bold", hjust=1) +
ylim(-1, n+1.5) +
theme_minimal() +
theme(
legend.position = "none",
text = element_text(size=8),
axis.title = element_blank(),
axis.text.x = element_text(angle=0, hjust=1),
axis.text.y = element_text(angle=0, hjust=12.7, vjust=-0.3)
) +
coord_polar(start = 0) +
# Add labels on top of each bar
geom_text_repel(data = label_data, aes(x = circ_start, y = n+0.1, label = miRNA_id, hjust = hjust),
color="black",
fontface="bold",
alpha=0.6,
size=2.5,
angle=angle,
inherit.aes = FALSE,
max.overlaps = 50)
print(circ_plot)
# Save at png
ggsave(circ_plot, file=paste0(output_dir, "circplot_miRNA.png"), width=10, height=10, dpi = 600)
}
}
```
```{r pre_table_miRNA_binding_sites, echo=FALSE, include=TRUE}
if ((parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") & (miRNA_pred[, .N] > 0)) {
setkey(miRNA_pred, circ_id)
setkey(gene_names, circ_id)
miRNA_pred <- miRNA_pred[gene_names, nomatch = 0]
miRNA_pred$gene_circ_names <- paste0("circ", miRNA_pred$gene_names, "_", miRNA_pred$circ_id)
} else {
miRNA_pred <- data.table(miRNA_id = integer())
}
```
Number of different identified miRNAs: `r length(unique(miRNA_pred$miRNA_id))`.
```{r table_miRNA_binding_sites, echo=FALSE, include=TRUE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
data_escape <- miRNA_pred[, c(1,16,seq(2,15))]
data_escape$gene_names <- paste0("<a href=\"", "https://www.genecards.org/cgi-bin/carddisp.pl?gene=", data_escape$gene_names, "\" target=\"_blank\">", data_escape$gene_names, "</a>")
data_escape$miRNA_id <- paste0("<a href=\"", "http://www.mirbase.org/textsearch.shtml?q=", data_escape$miRNA_id, "&submit=submit", "\" target=\"_blank\">", data_escape$miRNA_id, "</a>")
datatable(data = data_escape,
rownames = F,
colnames = c("CircRNA", "Gene name", "MiRNA", "CircRNA start position", "CircRNA end position", "MiRanda score", "MiRanda energy", "% alignment circRNA", "% alignment miRNA", "dGduplex", "dG5", "dG3", "dG0", "dG1", "dGopen", "ddG"),
style = "bootstrap",
class = "compact display",
caption = paste0("Predicted miRNA binding sites. CircRNA host gene name is linked to GeneCards, miRNA name is linked to miRBase. Filters are based on highlighted columns (miRanda score > ", score_miRNA,", miRanda energy < ", energy_miRNA, "; PITA dGduplex < ", dGduplex_miRNA, ", PITA dGopen > ", dGopen_miRNA, "). Best predictions are obtained with higher score and lower energy for miRanda, and lower dGduplex and higher dGopen for PITA."),
fillContainer = F,
autoHideNavigation = T,
filter = "top",
escape = FALSE,
extensions = c('ColReorder', 'Buttons', 'KeyTable'),
options = list(colReorder = TRUE,
searching = TRUE,
pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
keys = TRUE
)
) %>%
formatStyle(c("miRanda_score", "miRanda_energy", "dGduplex", "dGopen"),
backgroundColor = 'lightskyblue'
)
}
}
```
## Validated miRNA target genes (TGs)
```{r, echo=FALSE, include=FALSE}
# validated target genes
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
if (parameters[2] == "hsa" | parameters[2] == "mmu" | parameters[2] == "rno") {
## multiMir
multimir_results_all <- data.table()
miRNA_id <- barM$miRNA_id
if (length(miRNA_id) > 0) {
specie <- case_when(
parameters[2] == "hsa" ~ "hsa",
parameters[2] == "mmu" ~ "mmu",
parameters[2] == "rno" ~ "rno"
)
multimir_results <- get_multimir(org = specie, mirna = miRNA_id, table = 'validated', summary = TRUE)
multimir_results <- as.data.table(multimir_results@data)
#filter for strong categories
multimir_results <- multimir_results[grep("PAR-CLIP|HITS-CLIP|CLASH|Luciferase|Degradome|ChIP-seq|ELISA|Immuno.*", experiment),]
multimir_results <- multimir_results[support_type != "Functional MTI (Weak)",]
if (multimir_results[, .N] != 0) {
pair_miRNA_tg <- unique(multimir_results[, 3:4])
pair_miRNA_tg <- pair_miRNA_tg[target_symbol != "",]
tg_per_miRNA <- pair_miRNA_tg[, .N, by = mature_mirna_id] # unique
tg_per_miRNA$mature_mirna_id <- paste0("<a href=\"", "http://www.mirbase.org/textsearch.shtml?q=", tg_per_miRNA$mature_mirna_id, "&submit=submit", "\" target=\"_blank\">", tg_per_miRNA$mature_mirna_id, "</a>")
miRNA_per_tg <- pair_miRNA_tg[, .N, by = target_symbol][order(-N),]
}
}
}
}
}
```
```{r print_1, echo=FALSE, include=FALSE}
print_1 <- "Number of identified TGs: 0."
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
if (parameters[2] == "hsa" | parameters[2] == "mmu" | parameters[2] == "rno") {
if (length(miRNA_id) > 0) {
if (multimir_results[, .N] != 0) {
print_1 <- paste0("Number of identified TGs: ", length(unique(miRNA_per_tg$target_symbol)), ".")
}
}
}
}
}
```
`r print_1`
```{r table_validated_TG, echo=FALSE, include=TRUE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
if (parameters[2] == "hsa" | parameters[2] == "mmu" | parameters[2] == "rno") {
if (length(miRNA_id) > 0 & multimir_results[, .N] != 0) { # not necessary
data_escape <- multimir_results
data_escape <- data_escape[, -"mature_mirna_acc"]
organism <- case_when(
parameters[2] == "hsa" ~ "Homo_sapiens",
parameters[2] == "mmu" ~ "Mus_musculus",
parameters[2] == "rno" ~ "Rattus_norvegicus"
)
data_escape$mature_mirna_id <- paste0("<a href=\"", "http://www.mirbase.org/textsearch.shtml?q=", data_escape$mature_mirna_id, "&submit=submit", "\" target=\"_blank\">", data_escape$mature_mirna_id, "</a>")
data_escape$target_symbol <- paste0("<a href=\"", "https://www.genecards.org/cgi-bin/carddisp.pl?gene=", data_escape$target_symbol, "\" target=\"_blank\">", data_escape$target_symbol, "</a>")
data_escape$target_entrez <- paste0("<a href=\"", "https://www.ncbi.nlm.nih.gov/gene/", data_escape$target_entrez,"\" target=\"_blank\">", data_escape$target_entrez, "</a>")
data_escape$target_ensembl <- paste0("<a href=\"", "https://www.ensembl.org/", organism ,"/Gene/Summary?db=core;g=", data_escape$target_ensembl, "\" target=\"_blank\">", data_escape$target_ensembl, "</a>")
data_escape$pubmed_id <- paste0("<a href=\"", "https://pubmed.ncbi.nlm.nih.gov/", data_escape$pubmed_id, "\" target=\"_blank\">", data_escape$pubmed_id, "</a>")
colnames(data_escape) <- c("Database", "Mature miRNA id", "Target gene", "Entrez", "Ensembl", "Experiment", "Support type", "Pubmed", "Type")
data_escape <- data_escape[order(Database),]
datatable(data = data_escape,
rownames = F,
style = "bootstrap",
class = "compact display",
caption = "Validated target genes (TGs). MiRNA name is linked to miRBase, TG name is linked to GeneCards, Entrez and Ensemble databases, the couple miRNA-TG is linked to Pubmed.",
fillContainer = F,
autoHideNavigation = T,
filter = "top",
escape = FALSE,
extensions = c('ColReorder', 'Buttons', 'KeyTable', 'RowGroup'),
options = list(colReorder = TRUE,
searching = TRUE,
pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
keys = TRUE,
rowGroup = list(dataSrc = 0)
)
)
}
}
}
}
```
```{r table_TG_per_miRNA, echo=FALSE, include=TRUE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
if (parameters[2] == "hsa" | parameters[2] == "mmu" | parameters[2] == "rno") {
if (length(miRNA_id) > 0 & multimir_results[, .N] != 0) {
tg_per_miRNA_escape <- tg_per_miRNA
colnames(tg_per_miRNA_escape) <- c("Mature miRNA", "Number of target genes")
datatable(data = tg_per_miRNA_escape,
rownames = F,
style = "bootstrap",
class = "compact display",
caption = "Target genes per miRNA. MiRNA name is linked to miRBase. Barplot highlights the number of target genes for each miRNA.",
fillContainer = F,
autoHideNavigation = T,
filter = "top",
escape = FALSE,
extensions = c('ColReorder', 'Buttons', 'KeyTable'),
options = list(colReorder = TRUE,
searching = TRUE,
pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
keys = TRUE
)
) %>%
formatStyle('Number of target genes',
background = styleColorBar(tg_per_miRNA_escape$`Number of target genes`, 'steelblue'),
backgroundSize = '100% 90%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center'
)
}
}
}
}
```
```{r, echo=FALSE, include=FALSE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
if (parameters[2] == "hsa" | parameters[2] == "mmu" | parameters[2] == "rno") {
if (length(miRNA_id) > 0 & multimir_results[, .N] != 0) {
pair_miRNA_tg$mature_mirna_id <- paste0("<a href=\"", "http://www.mirbase.org/textsearch.shtml?q=", pair_miRNA_tg$mature_mirna_id, "&submit=submit", "\" target=\"_blank\">", pair_miRNA_tg$mature_mirna_id, "</a>")
enr <- pair_miRNA_tg[, .(list(unique(mature_mirna_id)), length(unique(mature_mirna_id))), by = target_symbol]
colnames(enr)[2] <- "miRNA_ids"
colnames(enr)[3] <- "number_of_miRNA"
# delete rows with empty "target_symbol"
enr <- enr[target_symbol != "",]
enr$target_symbol <- paste0("<a href=\"", "https://www.genecards.org/cgi-bin/carddisp.pl?gene=", enr$target_symbol, "\" target=\"_blank\">", enr$target_symbol, "</a>")
}
}
}
}
```
```{r table_miRNA_per_TG, echo=FALSE, include=TRUE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
if (parameters[2] == "hsa" | parameters[2] == "mmu" | parameters[2] == "rno") {
if (length(miRNA_id) > 0 & multimir_results[, .N] != 0) {
enr_escape <- enr
colnames(enr_escape) <- c("Target gene", "Mature miRNA", "Number of miRNAs")
STEP <- (0.95-0.05) / (max(enr_escape$`Number of miRNAs`)-1)
brks <- quantile(unique(enr_escape$`Number of miRNAs`), probs = seq(.05, .95, STEP), na.rm = TRUE)
clrs <- round(seq(255, 40, length.out = max(brks) + 1), 0) %>%
{paste0("rgb(255,", ., ",", ., ")")}
while(length(brks) >= length(clrs)) {
brks <- brks[-1]
}
datatable(data = enr_escape,
rownames = F,
style = "bootstrap",
class = "compact display",
caption = "MiRNAs per target genes. Target gene name is linked to GeneCards, miRNA name is linked to miRBase. Rows are highlighted based on the number of miRNAs binding each target gene.",
fillContainer = F,
autoHideNavigation = T,
filter = "top",
escape = FALSE,
extensions = c('ColReorder', 'Buttons', 'KeyTable'),
options = list(colReorder = TRUE,
searching = TRUE,
pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
keys = TRUE
)
) %>%
formatStyle('Number of miRNAs',
target = "row",
backgroundColor = styleInterval(brks, clrs)
)
}
}
}
}
```
```{r table_miRNA-TG_interaction, echo=FALSE, include=TRUE, message=FALSE, warning=FALSE, error=FALSE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {
if (miRNA_pred[, .N] > 0) {
if (parameters[2] == "hsa" | parameters[2] == "mmu" | parameters[2] == "rno") {
# miRNA-target gene interactions associated with drugs or diseases
if (length(miRNA_id) > 0 & multimir_results[, .N] != 0) {
target_genes <- unique(sort(multimir_results[, "target_symbol"]$target_symbol))
target_genes <- target_genes[target_genes != ""]
if (length(target_genes) > 0) {
multimir_results_drug_disease <- get_multimir(org = specie, mirna = miRNA_id, target = target_genes, table = 'disease.drug', summary = TRUE)
data_escape <- multimir_results_drug_disease@data
data_escape <- as.data.table(data_escape)
data_escape <- data_escape[, -"mature_mirna_acc"]
data_escape$mature_mirna_id <- paste0("<a href=\"", "http://www.mirbase.org/textsearch.shtml?q=", data_escape$mature_mirna_id, "&submit=submit", "\" target=\"_blank\">", data_escape$mature_mirna_id, "</a>")
data_escape$target_symbol <- ifelse(data_escape$target_symbol != "NA", paste0("<a href=\"", "https://www.genecards.org/cgi-bin/carddisp.pl?gene=", data_escape$target_symbol, "\" target=\"_blank\">", data_escape$target_symbol, "</a>"), NA)
data_escape$target_entrez <- ifelse(data_escape$target_entrez != "NA", paste0("<a href=\"", "https://www.ncbi.nlm.nih.gov/gene/", data_escape$target_entrez,"\" target=\"_blank\">", data_escape$target_entrez, "</a>"), NA)
data_escape$target_ensembl <- ifelse(data_escape$target_ensembl != "NA", paste0("<a href=\"", "https://www.ensembl.org/", organism, "/Gene/Summary?db=core;g=", data_escape$target_ensembl, "\" target=\"_blank\">", data_escape$target_ensembl, "</a>"), NA)
data_escape$paper_pubmedID <- ifelse(data_escape$database != "mir2disease", paste0("<a href=\"", "https://pubmed.ncbi.nlm.nih.gov/", data_escape$paper_pubmedID, "\" target=\"_blank\">", data_escape$paper_pubmedID, "</a>"), data_escape$paper_pubmedID)
colnames(data_escape) <- c("Database", "Mature miRNA id", "Target gene", "Entrez", "Ensembl", "Disease drug", "Pubmed", "Type")
data_escape <- data_escape[order(Database),]
datatable(data = data_escape,
rownames = F,
style = "bootstrap",
class = "compact display",
caption = "MiRNA-target gene interactions associated with drugs or diseases. MiRNAs are linked to miRBase, target genes are linked to GeneCards.",
fillContainer = F,
autoHideNavigation = T,
filter = "top",
escape = FALSE,
extensions = c('ColReorder', 'Buttons', 'KeyTable', 'RowGroup'),
options = list(colReorder = TRUE,
searching = TRUE,
pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
keys = TRUE,
rowGroup = list(dataSrc = 0)
)
)
}
}
}
}
}
```
## Over-Representation Analysis (ORA)
```{r pre_ORA, echo=FALSE, include=TRUE}
if (parameters[1] == "M" | parameters[1] == "MR" | parameters[1] == "MO" | parameters[1] == "MRO") {