zhouhj1994 / LinDA

33 stars 3 forks source link

Running mixed model example crashes R #15

Open RachBioHaz opened 9 months ago

RachBioHaz commented 9 months ago

Hi, since the new installation of R and RStudio, I have been unable to run any mixed-model analysis in LinDA. I have tried natively in R and with RStudio with the same result. As long as it's a linear model, there is no crash, but it always crashes with a mixed model. I am able to replicate this with the example for this package in CRAN.

Following the example on https://search.r-project.org/CRAN/refmans/MicrobiomeStat/html/linda.html, the following bit of code crashes R/RStudio:

Differential abundance analysis pooling both the left and right throat data

Mixed effects model is used

ind <- depth >= 1000 linda.obj <- linda(otu.tab[, ind], meta[ind, ], formula = '~Smoke+Sex+(1|SubjectID)', feature.dat.type = 'count', prev.filter = 0.1, is.winsor = TRUE, outlier.pct = 0.03, p.adj.method = "BH", alpha = 0.1)

Hoping you can let me know what has changed - I am unable to go back to an earlier version of R as I need to run the current version for my other work. Cheers

Session Info

R version 4.3.1 (2023-06-16 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale: [1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8
[3] LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Australia.utf8

time zone: Australia/Sydney tzcode source: internal

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

other attached packages: [1] phyloseq_1.44.0 MicrobiomeStat_1.1.1 tibble_3.2.1 rlang_1.1.1

loaded via a namespace (and not attached): [1] bitops_1.0-7 permute_0.9-7 magrittr_2.0.3
[4] clue_0.3-65 ade4_1.7-22 matrixStats_1.0.0
[7] compiler_4.3.1 mgcv_1.9-0 systemfonts_1.0.4
[10] vctrs_0.6.3 reshape2_1.4.4 rmutil_1.1.10
[13] stringr_1.5.0 pkgconfig_2.0.3 crayon_1.5.2
[16] fastmap_1.1.1 XVector_0.40.0 labeling_0.4.3
[19] utf8_1.2.3 modeest_2.4.0 rmarkdown_2.25
[22] nloptr_2.0.3 ragg_1.2.5 xfun_0.40
[25] cachem_1.0.8 zlibbioc_1.46.0 GenomeInfoDb_1.36.4
[28] jsonlite_1.8.7 biomformat_1.28.0 rhdf5filters_1.12.1
[31] Rhdf5lib_1.22.1 parallel_4.3.1 cluster_2.1.4
[34] R6_2.5.1 bslib_0.5.1 stringi_1.7.12
[37] boot_1.3-28.1 rpart_4.1.19 jquerylib_0.1.4
[40] numDeriv_2016.8-1.1 Rcpp_1.0.11 iterators_1.0.14
[43] knitr_1.44 pacman_0.5.1 IRanges_2.34.1
[46] Matrix_1.6-1.1 splines_4.3.1 igraph_1.5.1
[49] tidyselect_1.2.0 rstudioapi_0.15.0 yaml_2.3.7
[52] vegan_2.6-4 timeDate_4022.108 codetools_0.2-19
[55] lattice_0.21-9 lmerTest_3.1-3 plyr_1.8.9
[58] Biobase_2.60.0 withr_2.5.1 evaluate_0.22
[61] stable_1.1.6 survival_3.5-7 Biostrings_2.68.1
[64] pillar_1.9.0 BiocManager_1.30.22 foreach_1.5.2
[67] stats4_4.3.1 generics_0.1.3 RCurl_1.98-1.12
[70] S4Vectors_0.38.2 ggplot2_3.4.3 munsell_0.5.0
[73] scales_1.2.1 minqa_1.2.6 timeSeries_4031.107
[76] glue_1.6.2 statip_0.2.3 tools_4.3.1
[79] data.table_1.14.8 lme4_1.1-34 spatial_7.3-17
[82] fBasics_4022.94 rhdf5_2.44.0 grid_4.3.1
[85] ape_5.7-1 colorspace_2.1-0 nlme_3.1-163
[88] GenomeInfoDbData_1.2.10 cli_3.6.1 textshaping_0.3.6
[91] fansi_1.0.4 dplyr_1.1.3 gtable_0.3.4
[94] stabledist_0.7-1 sass_0.4.7 digest_0.6.33
[97] BiocGenerics_0.46.0 ggrepel_0.9.3 farver_2.1.1
[100] htmltools_0.5.6.1 multtest_2.56.0 lifecycle_1.0.3
[103] MASS_7.3-60

zhouhj1994 commented 8 months ago

Hi,

It works fine on my R. It seems like to be the system's problem. What' the error message you've got?

On the other hand, you may try to use the LinDA package from the github to see if the mixed model works.

Anaherasm commented 8 months ago

Hello there,

I am having a similar issue. When I use the following model res.genotype <- linda(otu.tab, meta, formula = '~Genotype', alpha = 0.05, prev.cut = 0.1, lib.cut = 1000, winsor.quan = NULL)

There is no problem. However, since I have the same animal in multiple days, I should use this other code:

res.genotype <- linda(otu.tab, meta, formula = '~Genotype+(1|ID_MUESTRA)', alpha = 0.05, prev.cut = 0.1, lib.cut = 1000, winsor.quan = NULL)

And then my R session crashes.

Here is the session info:

R version 4.3.1 (2023-06-16 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=Spanish_Spain.utf8 LC_CTYPE=Spanish_Spain.utf8
[3] LC_MONETARY=Spanish_Spain.utf8 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.utf8

time zone: Europe/Madrid tzcode source: internal

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

loaded via a namespace (and not attached): [1] ade4_1.7-22 tidyselect_1.2.0 dplyr_1.1.3
[4] Biostrings_2.68.1 bitops_1.0-7 fastmap_1.1.1
[7] RCurl_1.98-1.12 phyloseq_1.44.0 promises_1.2.1
[10] digest_0.6.33 mime_0.12 lifecycle_1.0.3
[13] cluster_2.1.4 ellipsis_0.3.2 survival_3.5-7
[16] processx_3.8.2 magrittr_2.0.3 compiler_4.3.1
[19] rlang_1.1.1 tools_4.3.1 igraph_1.5.1
[22] utf8_1.2.3 data.table_1.14.8 prettyunits_1.2.0
[25] htmlwidgets_1.6.2 pkgbuild_1.4.2 plyr_1.8.9
[28] pkgload_1.3.3 miniUI_0.1.1.1 purrr_1.0.2
[31] BiocGenerics_0.46.0 grid_4.3.1 stats4_4.3.1
[34] fansi_1.0.5 urlchecker_1.0.1 profvis_0.3.8
[37] multtest_2.56.0 biomformat_1.28.0 xtable_1.8-4
[40] colorspace_2.1-0 Rhdf5lib_1.22.1 ggplot2_3.4.3
[43] scales_1.2.1 iterators_1.0.14 MASS_7.3-60
[46] cli_3.6.1 vegan_2.6-4 crayon_1.5.2
[49] generics_0.1.3 remotes_2.4.2.1 rstudioapi_0.15.0
[52] reshape2_1.4.4 sessioninfo_1.2.2 ape_5.7-1
[55] cachem_1.0.8 rhdf5_2.44.0 stringr_1.5.0
[58] splines_4.3.1 zlibbioc_1.46.0 parallel_4.3.1
[61] XVector_0.40.0 vctrs_0.6.3 devtools_2.4.5
[64] Matrix_1.6-1.1 jsonlite_1.8.7 callr_3.7.3
[67] IRanges_2.34.1 S4Vectors_0.38.2 foreach_1.5.2
[70] glue_1.6.2 codetools_0.2-19 ps_1.7.5
[73] stringi_1.7.12 gtable_0.3.4 later_1.3.1
[76] GenomeInfoDb_1.36.4 munsell_0.5.0 tibble_3.2.1
[79] pillar_1.9.0 htmltools_0.5.6.1 rhdf5filters_1.12.1
[82] GenomeInfoDbData_1.2.10 R6_2.5.1 shiny_1.7.5.1
[85] lattice_0.21-9 Biobase_2.60.0 memoise_2.0.1
[88] httpuv_1.6.11 Rcpp_1.0.11 permute_0.9-7
[91] nlme_3.1-163 mgcv_1.9-0 fs_1.6.3
[94] usethis_2.2.2 pkgconfig_2.0.3

Thank you for everything, Ana

zhouhj1994 commented 8 months ago

Does this examplework fine on your computer?

RachBioHaz commented 8 months ago

Hi, No. It still crashes R. It runs ok until it reaches formula = '~Smoke+Sex+(1|SubjectID)'. Then it crashes R.

image

Here's the session info before the line that crashes it. Cheers Rachele

R version 4.3.1 (2023-06-16 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale: [1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8 LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Australia.utf8

time zone: Australia/Sydney tzcode source: internal

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

other attached packages: [1] LinDA_0.1.0 phyloseq_1.44.0

loaded via a namespace (and not attached): [1] bitops_1.0-7 remotes_2.4.2.1 permute_0.9-7 rlang_1.1.1 magrittr_2.0.3 clue_0.3-65
[7] ade4_1.7-22 compiler_4.3.1 mgcv_1.9-0 callr_3.7.3 vctrs_0.6.4 reshape2_1.4.4
[13] rmutil_1.1.10 stringr_1.5.0 profvis_0.3.8 pkgconfig_2.0.3 crayon_1.5.2 fastmap_1.1.1
[19] XVector_0.40.0 ellipsis_0.3.2 utf8_1.2.3 modeest_2.4.0 promises_1.2.1 rmarkdown_2.25
[25] sessioninfo_1.2.2 nloptr_2.0.3 ps_1.7.5 purrr_1.0.2 xfun_0.40 zlibbioc_1.46.0
[31] cachem_1.0.8 GenomeInfoDb_1.36.4 jsonlite_1.8.7 biomformat_1.28.0 later_1.3.1 rhdf5filters_1.12.1
[37] Rhdf5lib_1.22.1 parallel_4.3.1 prettyunits_1.2.0 cluster_2.1.4 R6_2.5.1 stringi_1.7.12
[43] rpart_4.1.19 boot_1.3-28.1 pkgload_1.3.3 numDeriv_2016.8-1.1 Rcpp_1.0.11 iterators_1.0.14
[49] knitr_1.44 usethis_2.2.2 IRanges_2.34.1 httpuv_1.6.11 Matrix_1.6-1.1 splines_4.3.1
[55] igraph_1.5.1 tidyselect_1.2.0 rstudioapi_0.15.0 yaml_2.3.7 timeDate_4022.108 vegan_2.6-4
[61] codetools_0.2-19 miniUI_0.1.1.1 processx_3.8.2 pkgbuild_1.4.2 lmerTest_3.1-3 lattice_0.21-9
[67] tibble_3.2.1 plyr_1.8.9 Biobase_2.60.0 shiny_1.7.5.1 stable_1.1.6 evaluate_0.22
[73] Rtsne_0.16 survival_3.5-7 urlchecker_1.0.1 Biostrings_2.68.1 pillar_1.9.0 foreach_1.5.2
[79] stats4_4.3.1 generics_0.1.3 RCurl_1.98-1.12 S4Vectors_0.38.2 microbiome_1.22.0 ggplot2_3.4.4
[85] munsell_0.5.0 scales_1.2.1 timeSeries_4031.107 minqa_1.2.6 xtable_1.8-4 glue_1.6.2
[91] statip_0.2.3 tools_4.3.1 data.table_1.14.8 spatial_7.3-17 lme4_1.1-34 fBasics_4031.95
[97] fs_1.6.3 rhdf5_2.44.0 grid_4.3.1 tidyr_1.3.0 ape_5.7-1 devtools_2.4.5
[103] colorspace_2.1-0 nlme_3.1-163 GenomeInfoDbData_1.2.10 cli_3.6.1 fansi_1.0.5 dplyr_1.1.3
[109] gtable_0.3.4 stabledist_0.7-1 digest_0.6.33 BiocGenerics_0.46.0 ggrepel_0.9.4 htmlwidgets_1.6.2
[115] memoise_2.0.1 htmltools_0.5.6.1 multtest_2.56.0 lifecycle_1.0.3 mime_0.12 MASS_7.3-60

zhouhj1994 commented 7 months ago

You may try our CRAN package to see if it works https://cran.r-project.org/package=MicrobiomeStat

mmaechler commented 7 months ago

with about 120 package namespaces loaded .. you have an unstable situation.. and running this inside Rstudio (instead of just plain R) does add complexity. We (lme4 maintainers, @bbolker) have not seen one case where it was not sufficient to re-install enough packages and the problems were gone.

mmaechler commented 7 months ago

See also this (about updating your R packages, notably Matrix to at least 1.6-2): https://github.com/FrederickHuangLin/ANCOMBC/issues/217#issuecomment-1816154462

RachBioHaz commented 7 months ago

I have deleted the RData and history files and deleted and reinstalled all related packages from source. This seems to have sorted the issue. Thx