-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRidge Plot.qmd
More file actions
1339 lines (1089 loc) · 43 KB
/
Ridge Plot.qmd
File metadata and controls
1339 lines (1089 loc) · 43 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
# Comparison of TransPropy with Other Tool Packages Using Ridge Plot
```r
library(readr)
library(TransProR)
library(dplyr)
library(rlang)
library(linkET)
library(funkyheatmap)
library(tidyverse)
library(RColorBrewer)
library(ggalluvial)
library(tidyr)
library(tibble)
library(ggplot2)
library(ggridges)
library(reshape2)
library(gridExtra)
```
## Finding the top three genes with the highest countdown: CFD, ANKRD35, ALOXE3
```r
# Select all *countdown columns
test_formatted <- df_formatted[ ,c("id","deseq2countdown","edgeRcountdown","limmacountdown","outRstcountdown","TransPropycountdown")]
# Extract the rows where the values in the last column are greater than all previous columns
test_formatted1 <- test_formatted[apply(test_formatted[, -1], 1, function(row) all(row[length(row)] > row[1:(length(row)-1)])), ]
print(test_formatted1) # Show the total number of genes where the countdown is higher than that selected by the previous four methods
# Set the value of N
N <- 100 # Replace with your desired value
# Exclude the ID column from the comparison and find the rows where the value in the last column is greater than the maximum value of the previous columns by more than N
test_formatted2 <- test_formatted1[apply(test_formatted1[, -1], 1, function(row) max(row[1:(length(row)-1)]) + N < row[length(row)]), ]
# Display the result
print(test_formatted2)
# Sort by the difference between the last column and the maximum value of the previous columns, select the top N rows with the largest differences
N1 <- 3 # Replace with your desired value
# Calculate the difference and add it as a new column
test_formatted$Difference <- apply(test_formatted[, -1], 1, function(row) row[length(row)] - max(row[1:(length(row)-1)]))
# Sort the data frame by the Difference column in descending order
sorted_df <- test_formatted[order(-test_formatted$Difference), ]
# Select the top N rows
top_N1_rows <- head(sorted_df, N1)
# Display the result
print(top_N1_rows)
```
## Bubble chart + stacked chart + bar chart + nested bar chart
```r
test_formatted33 <- df_formatted[1:33 ,c("id","deseq2countdown","edgeRcountdown", "limmacountdown","outRstcountdown","TransPropycountdown")]
N1 <- 33 # Replace with your desired value
# Calculate the difference and add it as a new column
test_formatted33$Difference <- apply(test_formatted33[, -1], 1, function(row) row[length(row)] - max(row[1:(length(row)-1)]))
# Sort the data frame by the Difference column in descending order
sorted_df <- test_formatted33[order(-test_formatted33$Difference), ]
# Select the top N rows
top_N1_rows <- head(sorted_df, N1)
# Display the result
print(top_N1_rows)
top_N1_rows1 <- t(top_N1_rows[,c("id","deseq2countdown","edgeRcountdown","TransPropycountdown", "limmacountdown","outRstcountdown")])
colnames(top_N1_rows1) <- top_N1_rows1["id",]
top_N1_rows1 <- as.data.frame(top_N1_rows1[-1,])
top_N1_rows1$methods <- rownames(top_N1_rows1)
# rearrange
top_N1_rows1 <- top_N1_rows1[, c(ncol(top_N1_rows1), 1:(ncol(top_N1_rows1)-1))]
print(top_N1_rows1)
```
```r
Convert data to long format
data_melt <- melt(top_N1_rows1, id.vars = "methods")
data_melt$value <- as.numeric(data_melt$value)
data_melt$methods <- factor(data_melt$methods, levels = unique(data_melt$methods))
levels(data_melt$methods)
##count
p1 <- ggplot(data_melt, aes( x = variable,y=value,fill = methods,
stratum = methods, alluvium = methods))+
geom_stratum(width = 0.5, color='white')+
geom_alluvium(alpha = 0.5,
width = 0.5,
curve_type = "linear")+
theme_minimal()+
theme(axis.text.x = element_text(angle = 45, hjust = 1),
panel.grid = element_blank())+
scale_fill_manual(values = c("#3273c1","#2b8f9a","#6e4ab4",
"#48884d","#a8a74e"))+
#scale_y_continuous(expand = c(0,0),name="",
#label=c("0%","25%","50%","75%","100%"))+
scale_x_discrete(expand = c(0,0),name="")+
theme(panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_blank(),
axis.ticks.y = element_blank(),
axis.text = element_text(color="black",size=10),
axis.ticks.length.x = unit(0.1,"cm"),
plot.margin = margin(10, 10, 10, 10)
)
p1
```

