diff --git a/code/applications/herbivores/01_herbivores_prepare_data.R b/code/applications/herbivores/01_herbivores_prepare_data.R index d501928..7d60018 100644 --- a/code/applications/herbivores/01_herbivores_prepare_data.R +++ b/code/applications/herbivores/01_herbivores_prepare_data.R @@ -23,12 +23,15 @@ binary_interaction_data <- interaction_data %>% insectspecies, sep = "_" ) - ) %>% select(-c(insectorder:plantspecies, interquant)) + ) %>% + select(-c(insectorder:plantspecies, interquant)) netlist <- lapply(vec_web, function(web) { web_interaction_data <- binary_interaction_data[which(binary_interaction_data[["web"]] == web), ] - incidence_matrix <- table(web_interaction_data[["plantname"]], - web_interaction_data[["insectname"]]) + incidence_matrix <- (table( + web_interaction_data[["plantname"]], + web_interaction_data[["insectname"]] + ) != 0L) * 1L }) names(netlist) <- vec_web diff --git a/code/applications/herbivores/02_herbivores_clustering.R b/code/applications/herbivores/02_herbivores_clustering.R index 9027e7e..fb70166 100644 --- a/code/applications/herbivores/02_herbivores_clustering.R +++ b/code/applications/herbivores/02_herbivores_clustering.R @@ -2,6 +2,9 @@ library(colSBM) library(dplyr) library(tidyr) library(here) +library(future.apply) + +plan(multicore) application_name <- "herbivores" @@ -55,14 +58,15 @@ list_collection <- clusterize_bipartite_networks( nb_cores = parallelly::availableCores(omit = 1L) %/% 2L, verbosity = 2L, plot_details = 0L, - backend = "parallel" - ) + backend = "future" + ), + fit_opts = list(max_vem_steps = 500L) ) save_file <- file.path( save_folder, paste0( sprintf("%s_collection_", application_name), - model, "_", start_time, ".Rds" + model, "_", start_time, "maxsteps_500.Rds" ) )