Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when using interaction term in formla, in ancombc2 #297

Open
boaty opened this issue Nov 27, 2024 · 4 comments
Open

error when using interaction term in formla, in ancombc2 #297

boaty opened this issue Nov 27, 2024 · 4 comments

Comments

@boaty
Copy link

boaty commented Nov 27, 2024

Dear author,

I found a error when running anbombc2 with interaction term in formula.

ancombc2 version : 2.4.0

my R codes
out = ancombc2(data =phy_tmp, tax_level = "Species", fix_formula = "TimePoint * Group + AGE + SEX", rand_formula = "(1 + TimePoint |siteID) + ( 1 | siteID:subjectID)", p_adj_method = "BH", pseudo_sens = TRUE, prv_cut = 0.10, lib_cut = 1000, s0_perc = 0.05, group = "Group", struc_zero = TRUE, neg_lb = TRUE, alpha = 0.05, n_cl = 5, verbose = TRUE, global = T, pairwise = T, dunnet = T, trend = F, iter_control = list(tol = 1e-2, max_iter = 20, verbose = TRUE), em_control = list(tol = 1e-5, max_iter = 100), lme_control = lme4::lmerControl(), mdfdr_control = list(fwer_ctrl_method = "BH", B = 100) )

error message:
Error in .data_qc(meta_data = core2$meta_data, formula = fix_formula, : The following variables specified are not in the meta data: TimePoint * Group

So i did some dig in, found the function .data_qc() should take fix_formula as a reference to check the metadata varaible, but somehow it can not recognize "*" .

I replaced "TimePoint * Group + AGE + SEX" by "TimePoint + Group + AGE + SEX" for .data_qc() function. And use original "TimePoint * Group + AGE + SEX" for later modeling. i run as expected.

So, is it a bug or you did this for some reasons to disable interaction terms?

thanks

Zhou

@jamesriddellv
Copy link

jamesriddellv commented Dec 17, 2024

Running into the same issue with 2.6.0.

Error in .data_qc(meta_data = core2$meta_data, formula = fix_formula, :
The following variables specified are not in the meta data: timepoint * treatment

I also ran on the test code from the ANCOM-BC2 tutorial and encounter the same error:

`> library(ANCOMBC)

library(dplyr)
library(phyloseq)
library(microbiome)
library(readxl)
data(dietswap, package = "microbiome")
data(dietswap, package = "microbiome")
output = ancombc2(data = dietswap, tax_level = "Family",
fix_formula = "nationality + timepoint * group",
rand_formula = "(timepoint | subject)",
p_adj_method = "holm", pseudo_sens = TRUE,
prv_cut = 0.10, lib_cut = 1000, s0_perc = 0.05,
group = "group", struc_zero = TRUE, neg_lb = TRUE,
alpha = 0.05, n_cl = 2, verbose = TRUE,
global = TRUE, pairwise = TRUE, dunnet = TRUE, trend = TRUE,
iter_control = list(tol = 1e-2, max_iter = 20,
verbose = TRUE),
em_control = list(tol = 1e-5, max_iter = 100),
lme_control = lme4::lmerControl(),
mdfdr_control = list(fwer_ctrl_method = "holm", B = 100),
trend_control = list(contrast = list(matrix(c(1, 0, -1, 1),
nrow = 2,
byrow = TRUE)),
node = list(2),
solver = "ECOS",
B = 10))
Error in .data_qc(meta_data = core2$meta_data, formula = fix_formula, :
The following variables specified are not in the meta data: timepoint * group`

SessionInfo()
R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS 15.1.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Detroit
tzcode source: internal

attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods
[8] base

other attached packages:
[1] microbiome_1.26.0 ANCOMBC_2.6.0
[3] vegan3d_1.3-0 readxl_1.4.3
[5] corrplot_0.95 apcluster_1.4.13
[7] lubridate_1.9.3 forcats_1.0.0
[9] stringr_1.5.1 purrr_1.0.2
[11] readr_2.1.5 tibble_3.2.1
[13] tidyverse_2.0.0 BiocManager_1.30.25
[15] tidyr_1.3.1 dplyr_1.1.4
[17] ggplot2_3.5.1 viridis_0.6.5
[19] viridisLite_0.4.2 vegan_2.6-8
[21] lattice_0.22-6 permute_0.9-7
[23] phyloseq_1.48.0 TreeSummarizedExperiment_2.12.0
[25] Biostrings_2.72.1 XVector_0.44.0
[27] SingleCellExperiment_1.26.0 SummarizedExperiment_1.34.0
[29] Biobase_2.64.0 GenomicRanges_1.56.2
[31] GenomeInfoDb_1.40.1 IRanges_2.38.1
[33] S4Vectors_0.42.1 BiocGenerics_0.50.0
[35] MatrixGenerics_1.16.0 matrixStats_1.4.1

loaded via a namespace (and not attached):
[1] splines_4.4.0 cellranger_1.1.0
[3] rpart_4.1.23 DirichletMultinomial_1.46.0
[5] lifecycle_1.0.4 Rdpack_2.6.2
[7] doParallel_1.0.17 MASS_7.3-61
[9] MultiAssayExperiment_1.30.3 backports_1.5.0
[11] magrittr_2.0.3 rmarkdown_2.29
[13] Hmisc_5.2-1 doRNG_1.8.6
[15] gld_2.6.6 DBI_1.2.3
[17] minqa_1.2.8 ade4_1.7-22
[19] multcomp_1.4-26 abind_1.4-8
[21] zlibbioc_1.50.0 Rtsne_0.17
[23] expm_1.0-0 TH.data_1.1-2
[25] nnet_7.3-19 rgl_1.3.14
[27] yulab.utils_0.1.8 sandwich_3.1-1
[29] GenomeInfoDbData_1.2.12 ggrepel_0.9.6
[31] irlba_2.3.5.1 tidytree_0.4.6
[33] DelayedMatrixStats_1.26.0 codetools_0.2-20
[35] DelayedArray_0.30.1 energy_1.7-12
[37] scuttle_1.14.0 tidyselect_1.2.1
[39] UCSC.utils_1.0.0 farver_2.1.2
[41] lme4_1.1-35.5 gmp_0.7-5
[43] ScaledMatrix_1.12.0 base64enc_0.1-3
[45] jsonlite_1.8.9 BiocNeighbors_1.22.0
[47] multtest_2.60.0 e1071_1.7-16
[49] Formula_1.2-5 decontam_1.24.0
[51] mia_1.12.0 survival_3.7-0
[53] scater_1.32.1 iterators_1.0.14
[55] systemfonts_1.1.0 foreach_1.5.2
[57] tools_4.4.0 treeio_1.28.0
[59] ragg_1.3.3 DescTools_0.99.58
[61] Rcpp_1.0.13-1 glue_1.8.0
[63] gridExtra_2.3 SparseArray_1.4.8
[65] xfun_0.49 mgcv_1.9-1
[67] numDeriv_2016.8-1.1 withr_3.0.2
[69] fastmap_1.2.0 boot_1.3-31
[71] rhdf5filters_1.16.0 bluster_1.14.0
[73] fansi_1.0.6 digest_0.6.37
[75] rsvd_1.0.5 timechange_0.3.0
[77] R6_2.5.1 textshaping_0.4.1
[79] colorspace_2.1-1 gtools_3.9.5
[81] utf8_1.2.4 generics_0.1.3
[83] data.table_1.16.4 DECIPHER_3.0.0
[85] class_7.3-22 CVXR_1.0-15
[87] httr_1.4.7 htmlwidgets_1.6.4
[89] S4Arrays_1.4.1 scatterplot3d_0.3-44
[91] pkgconfig_2.0.3 gtable_0.3.6
[93] Exact_3.3 Rmpfr_1.0-0
[95] htmltools_0.5.8.1 biomformat_1.32.0
[97] scales_1.3.0 lmom_3.2
[99] knitr_1.49 rstudioapi_0.17.1
[101] tzdb_0.4.0 reshape2_1.4.4
[103] checkmate_2.3.2 nlme_3.1-166
[105] nloptr_2.1.1 zoo_1.8-12
[107] proxy_0.4-27 rhdf5_2.48.0
[109] rootSolve_1.8.2.4 parallel_4.4.0
[111] vipor_0.4.7 foreign_0.8-87
[113] pillar_1.9.0 grid_4.4.0
[115] vctrs_0.6.5 BiocSingular_1.20.0
[117] beachmat_2.20.0 cluster_2.1.6
[119] htmlTable_2.4.3 beeswarm_0.4.0
[121] evaluate_1.0.1 mvtnorm_1.3-2
[123] cli_3.6.3 compiler_4.4.0
[125] rngtools_1.5.2 rlang_1.1.4
[127] crayon_1.5.3 labeling_0.4.3
[129] plyr_1.8.9 fs_1.6.5
[131] ggbeeswarm_0.7.2 stringi_1.8.4
[133] BiocParallel_1.38.0 lmerTest_3.1-3
[135] gsl_2.1-8 munsell_0.5.1
[137] lazyeval_0.2.2 Matrix_1.7-1
[139] hms_1.1.3 sparseMatrixStats_1.16.0
[141] bit64_4.5.2 Rhdf5lib_1.26.0
[143] haven_2.5.4 rbibutils_2.3
[145] igraph_2.1.1 bit_4.5.0.1
[147] ape_5.8

@ctilves
Copy link

ctilves commented Dec 18, 2024

I was receiving the same errors, and realized that the version downloaded using BiocManager::install("ANCOMBC") was not actually the updated version (despite still saying it is version 2.6.0). Installing directly from github using devtools::install_github("FrederickHuangLin/ANCOMBC") seems to install the correct version 2.6.0, and I was able to run models including the interaction term.

@jamesriddellv
Copy link

Thanks @ctilves this fixed the issue for me!

@ScottWrigley
Copy link

I came here looking for a solution to this issue as well. Thank you, @ctilves. Your suggestion solved the problem, and the model will now run with interaction terms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants