ANCOMBC
ANCOMBC copied to clipboard
Contrasts error with lmerTest, but when run on individual ASVs the lmerTest works
Hello,
I'm trying to run ANCOMBC2 with repeated measures and am getting an error that I need help fixing.
Here is the code I'm running;
output = ancombc2(data = physeq, tax_level = "Genus",
fix_formula = "Term + Week",
rand_formula = "(Week | MouseID)",
p_adj_method = "holm", pseudo_sens = TRUE,
prv_cut = 0.10, lib_cut = 1000, s0_perc = 0.05,
group = "Term",
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 = 8)
)
And the error:
Obtaining initial estimates ...
Error: Encountering the error for `lmerTest` package.
Please try to select one of your taxa and use its raw counts to fix the same linear mixed-effects model using `lmerTest` without the `ANCOMBC` package.
Load all necessary packages EXCEPT `ANCOMBC`, and see if the error arises due to package incompatibility or other issues.
The error message from `lmerTest` is as follows:
contrasts can be applied only to factors with 2 or more levels
In addition: Warning message:
The group variable has < 3 categories
The multi-group comparisons (global/pairwise/dunnet/trend) will be deactivated
My factor has two levels and when I follow the directions and run the lmerTest on individual taxa's raw counts I'm able to get output. Here is my run on two different ASVs:
detach("package:ANCOMBC", unload = TRUE)
lmer(ASV1 ~ Term + Week + (Week | MouseID), data_for_lmer)
Linear mixed model fit by REML ['lmerModLmerTest']
Formula: ASV1 ~ Term + Week + (Week | MouseID)
Data: data_for_lmer
REML criterion at convergence: 926.1512
Random effects:
Groups Name Std.Dev. Corr
MouseID (Intercept) 4.017
Week 1.445 -0.98
Residual 2.916
Number of obs: 177, groups: MouseID, 59
Fixed Effects:
(Intercept) TermFullterm Week
0.2844 1.3294 -0.1271
lmer(ASV2 ~ Term + Week + (Week | MouseID), data_for_lmer)
boundary (singular) fit: see help('isSingular')
Linear mixed model fit by REML ['lmerModLmerTest']
Formula: ASV2 ~ Term + Week + (Week | MouseID)
Data: data_for_lmer
REML criterion at convergence: -54.0103
Random effects:
Groups Name Std.Dev. Corr
MouseID (Intercept) 0.5870
Week 0.2203 -1.00
Residual 0.1367
Number of obs: 177, groups: MouseID, 59
Fixed Effects:
(Intercept) TermFullterm Week
0.108372 0.009403 -0.042373
optimizer (nloptwrap) convergence code: 0 (OK) ; 0 optimizer warnings; 1 lme4 warnings
Any help identifying what the issue could be and how to fix it would be greatly appreciated! Thank you, Samantha
> sessionInfo()
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.34.0 lmerTest_3.1-3 lme4_1.1-36 Matrix_1.7-0 tibble_3.2.1 dplyr_1.1.4
[7] ggplot2_3.5.1 qiime2R_0.99.6 phyloseq_1.48.0
loaded via a namespace (and not attached):
[1] fs_1.6.4 matrixStats_1.3.0
[3] bitops_1.0-7 DirichletMultinomial_1.46.0
[5] devtools_2.4.5 httr_1.4.7
[7] doParallel_1.0.17 numDeriv_2016.8-1.1
[9] profvis_0.3.8 tools_4.4.1
[11] doRNG_1.8.6.2 backports_1.5.0
[13] utf8_1.2.4 R6_2.5.1
[15] vegan_2.6-6.1 lazyeval_0.2.2
[17] mgcv_1.9-1 rhdf5filters_1.16.0
[19] permute_0.9-7 urlchecker_1.0.1
[21] withr_3.0.1 gridExtra_2.3
[23] cli_3.6.3 Biobase_2.64.0
[25] sandwich_3.1-1 sass_0.4.9
[27] mvtnorm_1.2-5 readr_2.1.5
[29] proxy_0.4-27 yulab.utils_0.1.8
[31] foreign_0.8-87 scater_1.32.0
[33] decontam_1.24.0 sessioninfo_1.2.2
[35] readxl_1.4.3 rstudioapi_0.16.0
[37] generics_0.1.3 crosstalk_1.2.1
[39] gtools_3.9.5 biomformat_1.30.0
[41] ggbeeswarm_0.7.2 fansi_1.0.6
[43] DescTools_0.99.60 S4Vectors_0.42.1
[45] DECIPHER_3.0.0 abind_1.4-5
[47] lifecycle_1.0.4 multcomp_1.4-28
[49] yaml_2.3.9 SummarizedExperiment_1.34.0
[51] gplots_3.1.3.1 rhdf5_2.48.0
[53] SparseArray_1.4.8 grid_4.4.1
[55] promises_1.3.0 crayon_1.5.3
[57] miniUI_0.1.1.1 lattice_0.22-6
[59] haven_2.5.4 beachmat_2.20.0
[61] pillar_1.9.0 knitr_1.48
[63] GenomicRanges_1.56.1 boot_1.3-30
[65] gld_2.6.8 codetools_0.2-20
[67] glue_1.7.0 data.table_1.15.4
[69] remotes_2.5.0 MultiAssayExperiment_1.30.3
[71] vctrs_0.6.5 treeio_1.26.0
[73] Rdpack_2.6.2 cellranger_1.1.0
[75] gtable_0.3.5 cachem_1.1.0
[77] xfun_0.45 rbibutils_2.3
[79] S4Arrays_1.4.1 mime_0.12
[81] reformulas_0.4.0 survival_3.6-4
[83] SingleCellExperiment_1.26.0 iterators_1.0.14
[85] bluster_1.14.0 gmp_0.7-5
[87] TH.data_1.1-4 ellipsis_0.3.2
[89] nlme_3.1-164 usethis_2.2.3
[91] bit64_4.0.5 GenomeInfoDb_1.40.1
[93] bslib_0.7.0 irlba_2.3.5.1
[95] vipor_0.4.7 KernSmooth_2.23-24
[97] rpart_4.1.23 DBI_1.2.3
[99] colorspace_2.1-0 BiocGenerics_0.50.0
[101] Hmisc_5.2-0 nnet_7.3-19
[103] ade4_1.7-22 NADA_1.6-1.1
[105] Exact_3.3 tidyselect_1.2.1
[107] bit_4.0.5 compiler_4.4.1
[109] htmlTable_2.4.2 BiocNeighbors_1.22.0
[111] expm_1.0-0 DelayedArray_0.30.1
[113] checkmate_2.3.1 scales_1.3.0
[115] caTools_1.18.2 stringr_1.5.1
[117] digest_0.6.36 minqa_1.2.7
[119] rmarkdown_2.27 XVector_0.44.0
[121] htmltools_0.5.8.1 pkgconfig_2.0.3
[123] base64enc_0.1-3 sparseMatrixStats_1.16.0
[125] MatrixGenerics_1.16.0 fastmap_1.2.0
[127] rlang_1.1.4 htmlwidgets_1.6.4
[129] UCSC.utils_1.0.0 shiny_1.8.1.1
[131] zCompositions_1.5.0-4 DelayedMatrixStats_1.26.0
[133] jquerylib_0.1.4 zoo_1.8-12
[135] jsonlite_1.8.8 energy_1.7-12
[137] BiocParallel_1.38.0 BiocSingular_1.20.0
[139] magrittr_2.0.3 Formula_1.2-5
[141] scuttle_1.14.0 GenomeInfoDbData_1.2.12
[143] Rhdf5lib_1.26.0 munsell_0.5.1
[145] Rcpp_1.0.12 viridis_0.6.5
[147] ape_5.8 CVXR_1.0-15
[149] stringi_1.8.4 rootSolve_1.8.2.4
[151] zlibbioc_1.50.0 MASS_7.3-60.2
[153] plyr_1.8.9 pkgbuild_1.4.4
[155] parallel_4.4.1 ggrepel_0.9.5
[157] forcats_1.0.0 lmom_3.2
[159] Biostrings_2.72.1 splines_4.4.1
[161] multtest_2.60.0 hms_1.1.3
[163] igraph_2.0.3 rngtools_1.5.2
[165] reshape2_1.4.4 stats4_4.4.1
[167] ScaledMatrix_1.12.0 pkgload_1.4.0
[169] evaluate_0.24.0 BiocManager_1.30.23
[171] nloptr_2.1.1 tzdb_0.4.0
[173] foreach_1.5.2 httpuv_1.6.15
[175] tidyr_1.3.1 purrr_1.0.4
[177] rsvd_1.0.5 xtable_1.8-4
[179] Rmpfr_1.1-1 e1071_1.7-14
[181] tidytree_0.4.6 later_1.3.2
[183] viridisLite_0.4.2 class_7.3-22
[185] gsl_2.1-8 truncnorm_1.0-9
[187] memoise_2.0.1 beeswarm_0.4.0
[189] IRanges_2.38.0 cluster_2.1.6
[191] TreeSummarizedExperiment_2.12.0 mia_1.12.0