-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircRNA_mk_and_plt.Rmd
More file actions
2203 lines (1561 loc) · 85.7 KB
/
Copy pathcircRNA_mk_and_plt.Rmd
File metadata and controls
2203 lines (1561 loc) · 85.7 KB
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: "CircRNA expression and function in Megakaryocytes and platelets"
author: "Benoit P Nicolet"
date: "09/03/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(plyr)
library(dplyr)
library(pheatmap)
library(ggplot2)
library(RColorBrewer)
library(colorRamps)
library(devtools)
library(ggfortify)
library(reshape)
library(circlize)
library(biomaRt)
library(DESeq2)
library(stringr)
knitr::opts_knit$set("/home/ben/Analysis/circRNA_erys/circMK/")
```
# importing circRNA counts from DCC
```{r DCC circ import}
# DCC_MK is the DCC circRNA detection file
# DCC_MK_lin is the DCC linRNA detection file
### importing DCC circRNA counts ###
# DCC_MK <- read.delim('/.../Personal Folders/circRNA_ery_diff/MK_diff/DCC/CircRNACount',header=T)
#
# # DCC start sites are always 1nt after CE... Here I correct for that. Also make the ID column
# DCC_MK$Start <- as.numeric(DCC_MK$Start -1)
#
# # Making circRNA ID format (Chr:Start-End)
# DCC_MK$ID <- do.call(paste, c(DCC_MK[c("Start", "End")], sep = "-"))
# DCC_MK$ID <- do.call(paste, c(DCC_MK[c("Chr", "ID")], sep = ":"))
#
# #head(DCC_MK)
#
# # Remove circRNA from mitochondria #
# dim(DCC_MK)
# DCC_MK <- subset(DCC_MK, Chr != "chrM")
# dim(DCC_MK)
#
# # Make an ordered file for the rest of the analysis #
# DCC_MK <- data.frame("ID"=DCC_MK$ID,
# "CD42neg_1"=DCC_MK$C1MK42negChimeric.out.junction,"CD42neg_2"=DCC_MK$C2MK42negChimeric.out.junction,
# "CD42neg_3"=DCC_MK$C3MK42negChimeric.out.junction,
# "CD42pos_1"=DCC_MK$C1MK42posChimeric.out.junction,"CD42pos_2"=DCC_MK$C2MK42posChimeric.out.junction,
# "CD42pos_3"=DCC_MK$C3MK42posChimeric.out.junction)
#
# head(DCC_MK)
# dim(DCC_MK)
#
# # Combine duplicate counts using IDs #
# DCC_MK <- ddply(DCC_MK, "ID", numcolwise(sum))
# dim(DCC_MK)
#
# write.table(DCC_MK,"DCC_counts_MK_filtered_with_ID.csv",sep = ";",dec = ",",row.names = F)
#
## To simplify the procedure, I stored the results of the above code in a file, and only re-import the file: ##
DCC_MK <- read.delim("/home/ben/Analysis/circRNA_erys/circMK/DCC_counts_MK_filtered_with_ID.csv",sep = ";",dec = ",")
# head(DCC_MK)
```
###importing DCC linear RNA counts
```{r DCC lin import}
# #DCC_MK_lin <- read.delim('/Users/.../Dropbox/circRNA/CircRNA_in_T-cell/R_stuff/Linear_counts_DCC_MK_diff_filtered.csv',header=T,sep=";")
# #head(DCC_MK_lin) # The linear count positions are already corrected for the -1 of DCC
#
# DCC_MK_lin <- read.delim('/Users/.../ShareFile/Personal Folders/circRNA_ery_diff/MK_diff/DCC/LinearCount',header=T)
#
# # DCC start sites are always 1nt after CE... Here I correct for that. Also make ID
# DCC_MK_lin$Start <- as.numeric(DCC_MK_lin$Start -1)
#
# # Making circRNA ID format (Chr:Start-End)
# DCC_MK_lin$ID <- do.call(paste, c(DCC_MK_lin[c("Start", "End")], sep = "-"))
# DCC_MK_lin$ID <- do.call(paste, c(DCC_MK_lin[c("Chr", "ID")], sep = ":"))
#
# head(DCC_MK_lin)
#
#
# DCC_MK_lin <- data.frame("ID"=DCC_MK_lin$ID,
# "CD42neg_1_lin"=DCC_MK_lin$C1MK42negChimeric.out.junction,"CD42neg_2_lin"=DCC_MK_lin$C2MK42negChimeric.out.junction,
# "CD42neg_3_lin"=DCC_MK_lin$C3MK42negChimeric.out.junction,
# "CD42pos_1_lin"=DCC_MK_lin$C1MK42posChimeric.out.junction,"CD42pos_2_lin"=DCC_MK_lin$C2MK42posChimeric.out.junction,
# "CD42pos_3_lin"=DCC_MK_lin$C3MK42posChimeric.out.junction)
#
#
# head(DCC_MK_lin)
# dim(DCC_MK_lin)
#
# # Combine duplicate counts using IDs #
# DCC_MK_lin <- ddply(DCC_MK_lin, "ID", numcolwise(sum))
# dim(DCC_MK_lin)
#
# write.table(DCC_MK_lin,"Linear_counts_DCC_MK_filtered.csv",sep = ";",dec=",",row.names = F)
## To simplify the procedure, I stored the results of the above code in a file, and only re-import the file: ##
DCC_MK_lin <- read.delim("/home/ben/Analysis/circRNA_erys/circMK/Linear_counts_DCC_MK_filtered.csv",sep = ";",dec = ",")
#head(DCC_MK_lin)
```
# DCC circRNA filtering
```{r DCC circRNA filtering}
#DCC_MK
#DCC_MK_LC is the low-confidence filtered circRNA
DCC_MK_LC <- NULL
DCC_MK_LC <- subset(DCC_MK, (as.numeric(DCC_MK$CD42neg_1)>=2|as.numeric(DCC_MK$CD42neg_2)>=2|as.numeric(DCC_MK$CD42neg_3)>=2|
(as.numeric(DCC_MK$CD42pos_1)>=2|as.numeric(DCC_MK$CD42pos_2)>=2|as.numeric(DCC_MK$CD42pos_3)>=2)))
dim(DCC_MK_LC) # 30981 circRNA
DCC_MK_LC[is.na(DCC_MK_LC)]=0
#DCC_MK_hc is the high confidence filtered circRNA
DCC_MK_hc <- subset(DCC_MK, (as.numeric(DCC_MK$CD42neg_1)>=2 & as.numeric(DCC_MK$CD42neg_2)>=2 & as.numeric(DCC_MK$CD42neg_3)>=2|
(as.numeric(DCC_MK$CD42pos_1)>=2 & as.numeric(DCC_MK$CD42pos_2)>=2 & as.numeric(DCC_MK$CD42pos_3)>=2)))
dim(DCC_MK_hc) # 4198 circRNA
DCC_MK_hc[is.na(DCC_MK_hc)]=0
```
# CE import
```{r CE circ counts import}
## Importing circ counts from CE ##
CD42neg_1 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C1MK42negcirc_Annotation.txt',header=F)
CD42neg_2 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C2MK42negcirc_Annotation.txt',header=F)
CD42neg_3 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C3MK42negcirc_Annotation.txt',header=F)
CD42pos_1 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C1MK42poscirc_Annotation.txt',header=F)
CD42pos_2 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C2MK42poscirc_Annotation.txt',header=F)
CD42pos_3 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C3MK42poscirc_Annotation.txt',header=F)
## Checking size ##
dim(CD42neg_1)
dim(CD42neg_2)
dim(CD42neg_3)
dim(CD42pos_1)
dim(CD42pos_2)
dim(CD42pos_3)
## Making IDs ##
CD42neg_1$ID <- do.call(paste, c(CD42neg_1[c("V2", "V3")], sep = "-"))
CD42neg_1$ID <- do.call(paste, c(CD42neg_1[c("V1", "ID")], sep = ":"))
CD42neg_2$ID <- do.call(paste, c(CD42neg_2[c("V2", "V3")], sep = "-"))
CD42neg_2$ID <- do.call(paste, c(CD42neg_2[c("V1", "ID")], sep = ":"))
CD42neg_3$ID <- do.call(paste, c(CD42neg_3[c("V2", "V3")], sep = "-"))
CD42neg_3$ID <- do.call(paste, c(CD42neg_3[c("V1", "ID")], sep = ":"))
CD42pos_1$ID <- do.call(paste, c(CD42pos_1[c("V2", "V3")], sep = "-"))
CD42pos_1$ID <- do.call(paste, c(CD42pos_1[c("V1", "ID")], sep = ":"))
CD42pos_2$ID <- do.call(paste, c(CD42pos_2[c("V2", "V3")], sep = "-"))
CD42pos_2$ID <- do.call(paste, c(CD42pos_2[c("V1", "ID")], sep = ":"))
CD42pos_3$ID <- do.call(paste, c(CD42pos_3[c("V2", "V3")], sep = "-"))
CD42pos_3$ID <- do.call(paste, c(CD42pos_3[c("V1", "ID")], sep = ":"))
## Reducing the data frame to ID + counts ##
CD42neg_1 <- data.frame("ID"=CD42neg_1$ID, "CD42neg_1"=CD42neg_1$V13)
CD42neg_2 <- data.frame("ID"=CD42neg_2$ID, "CD42neg_2"=CD42neg_2$V13)
CD42neg_3 <- data.frame("ID"=CD42neg_3$ID, "CD42neg_3"=CD42neg_3$V13)
CD42pos_1 <- data.frame("ID"=CD42pos_1$ID, "CD42pos_1"=CD42pos_1$V13)
CD42pos_2 <- data.frame("ID"=CD42pos_2$ID, "CD42pos_2"=CD42pos_2$V13)
CD42pos_3 <- data.frame("ID"=CD42pos_3$ID, "CD42pos_3"=CD42pos_3$V13)
## merging things togehter ##
CE_MK <- NULL
CE_MK <- merge(CD42neg_1, CD42neg_2, by= "ID", all.x= T, all.y= T)
CE_MK <- merge(CE_MK, CD42neg_3, by= "ID", all.x= T, all.y= T)
CE_MK <- merge(CE_MK, CD42pos_1, by= "ID", all.x= T, all.y= T)
CE_MK <- merge(CE_MK, CD42pos_2, by= "ID", all.x= T, all.y= T)
CE_MK <- merge(CE_MK, CD42pos_3, by= "ID", all.x= T, all.y= T)
dim(CE_MK)
```
# Creating annotation file
```{r annotation file}
## creating an annotation file ##
{
CD42neg_1 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C1MK42negcirc_Annotation.txt',header=F)
CD42neg_2 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C2MK42negcirc_Annotation.txt',header=F)
CD42neg_3 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C3MK42negcirc_Annotation.txt',header=F)
CD42pos_1 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C1MK42poscirc_Annotation.txt',header=F)
CD42pos_2 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C2MK42poscirc_Annotation.txt',header=F)
CD42pos_3 <- read.delim('/home/ben/Analysis/circRNA_erys/circMK/circRNA_CE2/C3MK42poscirc_Annotation.txt',header=F)
}
## combining all annotation together ##
CE_MK_annotation_file <- rbind(CD42neg_1,CD42neg_2,CD42neg_3,
CD42pos_1,CD42pos_2,CD42pos_3)
dim(CE_MK_annotation_file)
## Making an ID column ##
CE_MK_annotation_file$ID <- do.call(paste, c(CE_MK_annotation_file[c("V2", "V3")], sep = "-"))
CE_MK_annotation_file$ID <- do.call(paste, c(CE_MK_annotation_file[c("V1", "ID")], sep = ":"))
## Naming columns ##
colnames(CE_MK_annotation_file) <- c("chrom" ,"start", "end", "name", "score", "strand" ,"thickStart", "thickEnd" ,"itemRgb", "exonCount", "exonSizes", "exonOffsets", "readNumber", "circType", "geneName" ,"isoformName" ,"index" ,"flankIntron", "ID")
CE_MK_annotation_file$name <- NULL
CE_MK_annotation_file$readNumber <- NULL
## making sure we have only unique annotations ##
CE_MK_annotation_file <- unique(CE_MK_annotation_file)
#head(CE_MK_annotation_file)
dim(CE_MK_annotation_file)
```
# CE filtering
```{r CE filtering}
## Here we filter for circRNAs using CE counts ##
## Low confidence (LC) circRNA first ##
CE_MK[is.na(CE_MK)]=0
CE_MK_LC <- NULL
CE_MK_LC <- subset(CE_MK, (as.numeric(CE_MK$CD42neg_1)>=2|as.numeric(CE_MK$CD42neg_2)>=2|as.numeric(CE_MK$CD42neg_3)>=2|
(as.numeric(CE_MK$CD42pos_1)>=2|as.numeric(CE_MK$CD42pos_2)>=2|as.numeric(CE_MK$CD42pos_3)>=2)))
dim(CE_MK_LC) # 12879 circRNA
CE_MK_LC[is.na(CE_MK_LC)]=0
## High confidence (HC) circRNAs ##
CE_MK_HC <- NULL
CE_MK_HC <- base::subset(CE_MK, (CE_MK$CD42neg_1>=2 & CE_MK$CD42neg_2>=2 & CE_MK$CD42neg_3>=2)|
(CE_MK$CD42pos_1>=2 & CE_MK$CD42pos_2>=2 & CE_MK$CD42pos_3>=2))
dim(CE_MK_HC) # 2539
```
# Combining DCC and CE counts
```{r Combining DCC and CE counts}
## Filtering Low confidence co-detected circRNA by DCC and CE ##
DCC_MK_LC$Co_detected[DCC_MK_LC$ID %in% CE_MK_LC$ID] <- "yes"
DCC_CE_MK_LC <- subset(DCC_MK_LC,DCC_MK_LC$Co_detected=="yes")
dim(DCC_CE_MK_LC) # 12809 circRNA are co-detected by CE and DCC with high confidence
## Filtering High confidence co-detected circRNA by DCC and CE ##
DCC_MK_hc$Co_detected [DCC_MK_hc$ID %in% CE_MK_HC$ID] <- "yes"
DCC_CE_MK_HC <- subset(DCC_MK_hc,DCC_MK_hc$Co_detected=="yes")
dim(DCC_CE_MK_HC) # 2531 circRNA are co-detected by CE and DCC with high confidence
```
# CircRNA annotation
```{r CircRNA annotation}
## Merging annotation with LC count tables ##
DCC_CE_MK_LC_annotated <- merge(DCC_CE_MK_LC, CE_MK_annotation_file, by="ID",all.x = T)
DCC_CE_MK_LC_annotated <- data.frame(DCC_CE_MK_LC_annotated)
dim(DCC_CE_MK_LC_annotated)
## Removing useless columns ##
{
DCC_CE_MK_LC_annotated$itemRgb <- NULL
DCC_CE_MK_LC_annotated$Co_detected <- NULL
DCC_CE_MK_LC_annotated$NA. <- NULL
DCC_CE_MK_LC_annotated$readNumber <- NULL
DCC_CE_MK_LC_annotated$score <- NULL
}
DCC_CE_MK_LC_annotated <- DCC_CE_MK_LC_annotated[!duplicated(DCC_CE_MK_LC_annotated$ID),]
write.table(DCC_CE_MK_LC_annotated,"DCC_CE_MK_LC_annotated.csv",sep=";",dec=",",row.names = F)
## ______________________________________________________________________________ ##
# Same with HC circRNA #
## Merging annotation with HC count tables ##
DCC_CE_MK_HC_annotated <- merge(DCC_CE_MK_HC, CE_MK_annotation_file, by="ID",all.x = T)
DCC_CE_MK_HC_annotated <- data.frame(DCC_CE_MK_HC_annotated)
dim(DCC_CE_MK_HC_annotated)
## Removing useless columns ##
{
DCC_CE_MK_HC_annotated$Co_detected <- NULL
DCC_CE_MK_HC_annotated$NA. <- NULL
DCC_CE_MK_HC_annotated$readNumber <- NULL
}
write.table(DCC_CE_MK_HC_annotated,"DCC_CE_MK_HC_annotated.csv",sep=";",dec=",",row.names = F)
## Here I make a BED file ##
## The BED file is needing to get the circRNA sequence in downstream analysis ##
DCC_CE_MK_HC_annotated_BED <- DCC_CE_MK_HC_annotated
{
DCC_CE_MK_HC_annotated_BED$CD42neg_1 <- NULL
DCC_CE_MK_HC_annotated_BED$CD42neg_2 <- NULL
DCC_CE_MK_HC_annotated_BED$CD42neg_3 <- NULL
DCC_CE_MK_HC_annotated_BED$CD42pos_1 <- NULL
DCC_CE_MK_HC_annotated_BED$CD42pos_2 <- NULL
DCC_CE_MK_HC_annotated_BED$CD42pos_3 <- NULL
DCC_CE_MK_HC_annotated_BED$circType <- NULL
DCC_CE_MK_HC_annotated_BED$geneName <- NULL
DCC_CE_MK_HC_annotated_BED$isoformName <- NULL
DCC_CE_MK_HC_annotated_BED$index <- NULL
DCC_CE_MK_HC_annotated_BED$flankIntron <- NULL
DCC_CE_MK_HC_annotated_BED$score <- 950
}
DCC_CE_MK_HC_annotated_BED <- DCC_CE_MK_HC_annotated_BED[c(2:4,1,5:12)] ## Putting the name at its right place for BED export!
write.table(DCC_CE_MK_HC_annotated_BED,"DCC_CE_MK_HC_BED.bed",sep="\t",dec=".",row.names = F,col.names = F,quote = F)
```
## CircRNA counts per pop and gene-circRNA
```{r circRNA counts per pop and gene circRNA}
## how many LC circRNA are expressed in : ##
## CD42- MK ##
dim(subset(DCC_CE_MK_LC_annotated,
DCC_CE_MK_LC_annotated$CD42neg_1>=2 |
DCC_CE_MK_LC_annotated$CD42neg_2>=2 |
DCC_CE_MK_LC_annotated$CD42neg_3>=2)) # 7972
## CD42+ MK ##
dim(subset(DCC_CE_MK_LC_annotated,
DCC_CE_MK_LC_annotated$CD42pos_1>=2 |
DCC_CE_MK_LC_annotated$CD42pos_2>=2 |
DCC_CE_MK_LC_annotated$CD42pos_3>=2)) # 11070
## how many genes express LC circRNA in : ##
## CD42- MK ##
neg <- subset(DCC_CE_MK_LC_annotated,
DCC_CE_MK_LC_annotated$CD42neg_1>=2 |
DCC_CE_MK_LC_annotated$CD42neg_2>=2 |
DCC_CE_MK_LC_annotated$CD42neg_3>=2) ##
dim(distinct(neg,geneName)) # 3341
## CD42+ MK ##
pos <- subset(DCC_CE_MK_LC_annotated,
DCC_CE_MK_LC_annotated$CD42pos_1>=2 |
DCC_CE_MK_LC_annotated$CD42pos_2>=2 |
DCC_CE_MK_LC_annotated$CD42pos_3>=2)
dim(distinct(pos,geneName)) ## 3842
```
# CircRNA Specs
# Exon count per circRNA
## Low confidence circRNA
```{r LC circ exon usage}
## LC ##
mean(DCC_CE_MK_LC_annotated$exonCount,na.rm=T) # 4.564993 exon per circRNA on average
median(DCC_CE_MK_LC_annotated$exonCount,na.rm = T) # 4 median exon per circRNA on average
ggplot(DCC_CE_MK_LC_annotated, aes(exonCount))+
geom_histogram(binwidth = 1,fill="#20639B")+
scale_y_continuous(limits = c(0,3000), expand = c(0,0))+
scale_x_continuous(limits = c(0,50), expand = c(0,0))+
geom_vline(xintercept = 4.564993,color="red")+
ggtitle("Low confidence circRNA exon count")+
theme_classic()
```
## High confidence circRNA
```{r HC circ exon usage}
# HC #
mean(DCC_CE_MK_HC_annotated$exonCount,na.rm=T) # 3.937994 exon per circRNA on average
median(DCC_CE_MK_HC_annotated$exonCount, na.rm = T) # 3 median exon per circRNA on average
ggplot(DCC_CE_MK_HC_annotated, aes(exonCount))+
geom_histogram(binwidth = 1,fill="#20639B")+
scale_y_continuous(limits = c(0,750), expand = c(0,0))+
scale_x_continuous(limits = c(0,50), expand = c(0,0))+
geom_vline(xintercept = 3.937994,color="red")+
ggtitle("High confidence circRNA exon count")+
theme_classic()
```
# Putative circRNA size
## Low confidence circRNA
```{r Putative circRNA size}
# LC #
DCC_CE_MK_LC_annotated$spliced_length <- mapply(strsplit(as.character(DCC_CE_MK_LC_annotated$exonSizes),","),FUN=function(x){sum(as.numeric(x))})
#head(DCC_CE_MK_LC_annotated)
mean(DCC_CE_MK_LC_annotated$spliced_length,na.rm = T) # 663.871 nt on average
median(DCC_CE_MK_LC_annotated$spliced_length,na.rm = T) # 484 nt median
ggplot(DCC_CE_MK_LC_annotated, aes(log10(spliced_length)))+
geom_histogram(binwidth = 0.05,fill="#20639B")+
scale_y_continuous(limits = c(0,1000), expand = c(0,0))+
scale_x_continuous(limits = c(1,5), expand = c(0,0))+
ggtitle("Low confidence circRNA spliced length")+
geom_vline(xintercept = log10(663.871),color="red")+
theme_classic()
```
* High confidence circRNA
```{r HC circRNA putative length}
# HC #
DCC_CE_MK_HC_annotated$spliced_length <- mapply(strsplit(as.character(DCC_CE_MK_HC_annotated$exonSizes),","),FUN=function(x){sum(as.numeric(x))})
#head(DCC_CE_MK_HC_annotated)
mean(DCC_CE_MK_HC_annotated$spliced_length) # 592.0774 nt per circRNA on average
median(DCC_CE_MK_HC_annotated$spliced_length) # 443 nt median exon per circRNA
ggplot(DCC_CE_MK_HC_annotated, aes(log10(spliced_length)))+
geom_histogram(binwidth = 0.05,fill="#20639B")+
scale_y_continuous(limits = c(0,250), expand = c(0,0))+
scale_x_continuous(limits = c(1,5), expand = c(0,0))+
ggtitle("High confidence circRNA spliced length")+
geom_vline(xintercept = log10(592.0774),color="red")+
theme_classic()
```
# Start exon usage
* Low confidence circRNA
```{r LC circRNA start exon usage}
# LC #
DCC_CE_MK_LC_annotated$first_exon <- mapply(strsplit(as.character(DCC_CE_MK_LC_annotated$index),","),FUN=function(x){min(sort(as.numeric(x)))})
ggplot(DCC_CE_MK_LC_annotated, aes(first_exon))+
geom_histogram(binwidth = 1, fill="#c69452")+
scale_x_continuous(limits = c(0.5,5.5), expand = c(0,0))+
scale_y_continuous(limits=c(0,5000), expand = c(0,0))+
ggtitle("Start exon usage in LC circRNA")+
theme_classic()
dim(DCC_CE_MK_LC)
dim(subset(DCC_CE_MK_LC_annotated,DCC_CE_MK_LC_annotated$first_exon==2)) # 3742 (29.21383%) LC circRNA are starting at exon 2
(3742/12809)*100
dim(subset(DCC_CE_MK_LC_annotated,DCC_CE_MK_LC_annotated$first_exon==1)) # 32 circRNA at exon 1
```
* High confidence circRNA
```{r HC circRNA start exon usage}
# HC #
DCC_CE_MK_HC_annotated$first_exon <- mapply(strsplit(as.character(DCC_CE_MK_HC_annotated$index),","),FUN=function(x){min(sort(as.numeric(x)))})
ggplot(DCC_CE_MK_HC_annotated, aes(first_exon))+
geom_histogram(binwidth = 1, fill="#c69452")+
scale_x_continuous(limits = c(0.5,5.5), expand = c(0,0))+
scale_y_continuous(limits=c(0,1500), expand = c(0,0))+
ggtitle("Start exon usage in HC circRNA")+
theme_classic()
dim(DCC_CE_MK_HC)
dim(subset(DCC_CE_MK_HC_annotated,DCC_CE_MK_HC_annotated$first_exon==2)) # 942 (37.21849%) LC circRNA are starting at exon 2
(942/2531)*100
dim(subset(DCC_CE_MK_HC_annotated,DCC_CE_MK_HC_annotated$first_exon==1)) # 5 circRNA at exon 1
```
# End exon usage
* First, low confidence circRNA
```{r End exon usage}
# We need to import the GTF file to get linear RNA informations #
hg_19_ref_linear <- read.delim("/home/ben/Analysis/circRNA_erys/circMK/hg19_ref_all.txt", header = F, sep = "")
colnames(hg_19_ref_linear) <- c("Gene_name","isoformName","Chrom","Strand","Start","End","Thick_start","Thick_end","exon_number","exon_position","exon_position_2")
hg_19_ref_linear$exon_position_2 <- NULL
hg_19_ref_linear$exon_position <- NULL
#head(hg_19_ref_linear)
## for LC ##
DCC_CE_MK_LC_annotated$last_exon <- mapply(strsplit(as.character(DCC_CE_MK_LC_annotated$index),","),FUN=function(x){max(sort(as.numeric(x)))}) # Getting the last exon used by the circRNA
last_exon_calc_LC <- data.frame(DCC_CE_MK_LC_annotated$ID,DCC_CE_MK_LC_annotated$geneName,DCC_CE_MK_LC_annotated$isoformName,DCC_CE_MK_LC_annotated$index,DCC_CE_MK_LC_annotated$first_exon,DCC_CE_MK_LC_annotated$last_exon,DCC_CE_MK_LC_annotated$exonCount) # Making a simplified data frame
colnames(last_exon_calc_LC) <-c("ID","geneName","isoformName","index","first_exon","last_exon","exonCount")
#head(last_exon_calc_LC)
last_exon_calc_LC <- merge(hg_19_ref_linear,last_exon_calc_LC,by = "isoformName",all.y = T) # Merging info on mRNA exons and circRNA exon usage for comparison
#head(last_exon_calc_LC)
last_exon_calc_LC$from_last_exon <- (((last_exon_calc_LC$last_exon)-(last_exon_calc_LC$exon_number))) ## getting the position of the last exon used in circRNA in relation to the mRNA exons.
last_exon_calc_LC <- subset(last_exon_calc_LC, last_exon_calc_LC$from_last_exon<=0)
#head(last_exon_calc_LC)
ggplot(last_exon_calc_LC,aes(x=from_last_exon))+
geom_histogram(binwidth = 1, fill="#8a4900",breaks=seq(-200, 0, by =1))+
scale_y_continuous(expand = c(0,0), limits = c(0,5000))+
scale_x_continuous(expand = c(0,0), limits = c(-6,0))+
theme_classic()
dim(subset(last_exon_calc_LC,last_exon_calc_LC$from_last_exon==-1)) # 1814 (14.16192 %) LC circRNA use the second to last exon
(1814/12809)*100 # 14.16192
dim(subset(last_exon_calc_LC,last_exon_calc_LC$from_last_exon==0)) # 20 LC circRNA use the last exon, most likely mis-annotation of last exon?
```
* High confidence circRNA
```{r HC circRNA last exon usage}
# Same than above but for HC #
DCC_CE_MK_HC_annotated$last_exon <- mapply(strsplit(as.character(DCC_CE_MK_HC_annotated$index),","),FUN=function(x){max(sort(as.numeric(x)))})
last_exon_calc_HC <- data.frame(DCC_CE_MK_HC_annotated$ID,DCC_CE_MK_HC_annotated$geneName,DCC_CE_MK_HC_annotated$isoformName,DCC_CE_MK_HC_annotated$index,DCC_CE_MK_HC_annotated$first_exon,DCC_CE_MK_HC_annotated$last_exon,DCC_CE_MK_HC_annotated$exonCount)
colnames(last_exon_calc_HC) <-c("ID","geneName","isoformName","index","first_exon","last_exon","exonCount")
#head(last_exon_calc_HC)
last_exon_calc_HC <- merge(hg_19_ref_linear,last_exon_calc_HC,by = "isoformName",all.y = T)
#head(last_exon_calc_HC)
last_exon_calc_HC$from_last_exon <- (((last_exon_calc_HC$last_exon)-(last_exon_calc_HC$exon_number)))
last_exon_calc_HC <- subset(last_exon_calc_HC, last_exon_calc_HC$from_last_exon<=0)
#head(last_exon_calc_HC)
ggplot(last_exon_calc_HC,aes(x=from_last_exon))+
geom_histogram(binwidth = 1, fill="#8a4900",breaks=seq(-200, 0, by =1))+
scale_y_continuous(expand = c(0,0), limits = c(0,550))+
scale_x_continuous(expand = c(0,0), limits = c(-6,0))+
theme_classic()
dim(subset(last_exon_calc_HC,last_exon_calc_HC$from_last_exon==-1)) # 352 (13.90755 %) HC circRNA
(352/2531)*100
dim(subset(last_exon_calc_HC,last_exon_calc_HC$from_last_exon==0)) # 2 HC circRNA
```
# Chromosomal distribution of circRNA
* First, low confidence circRNA
```{r LC circRNA genome position}
## Lets have a look at the circRNA distribution on the genome ##
# LC #
last_exon_calc_LC$Chr_number <- last_exon_calc_LC$Chrom
last_exon_calc_LC$Chr_number <- gsub("chr","",last_exon_calc_LC$Chr_number)
last_exon_calc_LC$Chr_number <- gsub("X","22",last_exon_calc_LC$Chr_number)
last_exon_calc_LC$Chr_number <- gsub("Y","23",last_exon_calc_LC$Chr_number)
ggplot(last_exon_calc_LC,aes(x=Chr_number))+
geom_bar()+
theme_classic()+
theme(axis.text.x = element_text(angle = 45, hjust = 1))+
scale_y_continuous(expand = c(0,0), limits = c(0,1500))+
scale_x_discrete(expand = c(0,0), limits = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23))
```
* High confidence circRNA
```{r HC circRNA genome position}
# HC #
last_exon_calc_HC$Chr_number <- last_exon_calc_HC$Chrom
last_exon_calc_HC$Chr_number <- gsub("chr","",last_exon_calc_HC$Chr_number)
last_exon_calc_HC$Chr_number <- gsub("X","22",last_exon_calc_HC$Chr_number)
last_exon_calc_HC$Chr_number <- gsub("Y","23",last_exon_calc_HC$Chr_number)
ggplot(last_exon_calc_HC,aes(x=Chr_number))+
geom_bar()+
theme_classic()+
theme(axis.text.x = element_text(angle = 45, hjust = 1))+
scale_y_continuous(expand = c(0,0), limits = c(0,250))+
scale_x_discrete(expand = c(0,0), limits = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23))
```
# Relation position versus length of circRNA
* First, low confidence circRNA
```{r Relation position versus length of circRNA}
## Is there a relation bewteen circRNA length and first exon used? ##
# LC #
ggplot(DCC_CE_MK_LC_annotated, aes(x=first_exon,y=log10(spliced_length)))+
geom_boxplot(aes(group=first_exon))+
scale_x_continuous(limits = c(0.5,10.5))+
scale_y_continuous(limits = c(1,4))+
theme_classic()
```
* High confidence circRNA
```{r Length vs first exon in HC circRNA}
# HC #
ggplot(DCC_CE_MK_HC_annotated, aes(x=first_exon,y=log10(spliced_length)))+
geom_boxplot(aes(group=first_exon))+
scale_x_continuous(limits = c(0.5,10.5))+
scale_y_continuous(limits = c(1,4))+
theme_classic()
```
# Sequencing depth correction
## For low confidence circRNA
```{r library depth correction LC circRNA}
## Here we correct for the library size (mapped reads based on genome mapping, unique + multimapped)
v <- as.vector(c(73893274,106969774,69632408,52413968,74197986,70753502))
# LC #
DCC_CE_MK_LC_c <- DCC_CE_MK_LC[,2:7]
DCC_CE_MK_LC_c <- data.frame(mapply('/',DCC_CE_MK_LC_c,v))
DCC_CE_MK_LC_c <- data.frame(mapply('*',DCC_CE_MK_LC_c,1000000))
DCC_CE_MK_LC_c <- cbind.data.frame(DCC_CE_MK_LC$ID, DCC_CE_MK_LC_c)
dim(DCC_CE_MK_LC_c)
DCC_CE_MK_LC_c[is.na(DCC_CE_MK_LC_c)]=0
colnames(DCC_CE_MK_LC_c) <- c("ID","CD42neg_1","CD42neg_2","CD42neg_3","CD42pos_1","CD42pos_2","CD42pos_3")
```
## For High confidence circRNA
```{r library depth correction HC circRNA}
# HC #
DCC_CE_MK_HC_c <- DCC_CE_MK_HC[,2:7]
DCC_CE_MK_HC_c <- data.frame(mapply('/',DCC_CE_MK_HC_c,v))
DCC_CE_MK_HC_c <- data.frame(mapply('*',DCC_CE_MK_HC_c,1000000))
DCC_CE_MK_HC_c <- cbind.data.frame(DCC_CE_MK_HC$ID, DCC_CE_MK_HC_c)
#head(DCC_CE_MK_HC_c)
dim(DCC_CE_MK_HC_c)
DCC_CE_MK_HC_c[is.na(DCC_CE_MK_HC_c)]=0
colnames(DCC_CE_MK_HC_c) <- c("ID","CD42neg_1","CD42neg_2","CD42neg_3","CD42pos_1","CD42pos_2","CD42pos_3")
DCC_CE_MK_HC_c <- merge(DCC_CE_MK_HC_c,CE_MK_annotation_file,by="ID")
write.table(DCC_CE_MK_HC_c,"DCC_CE_MK_HC_corrected_depth.csv",sep = ";",row.names = F,dec = ",")
```
```{r same for lin counts}
DCC_MK_lin_c <- DCC_MK_lin
DCC_MK_lin_c
v <- as.vector(c(73893274,106969774,69632408,52413968,74197986,70753502))
# LC #
DCC_MK_lin_c <- DCC_MK_lin_c[,2:7]
DCC_MK_lin_c <- data.frame(mapply('/',DCC_MK_lin_c,v))
DCC_MK_lin_c <- data.frame(mapply('*',DCC_MK_lin_c,1000000))
DCC_MK_lin_c <- cbind.data.frame(DCC_MK_lin$ID, DCC_MK_lin_c)
colnames(DCC_MK_lin_c)[1] <- "ID"
```
## Importing platelet data ##
```{r importing platetlets data}
## Importing platelets data from Nicolet et al. 2018 ##
## LC circRNA ##
LC_plt <- read.delim("./PLT_LC_file.csv",sep=";",dec=",")
LC_plt[5:12] <- NULL
LC_plt <- subset(LC_plt,LC_plt$Plt1>=2 |
LC_plt$Plt2>=2 |
LC_plt$Plt3>=2)
dim(LC_plt) # 47654 circRNa in PLT with LC cut off
## Here we correct for the sequencing depth in platlets ##
LC_plt_c <- LC_plt
LC_plt_c$Plt1 <- (LC_plt_c$Plt1/40902006)*1000000
LC_plt_c$Plt2 <- (LC_plt_c$Plt2/37380346)*1000000
LC_plt_c$Plt3 <- (LC_plt_c$Plt3/43617620)*1000000
dim(distinct(LC_plt,geneName)) # 6516 genes with circRNA in plt
## HC circRNA ##
HC_plt <- read.delim("./PLT_specific_HC_co-detected.csv",sep=";",dec=",")
head(HC_plt)
dim(HC_plt)
HC_plt <- HC_plt[1:4]
HC_plt_ID <- HC_plt$ID
HC_plt <- data.frame(mapply('/',HC_plt[2:4],2)) ## CE2 bugged on these samples and counted 2x the reads. I couldnt correct for this in CE2, so I do here
HC_plt$ID <- HC_plt_ID
## Lib depth correction for HC circRNA #
HC_plt_c <- HC_plt
HC_plt_c$Plt1 <- (HC_plt_c$Plt1/40902006)*1000000
HC_plt_c$plt2 <- (HC_plt_c$plt2/37380346)*1000000
HC_plt_c$plt3 <- (HC_plt_c$plt3/43617620)*1000000
```
## Correlation of MK and PLT with LC circRNA
```{r Corrlation of MK and PLT with LC circRNA}
## for LC circRNA ##
DCC_CE_MK_PLT_LC_c <- merge(DCC_CE_MK_LC_c,LC_plt_c,by="ID",all=T)
DCC_CE_MK_PLT_LC_c <- DCC_CE_MK_PLT_LC_c[1:10]
DCC_CE_MK_PLT_LC_c[is.na(DCC_CE_MK_PLT_LC_c)]=0
col_fun = colorRamp2(c(-3, -1.5, 0, 1.5, 3), c("#053061","#579EC9","#FFFFFF","#D96651","#67001F")) ## Making a custom color palette
corrplot::corrplot(corr = (cor(DCC_CE_MK_PLT_LC_c[2:10])),method = "shade",diag = T,type = "full",
col = col_fun(seq(-8,3,by=0.01)),hclust.method = "complete",order = "original",cl.lim=c(0,1))
```
## Correlation of MK and PLT with HC circRNA
```{r Correlation of MK and PLT with HC circRNA}
## in HC circRNA ##
DCC_CE_MK_PLT_HC_c <- merge(DCC_CE_MK_HC_c,HC_plt_c,by="ID",all=T)
DCC_CE_MK_PLT_HC_c$Co_detected <- NULL
DCC_CE_MK_PLT_HC_c <- cbind(DCC_CE_MK_PLT_HC_c[1:7],DCC_CE_MK_PLT_HC_c[24:26])
DCC_CE_MK_PLT_HC_c[is.na(DCC_CE_MK_PLT_HC_c)]=0
col_fun = colorRamp2(c(-3, -1.5, 0, 1.5, 3), c("#053061","#579EC9","#FFFFFF","#D96651","#67001F"))
#col_fun(seq(-2,2,by=0.01))
pheatmap(DCC_CE_MK_PLT_HC_c[2:10], col_fun(seq(-5,5,by=0.01)) ,scale = "row",
clustering_distance_cols = "canberra", cluster_cols = F, cluster_rows = T,
border_color = NA, labels_col=colnames(DCC_CE_MK_PLT_HC_c[2:10]),fontsize_row=0.1,
clustering_distance_rows = "manhattan")
col_fun= colorRamp2(c(-3, -1.5, 0, 1.5, 3), c("#053061","#579EC9","#FFFFFF","#D96651","#67001F"))
corrplot::corrplot(corr = (cor(DCC_CE_MK_PLT_HC_c[,2:10])),method = "shade",diag = T,type = "full",
col =col_fun(seq(-7,3,by=0.01)),order = "original",cl.lim=c(0,1) )+ theme(aspect.ratio = 1)
```
```{r k_means heatmap}
## Lets now see how MK and platelets express HC circRNA ##
## For clarity in the figure, I use a k-means approach (k is determined manually) ##
set.seed(1234) # Due to random number generation, we set a seed.
k_means_MK_PLT <- pheatmap(DCC_CE_MK_PLT_HC_c[2:10], col_fun(seq(-5,5,by=0.01)) ,scale = "row",
cluster_cols = F, cluster_rows = F,
border_color = NA, labels_col=colnames(DCC_CE_MK_PLT_HC_c[2:10]),fontsize_row=5,
kmeans_k = 5,clustering_method = "manhattan")
DCC_CE_MK_PLT_HC_c_kmeans <- DCC_CE_MK_PLT_HC_c
DCC_CE_MK_PLT_HC_c_kmeans <- cbind(DCC_CE_MK_PLT_HC_c_kmeans, "kmeans"=k_means_MK_PLT$kmeans$cluster) # Getting stuff together ##
DCC_CE_MK_PLT_HC_c_kmeans <- DCC_CE_MK_PLT_HC_c_kmeans[order(DCC_CE_MK_PLT_HC_c_kmeans$kmeans,decreasing = F ),] # Ordering circRNA by cluster number
pheatmap(DCC_CE_MK_PLT_HC_c_kmeans[2:10], col_fun(seq(-5,5,by=0.01)) ,scale = "row",
clustering_distance_cols = "canberra", cluster_cols = F, cluster_rows = F,
border_color = NA, labels_col=colnames(DCC_CE_MK_PLT_HC_c_kmeans[2:10]),fontsize_row=0.1,
clustering_distance_rows = "manhattan", gaps_col = 6)
## Saving stuff ##
#DCC_CE_MK_HC_c_kmeans <- merge(DCC_CE_MK_PLT_HC_c_kmeans,CE_MK_annotation_file, by="ID",all.x=T)
#write.table(DCC_CE_MK_HC_c_kmeans,"DCC_CE_MK_PLT_HC_c_withkmeans_n=5.csv",sep=";",dec=",",row.names = FALSE)
```
# PCA
* PCA low confidence
```{r PCA using LC circRNA}
DCC_CE_MK_LC_c_PCA <- DCC_CE_MK_LC_c[2:7] #Selecting count columns for PCA
{
gp <- c("CD42neg","CD42neg","CD42neg","CD42pos","CD42pos","CD42pos") # Making groups for PCA visualization
dim(gp)
PCA_data <- cbind.data.frame(t(DCC_CE_MK_LC_c_PCA[1:6]),gp)
head(PCA_data)
dim(PCA_data)
PCA_data[is.na(PCA_data)]= 0
PCA <- prcomp(PCA_data[2:6753])
plot(PCA)
}
### PCA on shared circRNA ###
autoplot(prcomp(PCA_data[2:6753]), data = PCA_data, colour='gp', size = 2,variance_percentage = T)+
theme_classic()
```
* PCA high confidence
```{r PCA using HC circRNA}
## Same for HC circRNA #
DCC_CE_MK_HC_c_PCA <- DCC_CE_MK_HC_annotated[2:7]
{
gp <- c("CD42neg","CD42neg","CD42neg","CD42pos","CD42pos","CD42pos")
dim(gp)
PCA_data <- cbind.data.frame(t(DCC_CE_MK_HC_c_PCA[1:6]),gp)
head(PCA_data)
dim(PCA_data)
PCA_data[is.na(PCA_data)]= 0
PCA <- prcomp(PCA_data[2:748])
plot(PCA)
}
### PCA on shared circRNA ###
autoplot(prcomp(PCA_data[2:748],scale. = F),data=PCA_data, size = 2, colour="gp",variance_percentage = T)+
theme_classic()
```
# Calculation of CLR (only on high confidence)
```{r CLR 42neg}
## Here we compute the circular-over-linear ratio (CLR) ##
DCC_CE_lin_circ_mk_HC <- merge(DCC_CE_MK_HC,DCC_MK_lin,by="ID") # Merging lin + circ RNA counts
DCC_CE_lin_circ_mk_HC <- distinct(DCC_CE_lin_circ_mk_HC,.keep_all = T) # making sure we didnt make double when merging
dim(DCC_CE_lin_circ_mk_HC)
### CD42- MK ###
{
CD42neg<- NULL # creating dataframe
CD42neg$ID <- (DCC_CE_lin_circ_mk_HC$ID)
CD42neg <- data.frame(CD42neg)
dim(CD42neg)
CD42neg$ratio1 <- (((DCC_CE_lin_circ_mk_HC$CD42neg_1)/(DCC_CE_lin_circ_mk_HC$CD42neg_1_lin))) # Making ratios per sample
CD42neg$ratio2 <- (((DCC_CE_lin_circ_mk_HC$CD42neg_2)/(DCC_CE_lin_circ_mk_HC$CD42neg_2_lin)))
CD42neg$ratio3 <- (((DCC_CE_lin_circ_mk_HC$CD42neg_3)/(DCC_CE_lin_circ_mk_HC$CD42neg_3_lin)))
CD42neg$ratio <- (((CD42neg$ratio1)+(CD42neg$ratio2)+(CD42neg$ratio3))/3) # average ratios
CD42neg$Lin<- (((DCC_CE_lin_circ_mk_HC$CD42neg_1_lin)+(DCC_CE_lin_circ_mk_HC$CD42neg_2_lin)+(DCC_CE_lin_circ_mk_HC$CD42neg_3_lin))/3) # average linear expression
CD42neg$circ<- (((DCC_CE_lin_circ_mk_HC$CD42neg_1)+(DCC_CE_lin_circ_mk_HC$CD42neg_2)+(DCC_CE_lin_circ_mk_HC$CD42neg_3))/3 ) # Average circRNA expression
head(CD42neg)
CD42neg[is.na(CD42neg)] = 0
CD42neg <- subset(CD42neg, ratio>0)
CD42neg <- merge(CD42neg,CE_MK_annotation_file, by="ID",all.x=T) # Merging with annotation file
CD42neg <- merge(CD42neg, DCC_CE_MK_HC_c, by="ID", all.x=T) # Using lib depth corrected data for expression
CD42neg$circRPM <- rowMeans(CD42neg[26:28]) # Average in populaiton
}
ggplot(CD42neg, aes(x=log10(circRPM), y=ratio))+
geom_point()+
geom_point(data=CD42neg[CD42neg$ratio>0.5,],color="grey")+
geom_point(data= CD42neg[CD42neg$ratio>1,],color="blue")+
theme_classic()+
geom_text(data=CD42neg[CD42neg$ratio >= 1,], aes(label = geneName.x), size = 3 ,nudge_y = 0.05, nudge_x = 0.15)+
labs(y="[ circular / linear ]", x= "log10 [circ RPM ]")+
theme(panel.border = element_rect(fill = NA))+
geom_hline(yintercept = 1, linetype="dotted")+
#geom_vline(xintercept = 0, linetype="dotted")+
scale_y_continuous(limits = c(0,3), expand = c(0,0))+
scale_x_continuous(limits = c(-2,2), expand = c(0,0))+
theme(aspect.ratio = 1)
CD42neg <- do.call(data.frame,lapply(CD42neg, function(x) replace(x, is.infinite(x),NA)))
mean(CD42neg$ratio,na.rm = T) # 0.05440738
```
```{r CLR 42pos}
## Same for CD42+ MK ##
{
CD42pos<- NULL
CD42pos$ID <- (DCC_CE_lin_circ_mk_HC$ID)
CD42pos$ratio1 <- (((DCC_CE_lin_circ_mk_HC$CD42pos_1)/(DCC_CE_lin_circ_mk_HC$CD42pos_1_lin)))
CD42pos$ratio2 <- (((DCC_CE_lin_circ_mk_HC$CD42pos_2)/(DCC_CE_lin_circ_mk_HC$CD42pos_2_lin)))
CD42pos$ratio3 <- (((DCC_CE_lin_circ_mk_HC$CD42pos_3)/(DCC_CE_lin_circ_mk_HC$CD42pos_3_lin)))
CD42pos$ratio <- (((CD42pos$ratio1)+(CD42pos$ratio2)+(CD42pos$ratio3))/3)
CD42pos$Lin<- (((DCC_CE_lin_circ_mk_HC$CD42pos_1_lin)+(DCC_CE_lin_circ_mk_HC$CD42pos_2_lin)+(DCC_CE_lin_circ_mk_HC$CD42pos_3_lin))/3)
CD42pos$circ<- (((DCC_CE_lin_circ_mk_HC$CD42pos_1)+(DCC_CE_lin_circ_mk_HC$CD42pos_2)+(DCC_CE_lin_circ_mk_HC$CD42pos_3))/3 )
CD42pos <- data.frame(CD42pos)
head(CD42pos)
CD42pos[is.na(CD42pos)] = 0
CD42pos <- subset(CD42pos, ratio>0)
CD42pos <- merge(CD42pos,CE_MK_annotation_file, by="ID",all.x=T)
CD42pos <- merge(CD42pos, DCC_CE_MK_HC_c, by="ID", all.x=T)
CD42pos$circRPM <- rowMeans(CD42pos[27:29])
}
ggplot(CD42pos, aes(x=log10(circRPM), y=ratio))+
geom_point()+
geom_point(data=CD42pos[CD42pos$ratio>0.5,],color="grey")+
geom_point(data= CD42pos[CD42pos$ratio>1,],color="blue")+
theme_classic()+
geom_text(data=CD42pos[CD42pos$ratio >= 1,], aes(label = geneName.x), size = 3 ,nudge_y = 0.05, nudge_x = 0.15)+
labs(y="[ circular / linear ]", x= "log10 [circ RPM ]")+
theme(panel.border = element_rect(fill = NA))+
geom_hline(yintercept = 1, linetype="dotted")+
scale_y_continuous(limits = c(0,3), expand = c(0,0))+
scale_x_continuous(limits = c(-2,2), expand = c(0,0))+
theme(aspect.ratio = 1)
CD42pos <- do.call(data.frame,lapply(CD42pos, function(x) replace(x, is.infinite(x),NA)))
mean(CD42pos$ratio,na.rm = T) # 0.1130388
```
```{r CLR PLT}
## Same for platelets ##
CLR_plt <- read.delim("./Platelets_CLR.csv", sep=";", dec=",") ## getting the CLR from Nicolet et al., 2018, NAR
PLT_CLR_expr<- NULL
PLT_CLR_expr <- merge(HC_plt_c,CLR_plt, by="ID",all=T) # Mergin expression data and CLR data
PLT_CLR_expr$avg_circ_corr <- (PLT_CLR_expr$Plt1 + PLT_CLR_expr$plt2 + PLT_CLR_expr$plt3)/3 # population average
PLT_CLR_expr[is.na(PLT_CLR_expr)] = 0
ggplot(PLT_CLR_expr, aes(x=log10(avg_circ_corr), y=ratio.average))+
geom_point()+
geom_point(data=PLT_CLR_expr[PLT_CLR_expr$ratio.average>0.5,],color="grey")+
geom_point(data= PLT_CLR_expr[PLT_CLR_expr$ratio.average>1,],color="blue")+
theme_classic()+
ggrepel::geom_text_repel(data=PLT_CLR_expr[PLT_CLR_expr$ID %in% CD42pos[CD42pos$ratio >= 1,]$ID,], aes(label = geneName), size = 3,force = 5, min.segment.length = 0.001)+
labs(y="[ circular / linear ]", x= "log10 [circ RPM ]")+
theme(panel.border = element_rect(fill = NA))+
geom_hline(yintercept = 1, linetype="dotted")+
scale_y_continuous(limits = c(0,3), expand = c(0,0))+
scale_x_continuous(limits = c(-2,2), expand = c(0,0))+
theme(aspect.ratio = 1)
```
## Plotting CLR of MK and plt
```{r Plotting CLR of MK and plt}
## Making a simplified df and assigning groups ##
CLR_plt <- read.delim("./Platelets_CLR.csv", sep=";", dec=",")
CLR_for_export_CD42neg <- CD42neg
CLR_for_export_CD42pos <- CD42pos
CLR_for_export_CD42neg$group <- "CD42neg"
CLR_for_export_CD42pos$group <- "CD42pos"