@@ -97,15 +97,15 @@ def fit_lm(table,
97
97
return lm , filtered , positive_controls
98
98
99
99
100
- def read_count_threshold (
101
- output_dir : str ,
100
+ def calculate_threshold (
102
101
threshold : int ,
103
102
positive_control_value : str ,
104
103
positive_control_column : qiime2 .CategoricalMetadataColumn ,
105
104
cell_count_column : qiime2 .NumericMetadataColumn ,
106
105
table : pd .DataFrame ,
107
106
control : str ,
108
- asv : str = None ) -> None :
107
+ asv : str = None ):
108
+
109
109
if control == 'asv' :
110
110
if asv is None :
111
111
raise ValueError ("Control type set to asv but no asv provided" )
@@ -187,6 +187,41 @@ def read_count_threshold(
187
187
min_freq = get_threshold (katharo ['log_asv_reads' ],
188
188
katharo ['correct_assign' ],
189
189
threshold / 100 )
190
+ return min_freq , popt , pcov , katharo , max_inputT
191
+
192
+
193
+ def read_count_threshold (
194
+ output_dir : str ,
195
+ threshold : int ,
196
+ positive_control_value : str ,
197
+ positive_control_column : qiime2 .CategoricalMetadataColumn ,
198
+ cell_count_column : qiime2 .NumericMetadataColumn ,
199
+ table : pd .DataFrame ,
200
+ control : str ,
201
+ asv : str = None ) -> None :
202
+
203
+ min_freq , popt , pcov , katharo , max_inputT = \
204
+ calculate_threshold (threshold ,
205
+ positive_control_value ,
206
+ positive_control_column ,
207
+ cell_count_column ,
208
+ table ,
209
+ control ,
210
+ asv )
211
+
212
+
213
+ # PLOT
214
+ x = np .linspace (0 , 5 , 50 )
215
+ y = allosteric_sigmoid (x , * popt )
216
+ plt .plot (katharo ['log_asv_reads' ],
217
+ katharo ['correct_assign' ],
218
+ 'o' , label = 'data' )
219
+ plt .plot (x , y , label = 'fit' )
220
+ plt .ylim (0 , 1.05 )
221
+ plt .legend (loc = 'best' )
222
+ plt .savefig (os .path .join (output_dir , 'fit.svg' ))
223
+ plt .close ()
224
+
190
225
191
226
# VISUALIZER
192
227
max_input_html = q2templates .df_to_html (max_inputT .to_frame ())
0 commit comments