<div style="text-align: center;">
down stacked chart
</div>
```r
##percentage
# Calculate the total value for each variable
total_values <- data_melt %>%
group_by(variable) %>%
summarize(total = sum(value))
# Merge data frames to calculate percentages
data_melt <- data_melt %>%
left_join(total_values, by = "variable") %>%
mutate(percentage = (value / total) * 100)
ggplot(data_melt, aes(x = variable, y = percentage, fill = methods, stratum = methods, alluvium = methods)) +
geom_stratum(width = 0.5, color = "white") +
geom_alluvium(alpha = 0.5, width = 0.5, curve_type = "linear") +
theme_minimal()+
theme(axis.text.x = element_text(angle = 45, hjust = 1),
panel.grid = element_blank())+
theme(axis.text.x = element_text(angle = 45, hjust = 1),
panel.grid = element_blank())+
scale_fill_manual(values = c("#3273c1","#2b8f9a","#6e4ab4",
"#48884d","#a8a74e"))+
#scale_y_continuous(expand = c(0,0),name="",
#label=c("0%","25%","50%","75%","100%"))+
scale_x_discrete(expand = c(0,0),name="")+
theme(panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_blank(),
axis.ticks.y = element_blank(),
axis.text = element_text(color="black",size=10),
axis.ticks.length.x = unit(0.1,"cm"),
plot.margin = margin(10, 10, 10, 10)
)
```
```r
p2 <- ggplot(data_melt, aes(x = variable, y = methods, size = value, color = methods)) +
geom_point(alpha = 0.7) +
scale_size_continuous(range = c(1, 10)) +
theme_minimal() +
theme(
panel.grid = element_blank(),
legend.position = "none",
axis.line = element_line(color = "black"),
axis.ticks = element_line(color = "black")
) +
theme_minimal()+
theme(axis.text.x = element_text(angle = 45, hjust = 1),
panel.grid = element_blank())+
scale_color_manual(values = c("#3273c1","#2b8f9a","#6e4ab4",
"#48884d","#a8a74e"))+
#scale_y_continuous(expand = c(0,0),name="",
#label=c("0%","25%","50%","75%","100%"))+
#scale_x_discrete(expand = c(0,0),name="")+
theme(panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_blank(),
axis.ticks.y = element_blank(),
axis.text = element_text(color="black",size=10),
axis.ticks.length.x = unit(0.1,"cm"),
plot.margin = margin(10, 10, 10, 10)
)
#labs(x = "Time", y = "Cell Type", size = "Proportion (%)", color = "Cell Type")
p2
```

<div style="text-align: center;">
bubble
</div>
```r
# bar chart
data_sums <- aggregate(value ~ methods, data = data_melt, sum)
data_sums$methods <- factor(data_sums$methods, levels = unique(data_sums$methods))
levels(data_sums$methods)
p3 <- ggplot(data_sums, aes(x = methods, y = value, fill = methods)) +
geom_bar(stat = "identity") +
coord_flip() +
theme_minimal() +
theme(
panel.grid = element_blank(),
legend.position = "none",
axis.line = element_line(color = "black"),
axis.ticks = element_line(color = "black")
) +
theme_minimal()+
theme(axis.text.x = element_text(angle = 45, hjust = 1),
panel.grid = element_blank())+
scale_fill_manual(values = c("#3273c1","#2b8f9a","#6e4ab4",
"#48884d","#a8a74e"))+
#scale_y_continuous(expand = c(0,0),name="",
#label=c("0%","25%","50%","75%","100%"))+
scale_x_discrete(expand = c(0,0),name="")+
theme(panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_blank(),
axis.ticks.y = element_blank(),
axis.text = element_text(color="black",size=10),
axis.ticks.length.x = unit(0.1,"cm"),
plot.margin = margin(10, 10, 10, 10)
)
#labs(y = "Proportion (%)", fill = "Cell Type", x = "Cell Type")
p3
```

