escamero / mirlyn

11 stars 3 forks source link

Problems running example code #2

Closed vivenha closed 2 years ago

vivenha commented 2 years ago

Thanks for providing this package.

Following your advice, I plan to run alphawichVis to see the differences for determining the repeated iterations. I tried to use example date at first, but I met a problem when I ran the code alphawichVis(example, "Id"). The "R session Error" occurs, showing "The previous R session was abnormally terminated due to an unexpected crash".

Here is the full code.

library(mirlyn)
data(example)
example1 <- mirl(example, rep = 100)
example2 <- alphadivDF(example1)
alphawichVis(example2, "Id")

Looking forward to your reply. Thanks!

Viven

bjmt commented 2 years ago

Hi Viven,

Thanks for trying out the package. Sorry about the trouble. Unfortunately neither me or Ellen are able to recreate your issue, so I'm guessing this is happening because of something specific to your setup. When I run the code R doesn't try and take more than 1GB of memory, so I doubt it's that the function needs too much memory.

Do you mind pasting the output of sessionInfo() here? Maybe there is something we can learn from that. Since the error occurs when you try and use the plotting function it could be related to how R is trying to show graphics.

Ben

vivenha commented 2 years ago

Thanks, Ben. Here is my output of sessionInfo().

R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.7 LTS

Matrix products: default BLAS: /usr/lib/libblas/libblas.so.3.6.0 LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] vegan_2.5-7 lattice_0.20-45 permute_0.9-5 MicrobeR_0.3.2
[5] devtools_2.4.3 usethis_2.1.5 dplyr_1.0.7 reshape2_1.4.4
[9] qiime2R_0.99.6 mirlyn_1.3.1 data.table_1.14.2 phyloseq_1.38.0

loaded via a namespace (and not attached): [1] backports_1.4.1 Hmisc_4.6-0 fastmatch_1.1-3
[4] plyr_1.8.6 igraph_1.2.10 lazyeval_0.2.2
[7] splines_4.1.2 GenomeInfoDb_1.30.0 ggplot2_3.3.5
[10] rtk_0.2.6.1 digest_0.6.29 foreach_1.5.1
[13] yulab.utils_0.0.4 htmltools_0.5.2 fansi_0.5.0
[16] magrittr_2.0.1 checkmate_2.0.0 memoise_2.0.1
[19] cluster_2.1.2 DECIPHER_2.22.0 remotes_2.4.2
[22] Biostrings_2.62.0 prettyunits_1.1.1 jpeg_0.1-9
[25] colorspace_2.0-2 blob_1.2.2 ggrepel_0.9.1
[28] xfun_0.29 callr_3.7.0 crayon_1.4.2
[31] RCurl_1.98-1.5 jsonlite_1.7.2 philr_1.20.0
[34] survival_3.2-13 phangorn_2.8.1 iterators_1.0.13
[37] ape_5.6 glue_1.6.0 gtable_0.3.0
[40] zlibbioc_1.40.0 XVector_0.34.0 pkgbuild_1.3.1
[43] Rhdf5lib_1.16.0 BiocGenerics_0.40.0 scales_1.1.1
[46] DBI_1.1.2 Rcpp_1.0.7 viridisLite_0.4.0
[49] htmlTable_2.3.0 gridGraphics_0.5-1 tidytree_0.3.6
[52] foreign_0.8-81 bit_4.0.4 Formula_1.2-4
[55] stats4_4.1.2 DT_0.20 truncnorm_1.0-8
[58] httr_1.4.2 htmlwidgets_1.5.4 RColorBrewer_1.1-2
[61] ellipsis_0.3.2 factoextra_1.0.7 pkgconfig_2.0.3
[64] NADA_1.6-1.1 nnet_7.3-16 utf8_1.2.2
[67] ggplotify_0.1.0 tidyselect_1.1.1 rlang_0.4.12
[70] munsell_0.5.0 tools_4.1.2 cachem_1.0.6
[73] cli_3.1.0 generics_0.1.1 RSQLite_2.2.9
[76] ade4_1.7-18 biomformat_1.22.0 stringr_1.4.0
[79] fastmap_1.1.0 yaml_2.2.1 ggtree_3.2.1
[82] processx_3.5.2 knitr_1.37 bit64_4.0.5
[85] fs_1.5.2 purrr_0.3.4 nlme_3.1-152
[88] aplot_0.1.1 compiler_4.1.2 rstudioapi_0.13
[91] plotly_4.10.0 png_0.1-7 testthat_3.1.1
[94] zCompositions_1.3.4 treeio_1.18.1 tibble_3.1.6
[97] stringi_1.7.6 ps_1.6.0 desc_1.4.0
[100] Matrix_1.4-0 multtest_2.50.0 vctrs_0.3.8
[103] pillar_1.6.4 lifecycle_1.0.1 rhdf5filters_1.6.0
[106] bitops_1.0-7 patchwork_1.1.1 R6_2.5.1
[109] latticeExtra_0.6-29 gridExtra_2.3 IRanges_2.28.0
[112] sessioninfo_1.2.2 codetools_0.2-18 MASS_7.3-54
[115] pkgload_1.2.4 picante_1.8.2 rhdf5_2.38.0
[118] rprojroot_2.0.2 withr_2.4.3 S4Vectors_0.32.3
[121] GenomeInfoDbData_1.2.7 mgcv_1.8-38 parallel_4.1.2
[124] quadprog_1.5-8 grid_4.1.2 rpart_4.1-15
[127] ggfun_0.0.4 tidyr_1.1.4 Biobase_2.54.0
[130] base64enc_0.1-3

bjmt commented 2 years ago

Thanks. Nothing about your setup looks like it could cause this. I ran the code again on linux to be sure and it still worked OK for me. Can you try and save the alphawichVis to an object instead of plotting it right away? (E.g. test <- alphawichVis(example2, "Id") If that doesn't throw an error, then I would think that this is a more general plotting issue with R on your system (maybe specific to ggplot2, which was mirlyn uses, but maybe not).

vivenha commented 2 years ago

Thanks for your kind help. You are right, I can save the alphawichVis to an object and just have no idea how to plot it. I plan to export the data in example2 (example2 <- alphadivDF(example1)), and plot it outside of R. I appreciate it if you have any advice. Thank you!

escamero commented 2 years ago

Hi Viven,

I would recommend saving the alphadivDF object as a csv. From there, depending on your metadata, I would plot it as a categorical scatter plot (assuming your.metadata is categorical that is). In the actual visualization function, we were using geom_jitter() to show the spread of the diversity points (example in Figure 4A here: https://www.nature.com/articles/s41598-021-01636-1). However, you could also visualise the spread in diversity using a box and whisker plot or otherwise. I only ever use R for plotting but perhaps using ggplot through python or one of the graph functions in excel you could generate a plot.

vivenha commented 2 years ago

Thanks, Ellen!