Hello,
I encountered a bug in ancombc2() that occurs only when the meta_data contains exactly one column. The error message says a variable (e.g., "Delivery_GW") is not found in the metadata — even though it clearly exists and can be used successfully by model.matrix(). Adding a second column (even arbitrary) resolves the issue immediately, suggesting an internal structure-handling bug.
Steps to Reproduce
library(ANCOMBC)
set.seed(123)
tiny_data <- matrix(rpois(50, lambda = 10), nrow = 5, ncol = 10)
colnames(tiny_data) <- paste0("S", 1:10)
rownames(tiny_data) <- paste0("Taxon_", 1:5)
# ★★★ Single-column metadata → triggers bug ★★★
tiny_meta <- data.frame(Delivery_GW = rnorm(10))
rownames(tiny_meta) <- colnames(tiny_data)
# This throws:
# Error: The following variables specified are not in the meta data: Delivery_GW
ancombc2(
tiny_data,
meta_data = tiny_meta,
fix_formula = "Delivery_GW",
n_cl = 1
)
# Checking the input data type ...
# The input data is of type: matrix
# The imported data is in a generic 'matrix'/'data.frame' format.
# PASS
# Checking the sample metadata ...
# The specified variables in the formula: Delivery_GW
# The available variables in the sample metadata:
# Error in data_sanity_check(data = data, taxa_are_rows = taxa_are_rows, :
# The following variables specified are not in the meta data: Delivery_GW
Workaround: Add Dummy Column
# Add any second column — even a constant
tiny_meta$.dummy <- 1
# Now this runs successfully!
ancombc2(
tiny_data,
meta_data = tiny_meta,
fix_formula = "Delivery_GW",
n_cl = 1
)
This strongly suggests the bug occurs due to unsafe conversion or name-stripping when meta_data is a single-column data frame (e.g., being coerced to vector or losing colnames internally).
Thank you for this useful package! I hope this detailed report helps improve robustness for edge cases like single-covariate models. Let me know if further debugging or testing is needed!
Best regards!
Hello,
I encountered a bug in
ancombc2()that occurs only when themeta_datacontains exactly one column. The error message says a variable (e.g., "Delivery_GW") is not found in the metadata — even though it clearly exists and can be used successfully bymodel.matrix(). Adding a second column (even arbitrary) resolves the issue immediately, suggesting an internal structure-handling bug.Steps to Reproduce
Workaround: Add Dummy Column
This strongly suggests the bug occurs due to unsafe conversion or name-stripping when
meta_datais a single-column data frame (e.g., being coerced to vector or losing colnames internally).Thank you for this useful package! I hope this detailed report helps improve robustness for edge cases like single-covariate models. Let me know if further debugging or testing is needed!
Best regards!