<div style="text-align: center;">
bar
</div>
```r
library(tidyverse)
library(ggtext)
library(ggrepel)
library(patchwork)
library(systemfonts)
library(dplyr)
# Retain only the TransPropy and Difference columns along with the id column
selected_columns <- sorted_df[, c("TransPropycountdown", "Difference")]
# Get the maximum value and its corresponding column position from the first four columns of TransPropy for each row
max_values <- apply(sorted_df[, 2:5], 1, max) # Assuming the first four columns are columns 2 to 5
max_index <- apply(sorted_df[, 2:5], 1, which.max)
# Create a new dataframe that retains the maximum value among the first four columns, setting other values to 0
new_data <- sorted_df[, 2:5]
for(i in 1:nrow(new_data)) {
new_data[i, ] <- ifelse(1:4 == max_index[i], new_data[i, ], 0)
}
# Add the id, TransPropy, and Difference columns back to the new dataframe
new_data <- cbind(sorted_df[, "id"], new_data, selected_columns)
# Display the result
print(new_data)
# Rename the first column of the new dataframe to id
colnames(new_data)[1] <- "id"
new_data$id <- factor(new_data$id, levels = unique(new_data$id))
new_data$color1 <- "TransProPy" # Add a pseudo-variable
new_data %>%
ggplot(aes(id, TransPropycountdown)) +
geom_col(aes(fill = "TransProPy"), width = .85) +
scale_fill_manual(values = c("TransProPy" = "#6d4cb1"), name = "Legend Title") +
labs(y = "TransPropycountdown", x = "ID") +
theme_minimal() + # Use a simple theme
theme(axis.text.x = element_text(angle = 45, hjust = 1),
panel.grid = element_blank())
# Create the color2 column
new_data <- new_data %>%
mutate(color2 = case_when(
deseq2countdown != 0 ~ "#3773bd",
edgeRcountdown != 0 ~ "#358e99",
limmacountdown != 0 ~ "#4b8954",
outRstcountdown != 0 ~ "#a8a75a",
TRUE ~ NA_character_
))
# Create the fourmethods column with non-zero elements from the four columns
new_data <- new_data %>%
mutate(fourmethods = case_when(
deseq2countdown != 0 ~ deseq2countdown,
edgeRcountdown != 0 ~ edgeRcountdown,
limmacountdown != 0 ~ limmacountdown,
outRstcountdown != 0 ~ outRstcountdown,
TRUE ~ NA_real_
))
# Base bar plot
base_plot <- new_data %>%
ggplot(aes(id, TransPropycountdown)) +
geom_col(fill = "#6d4cb1", width = .85, alpha = 1) + # Use fixed color, not mapped with aes
labs(y = "TransPropycountdown", x = "ID") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
panel.grid = element_blank())
# Overlay bar plot with text labels
overlay_plot <- base_plot +
geom_col(
data = new_data %>% filter(!is.na(fourmethods)),
aes(x = id, y = fourmethods, fill = color2),
width = .4, alpha = 0.9
) +
scale_fill_identity(name = "Method", guide = "legend", labels = c("edgeR", "limma", "outRst")) +
guides(fill = guide_legend(title = "Method")) +
# Add text labels to the base bar plot
geom_text(
data = new_data,
aes(x = id, y = TransPropycountdown, label = TransPropycountdown),
size = 4.3, nudge_y = 12, vjust = 0, color = "#6d4cb1", fontface = "bold"
) +
# Add text labels to the overlay bar plot
geom_text(
data = new_data %>% filter(!is.na(fourmethods)),
aes(x = id, y = fourmethods, label = fourmethods, color = color2),
size = 4.3, nudge_y = 12, vjust = 0, fontface = "bold"
) +
scale_color_identity()
# Display the overlay plot
print(overlay_plot)
```

<div style="text-align: center;">
overlay_plot1
</div>
```r
# Prepare data, sort by positive then negative differences
new_data1 <- new_data %>%
mutate(group = ifelse(Difference >= 0, "Positive", "Negative")) %>%
arrange(desc(Difference)) %>%
mutate(id = factor(id, levels = id))
# Plot line graph
difference_line <- new_data1 %>%
ggplot(aes(x = id, y = Difference, group = 1)) +
geom_line(aes(color = group), linewidth = 1) +
geom_point(size = 4, aes(color = group), show.legend = FALSE) +
theme_bw(base_size = 20) +
theme(panel.grid = element_blank(),
axis.text.x = element_text(angle = 60, size = 15, hjust = 1, vjust = 1)) +
scale_color_manual(values = c("Positive" = "#6c4dac", "Negative" = "#beb8d7"))
# Display line graph
print(difference_line)
```

