adw96 / DivNet

diversity estimation under ecological networks
83 stars 18 forks source link

testDiversity does not work for beta diversity measures #67

Closed mmp3 closed 3 years ago

mmp3 commented 3 years ago

Hello,

First, thank you for the statistically rigorous methods for diversity analysis and the accompanying easy-to-use and well-documented packages breakaway and DivNet! It has been very enjoyable to follow your work and use these tools.

Problem DivNet::testDiversity throws an error for beta diversity measures, i.e. when h0 = "bray-curtis" or h0="euclidean".

Minimal reproducible example From the Basic Usage section of the DivNet github page:

library(DivNet)
library(phyloseq)
data(Lee)
divnet_phylum <-  divnet(tax_glom(Lee, taxrank="Phylum"),
                         X = "char",
                         ncores = 4)

and now we do the test for a beta-diversity measure:

testDiversity(divnet_phylum , h0 = "bray-curtis")

which gives error message:

Hypothesis testing:
Error in X[consider, ] : (subscript) logical subscript too long

Version information:

> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.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

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

other attached packages:
[1] foreach_1.5.1   DivNet_0.3.7    breakaway_4.7.3 phyloseq_1.34.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6          ape_5.5             lattice_0.20-44
 [4] tidyr_1.1.3         prettyunits_1.1.1   Biostrings_2.58.0
 [7] assertthat_0.2.1    utf8_1.2.1          R6_2.5.0
[10] plyr_1.8.6          stats4_4.0.3        ggplot2_3.3.3
[13] pillar_1.6.0        zlibbioc_1.36.0     rlang_0.4.11
[16] progress_1.2.2      rstudioapi_0.13     minqa_1.2.4
[19] data.table_1.14.0   nloptr_1.2.2.2      vegan_2.5-7
[22] S4Vectors_0.28.1    mvnfast_0.2.5.1     Matrix_1.3-3
[25] splines_4.0.3       lme4_1.1-26         statmod_1.4.35
[28] stringr_1.4.0       igraph_1.2.6        munsell_0.5.0
[31] compiler_4.0.3      pkgconfig_2.0.3     BiocGenerics_0.36.1
[34] multtest_2.46.0     mgcv_1.8-33         biomformat_1.18.0
[37] tidyselect_1.1.1    tibble_3.1.2        IRanges_2.24.1
[40] codetools_0.2-18    fansi_0.4.2         permute_0.9-5
[43] crayon_1.4.1        dplyr_1.0.6         MASS_7.3-54
[46] rhdf5filters_1.2.1  grid_4.0.3          nlme_3.1-152
[49] jsonlite_1.7.2      gtable_0.3.0        lifecycle_1.0.0
[52] DBI_1.1.1           magrittr_2.0.1      scales_1.1.1
[55] stringi_1.6.2       XVector_0.30.0      reshape2_1.4.4
[58] doParallel_1.0.16   ellipsis_0.3.2      generics_0.1.0
[61] vctrs_0.3.8         boot_1.3-27         Rhdf5lib_1.12.1
[64] iterators_1.0.13    tools_4.0.3         ade4_1.7-16
[67] Biobase_2.50.0      glue_1.4.2          purrr_0.3.4
[70] hms_1.0.0           abind_1.4-5         parallel_4.0.3
[73] survival_3.2-7      colorspace_2.0-1    rhdf5_2.34.0
[76] cluster_2.1.0
ailurophilia commented 3 years ago

Hi – thanks for bringing this up! testDiversity is a wrapper for breakaway::betta(), which performs hypothesis testing for alpha diversities, so it is breaking because it cannot handle beta diversities. We will update so that error messages are more informative. Thanks!

ailurophilia commented 3 years ago

Update – we will be adding a test for beta diversity to testDiversity(). Stay tuned! Thanks!

ailurophilia commented 3 years ago

Hi again – thanks for your patience! DivNet now has a testBetaDiversity function for beta diversity analyses as well as a new vignette outlining how we recommend setting up beta diversity analyses in DivNet. Thanks!