Adding defaults to bm utils

This commit is contained in:
Louis 2026-01-23 17:02:27 +01:00
parent e53e3740f6
commit df319af88d

View file

@ -73,7 +73,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)) {
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) {
removed_root <- FALSE
# Detect if first rank (higher) is fully collapsed
if (nrow(per_taxa_networks[[1]]) <= 1L) {
@ -88,16 +88,16 @@ bm_propagate_taus_all_models <- function(phyloseq_data, rank_id_start = 2, targe
first_model <- BM_poisson(
membership_type = "LBM",
adj = per_taxa_networks[[net_id_start]], # Account for the root
verbosity = 2,
verbosity = verbosity,
plotting = "",
ncores = 1L
ncores = ncores
)
first_model$estimate()
}
propagated_models <- lapply(seq_along(first_model$ICL), function(current_q) {
if (!is.na(first_model$ICL[current_q])) {
bm_propagate_taus_Q_next_level(phyloseq_data = phyloseq_data, first_model = first_model, per_taxa_networks = per_taxa_networks, Q = current_q, removed_root = removed_root, rank_id_start = rank_id_start, target_rank_id = target_rank_id)
bm_propagate_taus_Q_next_level(phyloseq_data = phyloseq_data, first_model = first_model, per_taxa_networks = per_taxa_networks, Q = current_q, removed_root = removed_root, rank_id_start = rank_id_start, target_rank_id = target_rank_id, sd_noise = sd_noise)
} else {
return(NA)
}
@ -108,9 +108,9 @@ bm_propagate_taus_all_models <- function(phyloseq_data, rank_id_start = 2, targe
new_model <- BM_poisson(
membership_type = "LBM",
adj = per_taxa_networks[[target_net_id]], # Account for the root
verbosity = 6,
verbosity = verbosity,
plotting = "",
ncores = 1L
ncores = ncores
)
lapply(seq_along(propagated_models), function(current_q) {