@@ -80,9 +80,7 @@ ca_create_significance_marker <- function(adjusted_p_value) {
8080# ------------------------------------------------------------
8181ca_analyze_one_variable_pair <- function (
8282 data , variable_1 , variable_2 , pair_index ,
83- cell_adjust_method , alpha , simulation_count , seed ,
84- suppress_cell_p_when_sparse ,
85- practical_ratio_upper , practical_ratio_lower , practical_minimum_difference
83+ cell_adjust_method , alpha , simulation_count , seed
8684) {
8785 pair_data <- data %> %
8886 dplyr :: transmute(
@@ -168,12 +166,6 @@ ca_analyze_one_variable_pair <- function(
168166 names(cell_results ) <- c(" row_category" , " column_category" , " observed_count" )
169167 n <- sum(contingency_table )
170168
171- minimum_difference <- if (is.null(practical_minimum_difference )) {
172- max(5 , 0.005 * n )
173- } else {
174- practical_minimum_difference
175- }
176-
177169 cell_results <- cell_results %> %
178170 dplyr :: mutate(
179171 expected_count = as.vector(pearson_test $ expected ),
@@ -189,13 +181,8 @@ ca_analyze_one_variable_pair <- function(
189181 cell_p_value = 2 * pnorm(abs(adjusted_standardized_residual ), lower.tail = FALSE )
190182 )
191183
192- if (! asymptotic_approximation_ok && suppress_cell_p_when_sparse ) {
193- cell_results <- cell_results %> %
194- dplyr :: mutate(cell_p_value = NA_real_ , cell_adjusted_p_value = NA_real_ )
195- } else {
196- cell_results <- cell_results %> %
197- dplyr :: mutate(cell_adjusted_p_value = p.adjust(cell_p_value , method = cell_adjust_method ))
198- }
184+ cell_results <- cell_results %> %
185+ dplyr :: mutate(cell_adjusted_p_value = p.adjust(cell_p_value , method = cell_adjust_method ))
199186
200187 cell_results <- cell_results %> %
201188 dplyr :: mutate(
@@ -205,10 +192,6 @@ ca_analyze_one_variable_pair <- function(
205192 adjusted_standardized_residual < 0 ~ " less_than_expected" ,
206193 TRUE ~ " as_expected"
207194 ),
208- practical_difference = (
209- (observed_expected_ratio > = practical_ratio_upper | observed_expected_ratio < = practical_ratio_lower ) &
210- absolute_count_difference > = minimum_difference
211- ),
212195 significance_marker = ca_create_significance_marker(cell_adjusted_p_value ),
213196 cell_label = paste0(sprintf(" %.2f" , adjusted_standardized_residual ), significance_marker )
214197 ) %> %
@@ -218,7 +201,6 @@ ca_analyze_one_variable_pair <- function(
218201 n = n , test_method = test_method ,
219202 expected_count_warning = ! asymptotic_approximation_ok ,
220203 cell_adjust_method = cell_adjust_method ,
221- practical_minimum_difference = minimum_difference ,
222204 .before = 1
223205 )
224206
@@ -251,16 +233,9 @@ build_pairwise_association_results <- function(
251233 alpha = 0.05 ,
252234 missing_method = c(" listwise" , " pairwise" ),
253235 simulation_count = 20000 ,
254- seed = 123 ,
255- suppress_cell_p_when_sparse = TRUE ,
256- featured_rule = c(" statistical" , " statistical_and_practical" ),
257- practical_ratio_upper = 1.20 ,
258- practical_ratio_lower = 0.80 ,
259- practical_minimum_difference = NULL ,
260- require_overall_significance = TRUE
236+ seed = 123
261237) {
262238 missing_method <- match.arg(missing_method )
263- featured_rule <- match.arg(featured_rule )
264239
265240 supported_adjust_methods <- c(" holm" , " hochberg" , " hommel" , " bonferroni" , " BH" , " BY" , " fdr" , " none" )
266241 if (! overall_adjust_method %in% supported_adjust_methods ) stop(" overall_adjust_method is invalid." )
@@ -286,11 +261,7 @@ build_pairwise_association_results <- function(
286261 ca_analyze_one_variable_pair(
287262 data = analysis_data , variable_1 = pair [[1 ]], variable_2 = pair [[2 ]],
288263 pair_index = pair_index , cell_adjust_method = cell_adjust_method ,
289- alpha = alpha , simulation_count = simulation_count , seed = seed ,
290- suppress_cell_p_when_sparse = suppress_cell_p_when_sparse ,
291- practical_ratio_upper = practical_ratio_upper ,
292- practical_ratio_lower = practical_ratio_lower ,
293- practical_minimum_difference = practical_minimum_difference
264+ alpha = alpha , simulation_count = simulation_count , seed = seed
294265 )
295266 }
296267 )
@@ -324,11 +295,7 @@ build_pairwise_association_results <- function(
324295 settings <- list (
325296 variables = variables , analysis_n = nrow(analysis_data ),
326297 overall_adjust_method = overall_adjust_method , cell_adjust_method = cell_adjust_method ,
327- alpha = alpha , missing_method = missing_method , simulation_count = simulation_count ,
328- suppress_cell_p_when_sparse = suppress_cell_p_when_sparse , featured_rule = featured_rule ,
329- practical_ratio_upper = practical_ratio_upper , practical_ratio_lower = practical_ratio_lower ,
330- practical_minimum_difference = practical_minimum_difference ,
331- require_overall_significance = require_overall_significance
298+ alpha = alpha , missing_method = missing_method , simulation_count = simulation_count
332299 )
333300
334301 if (nrow(residual_heatmap_data ) == 0 ) {
@@ -353,22 +320,13 @@ build_pairwise_association_results <- function(
353320 ) %> %
354321 dplyr :: mutate(
355322 statistically_featured = (
356- cell_significant & ! expected_count_warning &
357- (! require_overall_significance | pair_significant )
323+ cell_significant & ! expected_count_warning
358324 ),
359- # featured_rule is a scalar: "statistical" -> statistically_featured;
360- # "statistical_and_practical" -> also require practical_difference.
361- featured_combination = statistically_featured &
362- (featured_rule == " statistical" | practical_difference ),
325+ featured_combination = statistically_featured ,
363326 # language-neutral final judgement enum
364327 final_judgement = dplyr :: case_when(
365- expected_count_warning & suppress_cell_p_when_sparse ~ " sparse_suppressed" ,
366- require_overall_significance & ! pair_significant ~ " exploratory_pair_not_significant" ,
367- ! cell_significant ~ " no_clear_difference" ,
368- adjusted_standardized_residual > 0 & practical_difference ~ " significantly_more" ,
369- adjusted_standardized_residual < 0 & practical_difference ~ " significantly_less" ,
370- adjusted_standardized_residual > 0 ~ " more_but_small" ,
371- adjusted_standardized_residual < 0 ~ " less_but_small" ,
328+ cell_significant & adjusted_standardized_residual > 0 ~ " significantly_more" ,
329+ cell_significant & adjusted_standardized_residual < 0 ~ " significantly_less" ,
372330 TRUE ~ " no_clear_difference"
373331 ),
374332 heatmap_fill_value = adjusted_standardized_residual ,
@@ -391,7 +349,7 @@ build_pairwise_association_results <- function(
391349 pair_index , pair_id , variable_1 , variable_2 , rank_within_pair , category_pair ,
392350 row_category , column_category , observed_count , expected_count , count_difference ,
393351 observed_expected_ratio , adjusted_standardized_residual , cell_p_value ,
394- cell_adjusted_p_value , practical_difference , final_judgement , n , cramers_v , association_strength
352+ cell_adjusted_p_value , final_judgement , n , cramers_v , association_strength
395353 )
396354
397355 list (
0 commit comments