ANCOMBC icon indicating copy to clipboard operation
ANCOMBC copied to clipboard

Error in { : task 1 failed - "values must be length 1, but FUN(X[[2]]) result is length 0"

Open EL9856 opened this issue 1 year ago • 1 comments

Hi to all,

I have recently encountered an issue with the ancombc2 function. It keeps returning the error message of:

Error in { : task 1 failed - "values must be length 1,
 but FUN(X[[2]]) result is length 0". 
In addition: Warning messages:
1: In min(beta, na.rm = TRUE) :
  no non-missing arguments to min; returning Inf
2: In max(beta, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf
3: In min(beta, na.rm = TRUE) :
  no non-missing arguments to min; returning Inf
4: In max(beta, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf
5: In min(beta, na.rm = TRUE) :
  no non-missing arguments to min; returning Inf
6: In max(beta, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf

Here's the code that I used to run ancombc2:

milk_output = ancombc2(data = data_phylo_M, tax_level = "Family", rand_formula = NULL,
                       fix_formula = "GDM+Ethnicity+Location+Delivery+Time+Batch",
                       pseudo_sens = T, prv_cut = 0.1, lib_cut = 0, s0_perc = 0.05,
                       group = "Time", struc_zero = T, neg_lb = FALSE, alpha = 0.05,
                       n_cl = 1, verbose = FALSE, global = T, pairwise = TRUE, dunnet = FALSE, 
                       trend = FALSE, iter_control = list(tol = 1e-5, max_iter = 20, verbose = F),
                       em_control = list(tol = 1e-5, max_iter = 100), lme_control = NULL, 
                       mdfdr_control = list(fwer_ctrl_method = "holm", B = 100), 
                       trend_control = NULL, p_adj_method = "holm")

Strangely, the function worked just fine when I removed "Batch" covariate from fix_formula. All of the variables listed in fix_formula are factors with 2 levels except for "Time" and "Batch" with 3 levels.

I've also tried the below code to test out if it's actually "Batch" that's causing the problem:

milk_output = ancombc2(data = data_phylo_M, tax_level = "Family", rand_formula = NULL,
                       fix_formula = "Batch",
                       pseudo_sens = T, prv_cut = 0.1, lib_cut = 0, s0_perc = 0.05,
                       group = "Batch", struc_zero = T, neg_lb = FALSE, alpha = 0.05,
                       n_cl = 1, verbose = FALSE, global = T, pairwise = TRUE, dunnet = FALSE, 
                       trend = FALSE, iter_control = list(tol = 1e-5, max_iter = 20, verbose = F),
                       em_control = list(tol = 1e-5, max_iter = 100), lme_control = NULL, 
                       mdfdr_control = list(fwer_ctrl_method = "holm", B = 100), 
                       trend_control = NULL, p_adj_method = "holm")

And got the same error message as above.

Does anyone have any clue to this?

EL9856 avatar Apr 01 '24 20:04 EL9856

Could you please check the missingness for the variable "Batch"?

Maggie8888 avatar Sep 27 '24 19:09 Maggie8888