@@ -32,9 +32,10 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
32
32
qcdata <- ribo [[2 ]]
33
33
34
34
# ----------------------------------------ANOVA test---------------------------
35
- if (length(unique(qcdata $ condition_col )) > 2 ){
35
+ if (length(unique(qcdata [[ condition_col ]] )) > 2 ){
36
36
compute_pval_anova <- rRMSAnalyzer :: compute_pval(ribo = ribo , test = " anova" , condition_col = condition_col )
37
37
a <- rRMSAnalyzer :: plot_stat(ribo = ribo , compute_pval = compute_pval_anova , pthr = pthr , condition_col = condition_col , cscore_cutoff = cscore_cutoff )
38
+ sites_anova <- a [[" plot_env" ]][[" significant_sites" ]]
38
39
}
39
40
40
41
# ----------------------------------------Welch test---------------------------
@@ -57,9 +58,10 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
57
58
}
58
59
59
60
# ----------------------------------------Kruskal test-------------------------
60
- if (length(unique(qcdata $ condition_col )) > 2 ){
61
+ if (length(unique(qcdata [[ condition_col ]] )) > 2 ){
61
62
compute_pval_kruskal <- rRMSAnalyzer :: compute_pval(ribo = ribo , test = " kruskal" , condition_col = condition_col )
62
63
k <- rRMSAnalyzer :: plot_stat(ribo = ribo , compute_pval = compute_pval_kruskal , pthr = pthr , condition_col = condition_col , cscore_cutoff = cscore_cutoff )
64
+ sites_kw <- k [[" plot_env" ]][[" significant_sites" ]]
63
65
}
64
66
65
67
# ----------------------------------------Wilcoxon test------------------------
@@ -75,9 +77,9 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
75
77
76
78
ribo_filtered_x <- keep_ribo_samples(ribo_filtered_x ,kept_samples_x )
77
79
78
- compute_pval_wolcoxon <- rRMSAnalyzer :: compute_pval(ribo = ribo_filtered_x , test = " wilcoxon" , condition_col = condition_col )
80
+ compute_pval_wilcoxon <- rRMSAnalyzer :: compute_pval(ribo = ribo_filtered_x , test = " wilcoxon" , condition_col = condition_col )
79
81
80
- x <- rRMSAnalyzer :: plot_stat(ribo = ribo_filtered_x , compute_pval = compute_pval_wolcoxon , pthr = pthr , condition_col = condition_col , cscore_cutoff = cscore_cutoff )
82
+ x <- rRMSAnalyzer :: plot_stat(ribo = ribo_filtered_x , compute_pval = compute_pval_wilcoxon , pthr = pthr , condition_col = condition_col , cscore_cutoff = cscore_cutoff )
81
83
x_list [[i ]] <- x
82
84
}
83
85
@@ -92,8 +94,8 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
92
94
comp_id <- paste0(case , " _vs_" , ctrl )
93
95
94
96
# Extract significant sites from tests
95
- sites_welch <- w_list [[ i ]][[ " plot_env" ]][[" significant_sites" ]]
96
- sites_wilcox <- x_list [[ i ]][[ " plot_env" ]][[" significant_sites" ]]
97
+ sites_welch <- unique(unlist(lapply( w_list , function ( w ) w [[ " plot_env" ]][[" significant_sites" ]])))
98
+ sites_wilcox <- unique(unlist(lapply( x_list , function ( x ) x [[ " plot_env" ]][[" significant_sites" ]])))
97
99
98
100
# Add to the list
99
101
comparison_results [[comp_id ]] <- list (
@@ -106,15 +108,13 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
106
108
results <- list ()
107
109
108
110
# Identify all significant sites in at least on test
109
- if (length(unique(qcdata $ condition_col )) > 2 ){
111
+ if (length(unique(qcdata [[ condition_col ]] )) > 2 ){
110
112
sites_anova <- a [[" plot_env" ]][[" significant_sites" ]]
111
113
sites_kw <- k [[" plot_env" ]][[" significant_sites" ]]
112
114
}
113
- sites_welch <- w_list [[i ]][[" plot_env" ]][[" significant_sites" ]]
114
- sites_wilcox <- x_list [[i ]][[" plot_env" ]][[" significant_sites" ]]
115
115
116
116
# all sites
117
- if (length(unique(qcdata $ condition_col )) > 2 ){
117
+ if (length(unique(qcdata [[ condition_col ]] )) > 2 ){
118
118
all_sites <- unique(c(sites_anova , sites_kw , sites_welch , sites_wilcox ))
119
119
} else {
120
120
all_sites <- unique(c(sites_welch , sites_wilcox ))
@@ -124,7 +124,7 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
124
124
results $ Site <- all_sites
125
125
126
126
# Add Anova et Kruskal column if groups > 2
127
- if (length(unique(qcdata $ condition_col )) > 2 ) {
127
+ if (length(unique(qcdata [[ condition_col ]] )) > 2 ) {
128
128
results $ Multiple_comparison_Anova <- ifelse(all_sites %in% sites_anova , " Significant" , " NS" )
129
129
results $ Multiple_comparison_Kruskal_Wallis <- ifelse(all_sites %in% sites_kw , " Significant" , " NS" )
130
130
}
0 commit comments