Skip to content

Sanity check function blocking interactions in group formula #337

Description

@JeanneDurivageAAC

The latest ancombc2 vignette (april 26th, 2026) suggests that interactions can be specified in the group formula :

Tests for interactions are supported by specifying the interactions in the fix_formula. Please ensure that interactions between variables are included using the * operator, as the : operator is not recognized by the ancombc2 function and will result in an error.
Additionally, when the group variable contains interaction terms, only the main effect will be considered in multi-group comparisons.

However, specifying an interaction in the group formula will result in an error. I have narrowed it down to the lines 133-135 of the data_sanity_check function used by ancombc2( ) :

# Lines 133-135  
else if (!is.numeric(meta_data[, group])) {
    meta_data[, group] = as.factor(meta_data[, group])
    n_level = nlevels(meta_data[, group])
# The following code will return an error : 
ancombc2(data = pseq, 
                  tax_level_ = "Family",
                  fix_formula = "age * bmi + region", 
                  group = "age * bmi", 
                  struc_zero = TRUE, 
                  neg_lb = TRUE)

I'm using ANCOMBC version 2.12.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions