reptalex / phylofactor

27 stars 9 forks source link

Error in h(simpleError(msg, call) #41

Closed chrismitbiz closed 9 months ago

chrismitbiz commented 1 year ago

The following error occured, right after it computed all phylofactors:

Error in h(simpleError(msg, call)) : s. Estimated time of completion: 2023-07-16 08:57:21.786461 error in evaluating the argument 'x' in selecting a method for function 'which': 'length = 524' in coercion to 'logical(1)' In addition: Warning message: In phylofactor::PhyloFactor(Data, tree_ur, X, frmla = Data ~ X, : Data has zeros and will receive default modification of zeros. Zeros will be replaced column wise with delta*min(x[x>0]), default delta=0.65

Using function: PF <- phylofactor::PhyloFactor(Data,tree_ur,X, frmla=Data~ X, ncores = 2, stop.early = NULL, transform.fcn=log, KS.Pthreshold = 0.01, nfactors = 13, choice = "var")

The issue started to appear after updating R and R studio. It ran fine beforehand.

Issue can be replicated using code from chapter 9.2.2 – 9.2.4 here, using the phyloseq object ps_ProjectX_2022July.

session info: R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.4.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.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.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: Australia/Melbourne tzcode source: internal

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

other attached packages: [1] ape_5.7-1 ggnewscale_0.4.9 ggtree_3.8.0 ggtreeExtra_1.10.0 colorspace_2.1-0 lubridate_1.9.2
[7] forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2 purrr_1.0.1 readr_2.1.4 tidyr_1.3.0
[13] tibble_3.2.1 tidyverse_2.0.0 ggpubr_0.6.0 ggplot2_3.4.2 phyloseq_1.44.0

loaded via a namespace (and not attached): [1] bitops_1.0-7 gridExtra_2.3 permute_0.9-7 rlang_1.1.1 magrittr_2.0.3
[6] ade4_1.7-22 compiler_4.3.0 mgcv_1.9-0 systemfonts_1.0.4 vctrs_0.6.3
[11] reshape2_1.4.4 rvest_1.0.3 pkgconfig_2.0.3 crayon_1.5.2 fastmap_1.1.1
[16] backports_1.4.1 XVector_0.40.0 utf8_1.2.3 rmarkdown_2.23 tzdb_0.4.0
[21] xfun_0.39 zlibbioc_1.46.0 aplot_0.1.10 GenomeInfoDb_1.36.1 jsonlite_1.8.7
[26] biomformat_1.28.0 rhdf5filters_1.12.1 Rhdf5lib_1.22.0 broom_1.0.5 parallel_4.3.0
[31] cluster_2.1.4 R6_2.5.1 stringi_1.7.12 car_3.1-2 Rcpp_1.0.11
[36] bookdown_0.34 iterators_1.0.14 knitr_1.43 IRanges_2.34.0 Matrix_1.6-0
[41] splines_4.3.0 igraph_1.5.0 timechange_0.2.0 tidyselect_1.2.0 rstudioapi_0.15.0
[46] abind_1.4-5 yaml_2.3.7 viridis_0.6.3 vegan_2.6-4 codetools_0.2-19
[51] lattice_0.21-8 plyr_1.8.8 treeio_1.24.1 Biobase_2.60.0 withr_2.5.0
[56] evaluate_0.21 gridGraphics_0.5-1 survival_3.5-5 phylofactor_0.0.1 xml2_1.3.5
[61] Biostrings_2.68.1 pillar_1.9.0 carData_3.0-5 foreach_1.5.2 stats4_4.3.0
[66] ggfun_0.1.1 generics_0.1.3 RCurl_1.98-1.12 S4Vectors_0.38.1 hms_1.1.3
[71] tidytree_0.4.4 munsell_0.5.0 scales_1.2.1 glue_1.6.2 lazyeval_0.2.2
[76] tools_4.3.0 data.table_1.14.8 webshot_0.5.5 ggsignif_0.6.4 rhdf5_2.44.0
[81] grid_4.3.0 patchwork_1.1.2 nlme_3.1-162 GenomeInfoDbData_1.2.10 cli_3.6.1
[86] kableExtra_1.3.4 fansi_1.0.4 viridisLite_0.4.2 svglite_2.1.1 gtable_0.3.3
[91] yulab.utils_0.0.6 rstatix_0.7.2 digest_0.6.33 BiocGenerics_0.46.0 ggplotify_0.1.1
[96] htmltools_0.5.5 multtest_2.56.0 lifecycle_1.0.3 httr_1.4.6 MASS_7.3-60

khalidtab commented 9 months ago

I'm having the same issue. I tried to see if it is an issue with the code I wrote, but it seems to occur in the Tutorial material as well. The code works fine if I am looking for only 1 factor, but once I choose any number higher than that, I get the same error.

Screenshot 2023-11-16 at 8 55 45 AM

R version 4.3.1 (2023-06-16) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Sonoma 14.0

khalidtab commented 9 months ago

I just installed it in a Docker image, same issue.

sessionInfo() R version 4.3.2 (2023-10-31) Platform: x86_64-conda-linux-gnu (64-bit) Running under: Debian GNU/Linux 12 (bookworm)

Matrix products: default BLAS/LAPACK: /opt/conda/envs/phylofactor/lib/libopenblasp-r0.3.24.so; LAPACK version 3.11.0

locale: [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

time zone: Etc/UTC tzcode source: system (glibc)

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

other attached packages: [1] phylofactor_0.0.1 Matrix_1.6-3 data.table_1.14.8
[4] magrittr_2.0.3 ggtree_3.8.0 Biostrings_2.68.1
[7] GenomeInfoDb_1.36.1 XVector_0.40.0 IRanges_2.34.1
[10] S4Vectors_0.38.1 BiocGenerics_0.46.0 treeio_1.24.1
[13] TreeTools_1.10.0 ape_5.7-1 data.tree_1.1.0
[16] lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1
[19] dplyr_1.1.3 purrr_1.0.2 readr_2.1.4
[22] tidyr_1.3.0 tibble_3.2.1 tidyverse_2.0.0
[25] igraph_1.5.1 ggraph_2.1.0 ggplot2_3.4.4

loaded via a namespace (and not attached): [1] Rdpack_2.6 bitops_1.0-7 gridExtra_2.3
[4] remotes_2.4.2.1 rlang_1.1.2 compiler_4.3.2
[7] callr_3.7.3 vctrs_0.6.4 profvis_0.3.8
[10] pkgconfig_2.0.3 crayon_1.5.2 fastmap_1.1.1
[13] ellipsis_0.3.2 utf8_1.2.4 promises_1.2.1
[16] sessioninfo_1.2.2 tzdb_0.4.0 ps_1.7.5
[19] bit_4.0.5 zlibbioc_1.46.0 cachem_1.0.8
[22] aplot_0.2.2 jsonlite_1.8.7 later_1.3.1
[25] tweenr_2.0.2 parallel_4.3.2 prettyunits_1.2.0
[28] R6_2.5.1 stringi_1.8.1 pkgload_1.3.3
[31] Rcpp_1.0.11 usethis_2.2.2 R.utils_2.12.2
[34] httpuv_1.6.12 R.cache_0.16.0 timechange_0.2.0
[37] tidyselect_1.2.0 viridis_0.6.4 miniUI_0.1.1.1
[40] curl_5.1.0 processx_3.8.2 pkgbuild_1.4.2
[43] lattice_0.22-5 shiny_1.7.5.1 withr_2.5.2
[46] desc_1.4.2 gridGraphics_0.5-1 urlchecker_1.0.1
[49] polyclip_1.10-6 pillar_1.9.0 ggfun_0.1.3
[52] generics_0.1.3 vroom_1.6.4 rprojroot_2.0.4
[55] RCurl_1.98-1.13 hms_1.1.3 munsell_0.5.0
[58] scales_1.2.1 tidytree_0.4.5 PlotTools_0.3.0
[61] xtable_1.8-4 glue_1.6.2 lazyeval_0.2.2
[64] tools_4.3.2 fs_1.6.3 graphlayouts_1.0.2
[67] fastmatch_1.1-4 tidygraph_1.2.3 grid_4.3.2
[70] rbibutils_2.2.16 devtools_2.4.5 colorspace_2.1-0
[73] nlme_3.1-163 GenomeInfoDbData_1.2.10 patchwork_1.1.3
[76] ggforce_0.4.1 cli_3.6.1 fansi_1.0.5
[79] viridisLite_0.4.2 gtable_0.3.4 R.methodsS3_1.8.2
[82] yulab.utils_0.1.0 digest_0.6.33 ggrepel_0.9.4
[85] ggplotify_0.1.2 htmlwidgets_1.6.2 farver_2.1.1
[88] memoise_2.0.1 htmltools_0.5.7 R.oo_1.25.0
[91] lifecycle_1.0.4 mime_0.12 bit64_4.0.5
[94] MASS_7.3-60

khalidtab commented 9 months ago

Been working on this all morning. The issue appears to be in this line of the main PhyloFactor function: output$bins = bins(output$basis), as I get the same error when surrounded by a tryCatch() function.

<simpleError in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'which': 'length = 140' in coercion to 'logical(1)'>

UPDATE 1: it is this specific line that is causing the issue, which is part of find.unsplit.Grps function:

inx <- which(unlist(lapply(ss, function(x, y) {all(y %in% x && x %in% y)

UPDATE 2: By splitting this step into two different steps,

 comparison_results <- lapply(ss, function(x, y) {
    in_x <- all(y %in% x)
    in_y <- all(x %in% y)
    return(in_x && in_y)
  }, y = ind)
  print(comparison_results)

inx <- which(unlist(comparison_results))

The issue is taken care of! Will submit a pull request shortly.

reptalex commented 9 months ago

Hey Chris and Khaled!

Thank you both for bringing this bug to my attention.

Khaled - thank you for your detailed efforts to debug this. From my end, I ended up publishing a geopolitically impactful paper on the origins of SARS-CoV-2, started getting stalked and approached by strange people, received all manners of unusual phishing attempts (including highly targeted phishing links sent directly to me from members of the Chinese Academy of Sciences who later claimed they never sent the messages), and somewhere in this process my computer was hacked, operating system corrupted, and all my files deleted.

I'll see if/when I can get back to this project and make the fix, which sounds like it might be due to an R update in how which() treats vectors of logicals or possibly some prior step in the construction of x and y.

I thought you might appreciate the little story of the odyssey behind this open source package and some of the challenges with its maintenance! I'm very grateful to know people are still using it and hope I can get this fixed for you soon :-)

Best, Alex

reptalex commented 9 months ago

P.S. In case you're interested in the paper that caused the odyssey, here it is!

https://www.biorxiv.org/content/biorxiv/early/2022/10/20/2022.10.18.512756.full.pdf

reptalex commented 9 months ago

Oh, and you might appreciate this (if you're appreciating the odyssey behind the open source code). I also received a bunch of death threats, including packages shipped to my house connected directly to the death threats. At the very last death threat, they said they were going to murder me in the next week and I responded with a yawn emoji.

Not dead yet! Hope to get back to phylofactor soon :-)

khalidtab commented 9 months ago

Oh Dear god I am so sorry to hear this!

FYI: not only I'm still using PhyloFactor, I used it to get evidence for a major question in dental microbiology research that dental researchers have been hypothesizing about for decades but never found the answer for until PhyloFactor. So, yes, this package is definitely still being used, and for me, its functions are irreplaceable!

chrismitbiz commented 9 months ago

RMIT Classification: Trusted

Hi Alex, Thanks for letting us know and really sorry to hear. I had no idea. That must have been stressful.

I read your fascinating article and then an article by Kesley Piper at Vox. Sounds like you created quite a stir and scientific (and political) discourse, which can only be good, ha? Hope you are ok.

All the best


From: Alex Washburne @.> Sent: Saturday, November 18, 2023 8:14 am To: reptalex/phylofactor @.> Cc: Christian Krohn @.>; Author @.> Subject: Re: [reptalex/phylofactor] Error in h(simpleError(msg, call) (Issue #41)

P.S. In case you're interested in the paper that caused the odyssey, here it is!

https://www.biorxiv.org/content/biorxiv/early/2022/10/20/2022.10.18.512756.full.pdf

— Reply to this email directly, view it on GitHubhttps://github.com/reptalex/phylofactor/issues/41#issuecomment-1817113153, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJZP6DUTBTWZD5JAJDZTQ4LYE7HOXAVCNFSM6AAAAAA2LRZPE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJXGEYTGMJVGM. You are receiving this because you authored the thread.Message ID: @.***>

reptalex commented 9 months ago

@khalidtab I've merged your fix - thank you so much for taking the time to study this error & make the correction!

If either of you want someone who puts the peer in peer-review, don't hesitate to list me. Happy to give a constructive look at your next paper and excited to hear you're using this tool!

Best, Alex

chrismitbiz commented 6 months ago

RMIT Classification: Trusted

Hi Alex, Thank you both for the fix.

Here the latest paper using phylofactor https://doi.org/10.1016/j.watres.2024.121354. 😊.

Cheers, Chris

From: Alex Washburne @.> Reply to: reptalex/phylofactor @.> Date: Friday, 8 December 2023 at 3:27 pm To: reptalex/phylofactor @.> Cc: Christian Krohn @.>, Author @.***> Subject: Re: [reptalex/phylofactor] Error in h(simpleError(msg, call) (Issue #41)

@khalidtabhttps://github.com/khalidtab I've merged your fix - thank you so much for taking the time to study this error & make the correction!

If either of you want someone who puts the peer in peer-review, don't hesitate to list me. Happy to give a constructive look at your next paper and excited to hear you're using this tool!

Best, Alex

— Reply to this email directly, view it on GitHubhttps://github.com/reptalex/phylofactor/issues/41#issuecomment-1846529713, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJZP6DSZHXUOPVCE6Y22F43YIKJJDAVCNFSM6AAAAAA2LRZPE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBWGUZDSNZRGM. You are receiving this because you authored the thread.Message ID: @.***>