@@ -19,16 +19,20 @@ calc_cmp_transcriptomics_traits=function(v){
19
19
print(c(" INFO|transcriptomics VS traits" ))
20
20
cn = c(" ---" ,colnames(v $ trait ))
21
21
appendTab(inputId = " tabset" ,
22
- tabPanel(" Correlation" ,
22
+ tabPanel(" Correlation with a trait " ,
23
23
isolate(selectInput(" phen0" , " Select Phenotype" ,choices = cn )),
24
24
radioButtons(" corr_type" , " Correlation coefficient:" , c(" Spearman" = " spearman" ," Pearson" = " pearson" )),
25
+ radioButtons(" multiple_test_correction" , " Multiple testing correction:" , c(" Benjamini-Hochberg (BH)" = " BH" ," Bonferroni" = " bonferroni" )),
25
26
isolate(actionButton(" go_alpha2" , " Go!" ))
26
27
))
27
28
appendTab(inputId = " tabset" ,
28
29
tabPanel(" Compare phenotypes" ,
29
30
isolate(selectInput(" phen1" , " Phenotype-1" ,choices = cn )),
30
31
isolate(selectInput(" phen2" , " Phenotype-2" ,choices = cn )),
31
32
isolate(selectInput(" phen3" , " Phenotype-3" ,choices = cn )),
33
+ radioButtons(" corr_type2" , " Correlation coefficient:" , c(" Spearman" = " spearman" ," Pearson" = " pearson" )),
34
+ radioButtons(" multiple_test_correction2" , " Multiple testing correction:" , c(" Benjamini-Hochberg (BH)" = " BH" ," Bonferroni" = " bonferroni" )),
35
+ radioButtons(" significance_level" , " Significance level:" , c(" 0.001" = 0.001 ," 0.05" = 0.05 )),
32
36
isolate(actionButton(" go_alpha3" , " Go!" ))
33
37
))
34
38
appendTab(inputId = " tabset" ,
@@ -40,54 +44,84 @@ calc_cmp_transcriptomics_traits=function(v){
40
44
}
41
45
42
46
cmp_traits = function (v ,my_trait1 ,my_trait2 ,my_trait3 ){
43
- print(" INFO|cmp_traits" )
47
+ print(" INFO|cmp_traits|start " )
44
48
45
49
shinyjs :: show(" plot" )
46
50
shinyjs :: hide(" plot2" )
47
51
52
+ mt_cor = v $ multiple_test_correction2
53
+ cor_type = v $ corr_type2
54
+ sign_level = as.double(v $ significance_level )
55
+
48
56
A = (colnames(v $ transcriptomics ))
49
57
B = v $ trait [,1 ]
50
58
AB = B [B %in% A ]
51
59
ix = which(v $ trait [,1 ]%in% AB )
52
60
N = dim(v $ transcriptomics )[1 ]
53
61
SET_A = c(); SET_B = c(); SET_C = c()
62
+
63
+ raw_p_val1 = c()
64
+ raw_p_val2 = c()
65
+ raw_p_val3 = c()
66
+
54
67
for (x in 1 : N ){
68
+ print(paste0(" INFO|cmp_traits|start" ,x ," |" ,N ))
69
+ print(sign_level )
55
70
if (my_trait1 != " ---" ){
56
71
iy = which(colnames(v $ trait )== my_trait1 )
57
72
T1 = as.numeric(v $ trait [ix ,iy ])
58
73
T2 = as.numeric(unlist(v $ transcriptomics [x ,AB ]))
59
- my_p = (cor.test(T1 ,T2 ))
60
- if (my_p $ p.value < 0.05 ){
61
- SET_A = c(SET_A ,v $ transcriptomics [x ,1 ])
62
- }
74
+ my_p = (cor.test(T1 ,T2 ,method = cor_type ))
75
+ SET_A = c(SET_A ,v $ transcriptomics [x ,1 ])
76
+ raw_p_val1 = c(raw_p_val1 ,my_p $ p.value )
63
77
}
64
78
if (my_trait2 != " ---" ){
65
79
iy = which(colnames(v $ trait )== my_trait2 )
66
80
T1 = as.numeric(v $ trait [ix ,iy ])
67
81
T2 = as.numeric(unlist(v $ transcriptomics [x ,AB ]))
68
- my_p = (cor.test(T1 ,T2 ))
69
- if (my_p $ p.value < 0.05 ){
70
- SET_B = c(SET_B ,v $ transcriptomics [x ,1 ])
71
- }
82
+ my_p = (cor.test(T1 ,T2 ,method = cor_type ))
83
+ SET_B = c(SET_B ,v $ transcriptomics [x ,1 ])
84
+ raw_p_val2 = c(raw_p_val2 ,my_p $ p.value )
72
85
}
73
86
if (my_trait3 != " ---" ){
74
87
iy = which(colnames(v $ trait )== my_trait3 )
75
88
T1 = as.numeric(v $ trait [ix ,iy ])
76
89
T2 = as.numeric(unlist(v $ transcriptomics [x ,AB ]))
77
- my_p = (cor.test(T1 ,T2 ))
78
- if (my_p $ p.value < 0.05 ){
79
- SET_C = c(SET_C ,v $ transcriptomics [x ,1 ])
80
- }
90
+ my_p = (cor.test(T1 ,T2 ,method = cor_type ))
91
+ SET_C = c(SET_C ,v $ transcriptomics [x ,1 ])
92
+ raw_p_val3 = c(raw_p_val3 ,my_p $ p.value )
81
93
}
82
94
83
95
}
96
+ print(summary(raw_p_val1 ))
97
+ print(summary(raw_p_val2 ))
98
+ print(summary(raw_p_val3 ))
99
+
100
+ raw_p_val1 = p.adjust(raw_p_val1 ,mt_cor )
101
+ SET_A = SET_A [raw_p_val1 < = sign_level ]
102
+ raw_p_val2 = p.adjust(raw_p_val2 ,mt_cor )
103
+ SET_B = SET_B [raw_p_val2 < = sign_level ]
104
+ raw_p_val3 = p.adjust(raw_p_val3 ,mt_cor )
105
+ SET_C = SET_C [raw_p_val3 < = sign_level ]
106
+
107
+ print(SET_A )
108
+ print(SET_B )
109
+ print(SET_C )
110
+
111
+ print(paste0(" SET_A" ," |" ,length(SET_A )))
112
+ print(paste0(" SET_B" ," |" ,length(SET_B )))
113
+ print(paste0(" SET_C" ," |" ,length(SET_C )))
114
+
84
115
area1 = SET_A [! (SET_A %in% SET_B )]
85
116
area2 = SET_B [! (SET_B %in% SET_A )]
86
117
cross = SET_A [SET_A %in% SET_B ]
87
118
area1 = length(area1 )
88
119
area2 = length(area2 )
89
120
cross = length(cross )
90
- if (length(SET_C )> 0 ){
121
+
122
+ if ((length(SET_A )+ length(SET_B )+ length(SET_C ))== 0 ){
123
+ shinyalert(" INFO" , " No genes remained using the current filters!" , type = " info" )
124
+ }else if (length(SET_C )> 0 ){
91
125
n12 = SET_A [SET_A %in% SET_B ]; n12 = length(n12 )
92
126
n23 = SET_B [SET_B %in% SET_C ]; n23 = length(n23 )
93
127
n13 = SET_A [SET_A %in% SET_C ]; n13 = length(n13 )
@@ -137,7 +171,7 @@ make_corr=function(v,my_trait,output){
137
171
X4 = c(X4 ,my_trait )
138
172
}
139
173
L = list ()
140
- X2 = p.adjust(X2 ,method = " bonferroni " )
174
+ X2 = p.adjust(X2 ,method = v $ multiple_test_correction )
141
175
L [[1 ]]= X1
142
176
L [[2 ]]= X2
143
177
L [[3 ]]= X3
@@ -173,7 +207,6 @@ make_corr=function(v,my_trait,output){
173
207
abline(h = 0.05 ,lty = 3 )
174
208
abline(h = 0.001 ,lty = 2 )
175
209
176
-
177
210
v $ df_output = new_entry
178
211
179
212
return (L )
0 commit comments