<div style="text-align: center;">
difference_line
</div>
```r
# Prepare data, sort by positive then negative differences
new_data1 <- new_data %>%
mutate(group = ifelse(Difference >= 0, "Positive", "Negative")) %>%
arrange(desc(Difference)) %>%
mutate(id = factor(id, levels = id))
# Plot bar graph
difference_bar <- new_data1 %>%
ggplot(aes(x = id, y = Difference, fill = group)) +
geom_col() +
scale_fill_manual(values = c("Positive" = "#6c4dac", "Negative" = "#beb8d7"), name = "Difference Type") +
theme_bw(base_size = 20) +
theme(panel.grid = element_blank(),
axis.text.x = element_text(angle = 60, size = 15, hjust = 1, vjust = 1)) +
labs(y = "Difference", x = "ID")
# Display bar graph
print(difference_bar)
```

<div style="text-align: center;">
difference_bar
</div>
## CFD
### TRANSPROPY
```r
#### TRANSPRO
# Set up the container for the final generated data
correlation <- data.frame()
TransPropy_CFD <- as.data.frame(TransPropy[,"CFD"])
colnames(TransPropy_CFD) <- c("CFD")
# Get the range for batch operations, which should be a vector
genelist <- colnames(TransPropy)
# Start the for loop, exporting data to the container
gene <- "CFD"
genedata <- as.numeric(TransPropy[,gene])
for(i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Compute correlation
dd <- cor.test(genedata, as.numeric(TransPropy[,i]), method="spearman")
# 3. Fill in the data
correlation[i,1] <- gene
correlation[i,2] <- genelist[i]
correlation[i,3] <- dd$estimate
correlation[i,4] <- dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation <- na.omit(correlation)
correlation_TransPropy_CFD <- correlation
# write.table(correlation_TransPropy_CFD, file="correlation_TransPropy_CFD.csv", sep=",", row.names=TRUE)
N <- 0.5 # Set the threshold to 0.5, for example
# Calculate the number of rows where the absolute value of 'cor' is greater than N
TransPropycount_CFD <- sum(abs(correlation_TransPropy_CFD$cor) > N)
# Print results
TransPropycountup_CFD <- sum(correlation_TransPropy_CFD$cor > N)
TransPropycountdown_CFD <- sum(correlation_TransPropy_CFD$cor < -N)
print(paste("TransPropycount_CFD:", TransPropycount_CFD,
"TransPropycountup_CFD:", TransPropycountup_CFD,
"TransPropycountdown_CFD:", TransPropycountdown_CFD))
```
### DESEQ2
```r
# Set up the container for the final generated data
correlation <- data.frame()
# Get the range for batch operations, which should be a vector
genelist <- colnames(deseq2)
# Start the for loop, exporting data to the container
gene <- "CFD"
genedata <- as.numeric(deseq2[,gene])
for(i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Compute correlation
dd <- cor.test(genedata, as.numeric(deseq2[,i]), method="spearman")
# 3. Fill in the data
correlation[i,1] <- gene
correlation[i,2] <- genelist[i]
correlation[i,3] <- dd$estimate
correlation[i,4] <- dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation <- na.omit(correlation)
correlation_deseq2_CFD <- correlation
# write.table(correlation_deseq2_CFD, file="correlation_deseq2_CFD.csv", sep=",", row.names=TRUE)
N <- 0.5 # Set the threshold to 0.5, for example
# Calculate the number of rows where the absolute value of 'cor' is greater than N
deseq2count_CFD <- sum(abs(correlation_deseq2_CFD$cor) > N)
# Print results
deseq2countup_CFD <- sum(correlation_deseq2_CFD$cor > N)
deseq2countdown_CFD <- sum(correlation_deseq2_CFD$cor < -N)
print(paste("deseq2count_CFD:", deseq2count_CFD,
"deseq2countup_CFD:", deseq2countup_CFD,
"deseq2countdown_CFD:", deseq2countdown_CFD))
```
### edgeR
```r
# Set up the container for the final generated data
correlation <- data.frame()
# Get the range for batch operations, which should be a vector
genelist <- colnames(edgeR)
# Start the for loop, exporting data to the container
gene <- "CFD"
genedata <- as.numeric(edgeR[,gene])
for(i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Compute correlation
dd <- cor.test(genedata, as.numeric(edgeR[,i]), method="spearman")
# 3. Fill in the data
correlation[i,1] <- gene
correlation[i,2] <- genelist[i]
correlation[i,3] <- dd$estimate
correlation[i,4] <- dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation <- na.omit(correlation)
correlation_edgeR_CFD <- correlation
# write.table(correlation_edgeR_CFD, file="correlation_edgeR_CFD.csv", sep=",", row.names=TRUE)
N <- 0.5 # Set the threshold to 0.5, for example
# Calculate the number of rows where the absolute value of 'cor' is greater than N
edgeRcount_CFD <- sum(abs(correlation_edgeR_CFD$cor) > N)
# Print results
edgeRcountup_CFD <- sum(correlation_edgeR_CFD$cor > N)
edgeRcountdown_CFD <- sum(correlation_edgeR_CFD$cor < -N)
print(paste("edgeRcount_CFD:", edgeRcount_CFD,
"edgeRcountup_CFD:", edgeRcountup_CFD,
"edgeRcountdown_CFD:", edgeRcountdown_CFD))
```
### limma
```r
# Set up the container for the final generated data
correlation <- data.frame()
# Get the range for batch operations, which should be a vector
genelist <- colnames(limma)
# Start the for loop, exporting data to the container
gene <- "CFD"
genedata <- as.numeric(limma[,gene])
for(i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Compute correlation
dd <- cor.test(genedata, as.numeric(limma[,i]), method="spearman")
# 3. Fill in the data
correlation[i,1] <- gene
correlation[i,2] <- genelist[i]
correlation[i,3] <- dd$estimate
correlation[i,4] <- dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation <- na.omit(correlation)
correlation_limma_CFD <- correlation
# write.table(correlation_limma_CFD, file="correlation_limma_CFD.csv", sep=",", row.names=TRUE)
N <- 0.5 # Set the threshold to 0.5, for example
# Calculate the number of rows where the absolute value of 'cor' is greater than N
limmacount_CFD <- sum(abs(correlation_limma_CFD$cor) > N)
# Print results
limmacountup_CFD <- sum(correlation_limma_CFD$cor > N)
limmacountdown_CFD <- sum(correlation_limma_CFD$cor < -N)
print(paste("limmacount_CFD:", limmacount_CFD,
"limmacountup_CFD:", limmacountup_CFD,
"limmacountdown_CFD:", limmacountdown_CFD))
```
### outRst
```r
# Set up the container for the final generated data
correlation <- data.frame()
# Get the range for batch operations, which should be a vector
genelist <- colnames(outRst)
# Start the for loop, exporting data to the container
gene <- "CFD"
genedata <- as.numeric(outRst[,gene])
for(i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Compute correlation
dd <- cor.test(genedata, as.numeric(outRst[,i]), method="spearman")
# 3. Fill in the data
correlation[i,1] <- gene
correlation[i,2] <- genelist[i]
correlation[i,3] <- dd$estimate
correlation[i,4] <- dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation <- na.omit(correlation)
correlation_outRst_CFD <- correlation
# write.table(correlation_outRst_CFD, file="correlation_outRst_CFD.csv", sep=",", row.names=TRUE)
N <- 0.5 # Set the threshold to 0.5, for example
# Calculate the number of rows where the absolute value of 'cor' is greater than N
outRstcount_CFD <- sum(abs(correlation_outRst_CFD$cor) > N)
# Print results
outRstcountup_CFD <- sum(correlation_outRst_CFD$cor > N)
outRstcountdown_CFD <- sum(correlation_outRst_CFD$cor < -N)
print(paste("outRstcount_CFD:", outRstcount_CFD,
"outRstcountup_CFD:", outRstcountup_CFD,
"outRstcountdown_CFD:", outRstcountdown_CFD))
```
## ANKRD35
### TRANSPROPY
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(TransPropy)
# Start the for loop, exporting data to the container
gene <- "ANKRD35"
genedata <- as.numeric(TransPropy[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(TransPropy[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_TransPropy_ANKRD35 <- correlation
# write.table(correlation_TransPropy_ANKRD35, file="correlation_TransPropy_ANKRD35.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
TransPropycount_ANKRD35 <- sum(abs(correlation_TransPropy_ANKRD35$cor) > N)
TransPropycountup_ANKRD35 <- sum(correlation_TransPropy_ANKRD35$cor > N)
TransPropycountdown_ANKRD35 <- sum(correlation_TransPropy_ANKRD35$cor < -N)
print(paste("TransPropycount_ANKRD35:", TransPropycount_ANKRD35,
"TransPropycountup_ANKRD35:", TransPropycountup_ANKRD35,
"TransPropycountdown_ANKRD35:", TransPropycountdown_ANKRD35))
```
### DESEQ2
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(deseq2)
# Start the for loop, exporting data to the container
gene <- "ANKRD35"
genedata <- as.numeric(deseq2[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(deseq2[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_deseq2_ANKRD35 <- correlation
# write.table(correlation_deseq2_ANKRD35, file="correlation_deseq2_ANKRD35.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
deseq2count_ANKRD35 <- sum(abs(correlation_deseq2_ANKRD35$cor) > N)
deseq2countup_ANKRD35 <- sum(correlation_deseq2_ANKRD35$cor > N)
deseq2countdown_ANKRD35 <- sum(correlation_deseq2_ANKRD35$cor < -N)
print(paste("deseq2count_ANKRD35:", deseq2count_ANKRD35,
"deseq2countup_ANKRD35:", deseq2countup_ANKRD35,
"deseq2countdown_ANKRD35:", deseq2countdown_ANKRD35))
```
### edgeR
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(edgeR)
# Start the for loop, exporting data to the container
gene <- "ANKRD35"
genedata <- as.numeric(edgeR[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(edgeR[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_edgeR_ANKRD35 <- correlation
# write.table(correlation_edgeR_ANKRD35, file="correlation_edgeR_ANKRD35.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
edgeRcount_ANKRD35 <- sum(abs(correlation_edgeR_ANKRD35$cor) > N)
edgeRcountup_ANKRD35 <- sum(correlation_edgeR_ANKRD35$cor > N)
edgeRcountdown_ANKRD35 <- sum(correlation_edgeR_ANKRD35$cor < -N)
print(paste("edgeRcount_ANKRD35:", edgeRcount_ANKRD35,
"edgeRcountup_ANKRD35:", edgeRcountup_ANKRD35,
"edgeRcountdown_ANKRD35:", edgeRcountdown_ANKRD35))
```
### limma
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(limma)
# Start the for loop, exporting data to the container
gene <- "ANKRD35"
genedata <- as.numeric(limma[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(limma[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_limma_ANKRD35 <- correlation
# write.table(correlation_limma_ANKRD35, file="correlation_limma_ANKRD35.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
limmacount_ANKRD35 <- sum(abs(correlation_limma_ANKRD35$cor) > N)
limmacountup_ANKRD35 <- sum(correlation_limma_ANKRD35$cor > N)
limmacountdown_ANKRD35 <- sum(correlation_limma_ANKRD35$cor < -N)
print(paste("limmacount_ANKRD35:", limmacount_ANKRD35,
"limmacountup_ANKRD35:", limmacountup_ANKRD35,
"limmacountdown_ANKRD35:", limmacountdown_ANKRD35))
```
### outRst
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(outRst)
# Start the for loop, exporting data to the container
gene <- "ANKRD35"
genedata <- as.numeric(outRst[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(outRst[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_outRst_ANKRD35 <- correlation
# write.table(correlation_outRst_ANKRD35, file="correlation_outRst_ANKRD35.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
outRstcount_ANKRD35 <- sum(abs(correlation_outRst_ANKRD35$cor) > N)
outRstcountup_ANKRD35 <- sum(correlation_outRst_ANKRD35$cor > N)
outRstcountdown_ANKRD35 <- sum(correlation_outRst_ANKRD35$cor < -N)
print(paste("outRstcount_ANKRD35:", outRstcount_ANKRD35,
"outRstcountup_ANKRD35:", outRstcountup_ANKRD35,
"outRstcountdown_ANKRD35:", outRstcountdown_ANKRD35))
```
## ALOXE3
### TRANSPROPY
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(TransPropy)
# Start the for loop, exporting data to the container
gene <- "ALOXE3"
genedata <- as.numeric(TransPropy[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(TransPropy[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_TransPropy_ALOXE3 <- correlation
# write.table(correlation_TransPropy_ALOXE3, file="correlation_TransPropy_ALOXE3.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
TransPropycount_ALOXE3 <- sum(abs(correlation_TransPropy_ALOXE3$cor) > N)
TransPropycountup_ALOXE3 <- sum(correlation_TransPropy_ALOXE3$cor > N)
TransPropycountdown_ALOXE3 <- sum(correlation_TransPropy_ALOXE3$cor < -N)
print(paste("TransPropycount_ALOXE3:", TransPropycount_ALOXE3,
"TransPropycountup_ALOXE3:", TransPropycountup_ALOXE3,
"TransPropycountdown_ALOXE3:", TransPropycountdown_ALOXE3))
```
### DESEQ2
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(deseq2)
# Start the for loop, exporting data to the container
gene <- "ALOXE3"
genedata <- as.numeric(deseq2[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(deseq2[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_deseq2_ALOXE3 <- correlation
# write.table(correlation_deseq2_ALOXE3, file="correlation_deseq2_ALOXE3.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
deseq2count_ALOXE3 <- sum(abs(correlation_deseq2_ALOXE3$cor) > N)
deseq2countup_ALOXE3 <- sum(correlation_deseq2_ALOXE3$cor > N)
deseq2countdown_ALOXE3 <- sum(correlation_deseq2_ALOXE3$cor < -N)
print(paste("deseq2count_ALOXE3:", deseq2count_ALOXE3,
"deseq2countup_ALOXE3:", deseq2countup_ALOXE3,
"deseq2countdown_ALOXE3:", deseq2countdown_ALOXE3))
```
### edgeR
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(edgeR)
# Start the for loop, exporting data to the container
gene <- "ALOXE3"
genedata <- as.numeric(edgeR[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(edgeR[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_edgeR_ALOXE3 <- correlation
# write.table(correlation_edgeR_ALOXE3, file="correlation_edgeR_ALOXE3.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
edgeRcount_ALOXE3 <- sum(abs(correlation_edgeR_ALOXE3$cor) > N)
edgeRcountup_ALOXE3 <- sum(correlation_edgeR_ALOXE3$cor > N)
edgeRcountdown_ALOXE3 <- sum(correlation_edgeR_ALOXE3$cor < -N)
print(paste("edgeRcount_ALOXE3:", edgeRcount_ALOXE3,
"edgeRcountup_ALOXE3:", edgeRcountup_ALOXE3,
"edgeRcountdown_ALOXE3:", edgeRcountdown_ALOXE3))
```
### limma
```r
# Set the container to store the final generated data
correlation <- data.frame()
# Get the range for batch processing, which should be a vector
genelist <- colnames(limma)
# Start the for loop, exporting data to the container
gene <- "ALOXE3"
genedata <- as.numeric(limma[, gene])
for (i in 1:length(genelist)) {
# 1. Indicate progress
print(i)
# 2. Calculate correlation
dd = cor.test(genedata, as.numeric(limma[, i]), method="spearman")
# 3. Fill the container
correlation[i, 1] = gene
correlation[i, 2] = genelist[i]
correlation[i, 3] = dd$estimate
correlation[i, 4] = dd$p.value
}
colnames(correlation) <- c("gene1", "gene2", "cor", "p.value")
class(correlation)
correlation = na.omit(correlation)
correlation_limma_ALOXE3 <- correlation
# write.table(correlation_limma_ALOXE3, file="correlation_limma_ALOXE3.csv", sep=",", row.names=T)
N <- 0.5 # Set threshold to 0.5
limmacount_ALOXE3 <- sum(abs(correlation_limma_ALOXE3$cor) > N)
limmacountup_ALOXE3 <- sum(correlation_limma_ALOXE3$cor > N)
limmacountdown_ALOXE3 <- sum(correlation_limma_ALOXE3$cor < -N)
print(paste("limmacount_ALOXE3:", limmacount_ALOXE3,
"limmacountup_ALOXE3:", limmacountup_ALOXE3,
"limmacountdown_ALOXE3:", limmacountdown_ALOXE3))
```
### outRst
```r
# Set the container to store the final generated data