From d46e7e891378dbd097048c206e9adf6a9b64e041 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 27 Jan 2026 09:52:03 +0100 Subject: [PATCH] Adding autosave capabilities --- utils-bm-seq.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/utils-bm-seq.R b/utils-bm-seq.R index 6964c2a..5e163d2 100644 --- a/utils-bm-seq.R +++ b/utils-bm-seq.R @@ -63,9 +63,11 @@ bm_estimate_with_inits <- function(bm_model, reinitialization_effort = 1) { cat("With ascending number of groups\n") ra <- bm_model$estim_ascend(reinitialization_effort, changing_effort) + bm_model$save_now() # Using blockmodels save capabilities cat("With descending number of groups\n") rb <- bm_model$estim_descend(reinitialization_effort) + bm_model$save_now() l <- ra || rb n <- n + 1 @@ -73,7 +75,7 @@ bm_estimate_with_inits <- function(bm_model, reinitialization_effort = 1) { } } -bm_propagate_taus_all_models <- function(phyloseq_data, rank_id_start = 2, target_rank_id = rank_id_start + 1, first_model = NULL, per_taxa_networks = collapse_otu_at_taxo(phyloseq_data), sd_noise = 0.001, ncores = parallelly::availableCores(), verbosity = 2L) { +bm_propagate_taus_all_models <- function(phyloseq_data, rank_id_start = 2, target_rank_id = rank_id_start + 1, first_model = NULL, per_taxa_networks = collapse_otu_at_taxo(phyloseq_data), sd_noise = 0.001, ncores = parallelly::availableCores(), verbosity = 2L, autosave = character(0)) { removed_root <- FALSE # Detect if first rank (higher) is fully collapsed if (nrow(per_taxa_networks[[1]]) <= 1L) { @@ -81,7 +83,6 @@ bm_propagate_taus_all_models <- function(phyloseq_data, rank_id_start = 2, targe removed_root <- TRUE per_taxa_networks <- per_taxa_networks[-1] } - result_list <- list() # Init net_id_start <- ifelse(removed_root, rank_id_start - 1, rank_id_start) if (missing(first_model)) { @@ -90,7 +91,8 @@ bm_propagate_taus_all_models <- function(phyloseq_data, rank_id_start = 2, targe adj = per_taxa_networks[[net_id_start]], # Account for the root verbosity = verbosity, plotting = "", - ncores = ncores + ncores = ncores, + autosave = autosave ) first_model$estimate() } @@ -110,7 +112,8 @@ bm_propagate_taus_all_models <- function(phyloseq_data, rank_id_start = 2, targe adj = per_taxa_networks[[target_net_id]], # Account for the root verbosity = verbosity, plotting = "", - ncores = ncores + ncores = ncores, + autosave = autosave ) lapply(seq_along(propagated_models), function(current_q) {