Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularity analysis using Dormann and Strauss, 2014 method #16

Closed
Danvel91 opened this issue Jul 26, 2023 · 2 comments
Closed

Modularity analysis using Dormann and Strauss, 2014 method #16

Danvel91 opened this issue Jul 26, 2023 · 2 comments

Comments

@Danvel91
Copy link

Danvel91 commented Jul 26, 2023

Hi!
I am conducting an ecological analysis of a metavirome using the computeModules function. I´ve been able to compute the modules and plot them, but I always get warning messages saying that the matrix length of the modules object and the original web are not same, and because of that I believe that not all nodes are displayed. I attach you my code and the warning messages:

otus.net <- graph.data.frame(links.net, nodes.net, directed = FALSE)

otus.net.adj <- get.adjacency(otus.net, sparse = FALSE, names = TRUE)
modules.net <- computeModules(otus.net.adj, deep = FALSE, tolerance = 1e-10)

plotModuleWeb(modules.net, plotModules = TRUE,
              rank = FALSE, weighted = FALSE, displayAlabels = TRUE,
              displayBlabels = TRUE, labsize = 1, xlabel = "", ylabel = "",
              square.border = "white", fromDepth = 0, upToDepth = -1)

I´ve used upToDepth = -1 with the idea of plotting all modules (If upToDepth is smaller
than fromDepth, all modules are plot)

Warning messages:
1: In dim(slot(moduleWebObject, "originalWeb")) == 0 || dim(slot(moduleWebObject, :
'length(x) = 2 > 1' in coercion to 'logical(1)'
2: In dim(slot(moduleWebObject, "originalWeb")) == 0 || dim(slot(moduleWebObject, :
'length(x) = 2 > 1' in coercion to 'logical(1)'
3: In dim(slot(moduleWebObject, "originalWeb")) == 0 || dim(slot(moduleWebObject, :
'length(x) = 2 > 1' in coercion to 'logical(1)'

Info about R session:

sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

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    

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

other attached packages:
 [1] pheatmap_1.0.12      RColorBrewer_1.1-3   forcats_1.0.0       
 [4] stringr_1.5.0        dplyr_1.1.0          purrr_1.0.1         
 [7] readr_2.1.4          tidyr_1.3.0          tibble_3.1.8        
[10] tidyverse_1.3.2      readxl_1.4.2         dendextend_1.17.1   
[13] factoextra_1.0.7     ggplot2_3.4.1        cluster_2.1.4       
[16] igraph_1.4.0         relaimpo_2.2-6       mitools_2.4         
[19] survey_4.1-1         survival_3.5-0       Matrix_1.5-3        
[22] boot_1.3-28.1        MASS_7.3-58.2        bipartite_2.18      
[25] sna_2.7-1            network_1.18.1       statnet.common_4.8.0
[28] vegan_2.6-4          lattice_0.20-45      permute_0.9-7       

loaded via a namespace (and not attached):
 [1] viridis_0.6.2       httr_1.4.4          maps_3.4.1         
 [4] jsonlite_1.8.4      viridisLite_0.4.1   splines_4.2.2      
 [7] modelr_0.1.10       dotCall64_1.0-2     assertthat_0.2.1   
[10] googlesheets4_1.0.1 cellranger_1.1.0    ggrepel_0.9.3      
[13] pillar_1.8.1        backports_1.4.1     glue_1.6.2         
[16] rvest_1.0.3         colorspace_2.1-0    pkgconfig_2.0.3    
[19] broom_1.0.3         haven_2.5.1         corpcor_1.6.10     
[22] scales_1.2.1        tzdb_0.3.0          timechange_0.2.0   
[25] googledrive_2.0.0   mgcv_1.8-41         generics_0.1.3     
[28] ellipsis_0.3.2      withr_2.5.0         cli_3.6.0          
[31] crayon_1.5.2        magrittr_2.0.3      fs_1.6.1           
[34] fansi_1.0.4         nlme_3.1-162        xml2_1.3.3         
[37] tools_4.2.2         hms_1.1.2           gargle_1.3.0       
[40] lifecycle_1.0.3     reprex_2.0.2        munsell_0.5.0      
[43] compiler_4.2.2      rlang_1.0.6         rstudioapi_0.14    
[46] spam_2.9-1          gtable_0.3.1        DBI_1.1.3          
[49] R6_2.5.1            gridExtra_2.3       lubridate_1.9.2    
[52] utf8_1.2.3          stringi_1.7.12      parallel_4.2.2     
[55] Rcpp_1.0.10         fields_14.1         vctrs_0.5.2        
[58] dbplyr_2.3.0        tidyselect_1.2.0    coda_0.19-4 

Is this related with the window size or with the length of the matrix? Many thanks in advance for your support,

Best

@rubenroos
Copy link

Hi!

I'm getting a similar error when running plotModuleWeb follwing the example code for computeModules() (https://rdrr.io/cran/bipartite/man/computeModules.html) and similar issues when using the script and data provided by Marini et al. 2019 (https://besjournals.onlinelibrary.wiley.com/action/downloadSupplement?doi=10.1111%2F1365-2664.13337&file=jpe13337-sup-0001-Supinfo.doc).

data(small1976)
(res <- computeModules(small1976)) 
plotModuleWeb(res)
Error in dim(slot(moduleWebObject, "originalWeb")) == 0 || dim(slot(moduleWebObject, :
'length = 2' in coercion to 'logical(1)'

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] C

time zone: Europe/Oslo
tzcode source: internal

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

other attached packages:
 [1] visNetwork_2.1.2     igraph_1.5.1         bipartite_2.18       sna_2.7-1            network_1.18.1       statnet.common_4.9.0
 [7] vegan_2.6-4          lattice_0.21-8       permute_0.9-7        reshape_0.8.9       

loaded via a namespace (and not attached):
 [1] Matrix_1.5-4.1    jsonlite_1.8.7    compiler_4.3.1    maps_3.4.1        Rcpp_1.0.11       parallel_4.3.1    cluster_2.1.4     splines_4.3.1    
 [9] yaml_2.3.7        fastmap_1.1.1     coda_0.19-4       plyr_1.8.8        knitr_1.43        htmlwidgets_1.6.2 MASS_7.3-60       dotCall64_1.0-2  
[17] tibble_3.2.1      pillar_1.9.0      rlang_1.1.1       utf8_1.2.3        xfun_0.40         viridisLite_0.4.2 cli_3.6.1         magrittr_2.0.3   
[25] mgcv_1.8-42       digest_0.6.33     grid_4.3.1        spam_2.9-1        lifecycle_1.0.3   nlme_3.1-162      fields_15.2       vctrs_0.6.3      
[33] evaluate_0.21     glue_1.6.2        fansi_1.0.4       rmarkdown_2.24    ellipsis_0.3.2    tools_4.3.1       pkgconfig_2.0.3   htmltools_0.5.6

Many thanks for the support!
Best wishes

@cdormann
Copy link
Contributor

cdormann commented Dec 7, 2023

Hm. So I think this issue is fixed with the 2.19 release. At least I cannot reproduce any of the errors, and it works "perfectly" with both the small1976 example and a larger memmott1999 data set (both in the default and the deep=T setting with method="DormannStrauss"). Please re-open issue if problem still exists! Reproducible example like that of rubenroos much appreciated!

@cdormann cdormann closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants