@@ -29,7 +29,8 @@ confounders_clsq<-setClass(
29
29
30
30
params.threshold = entity(name = ' Confounding factor threshold' ,
31
31
type = ' character' ,
32
- description = ' threshold for accepting a factor as confounding (0 < threshold < 1)'
32
+ description = ' threshold for accepting a factor as confounding (0 < threshold < 1)' ,
33
+ value = 0.15
33
34
),
34
35
35
36
params.confounding_factors = entity(name = ' Confounding factors' ,
@@ -74,7 +75,7 @@ setMethod(f="method.apply",
74
75
nm = character (length(factor_names ))
75
76
for (i in 1 : length(factor_names )) {
76
77
fn = unique(c(factor_names [1 ],factor_names [i ]))
77
-
78
+
78
79
# for each factor name check the na count
79
80
FF = filter_na_count(threshold = 2 )
80
81
excl = matrix (NA ,nrow = ncol(D $ data ),ncol = length(fn ))
@@ -88,15 +89,15 @@ setMethod(f="method.apply",
88
89
excl [,k ]= FALSE
89
90
}
90
91
}
91
-
92
+
92
93
if (! all(! excl )) {
93
94
excl = apply(excl ,1 ,function (x ) {
94
95
fn [! x ]
95
96
})
96
97
} else {
97
- excl = fn #
98
+ excl = fn #
98
99
}
99
-
100
+
100
101
clsq $ factor_names = excl
101
102
clsq = method.apply(clsq ,D )
102
103
@@ -121,13 +122,13 @@ setMethod(f="method.apply",
121
122
# redo regression including all potential confounders for each feature
122
123
conf = M $ percent_change > M $ threshold
123
124
factor_names = M $ confounding_factors
124
- L = apply(conf [,2 : ncol(conf )],1 ,function (x ) c(M $ factor_name ,factor_names [x ]))
125
+ L = apply(conf [,2 : ncol(conf ), drop = FALSE ],1 ,function (x ) c(M $ factor_name ,factor_names [x ]))
125
126
M2 = classical_lsq(intercept = TRUE ,alpha = M $ alpha ,mtc = M $ mtc ,factor_names = L )
126
127
M2 = method.apply(M2 ,D )
127
128
128
129
M $ p_value = data.frame (' ttest.p' = pvals [,1 ],' corrected.p' = M2 $ p_value [,2 ]) # MTC already applied
129
130
names(L )= colnames(D $ data )
130
- M $ potential_confounders = L
131
+ M $ potential_confounders = as.list( L )
131
132
M $ significant = data.frame (' sig' = M $ p_value < M $ alpha )
132
133
133
134
return (M )
0 commit comments