From 97b4a435973cac868b3c8ccd5e4d865f4e984888 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 19 Feb 2026 10:40:01 +0100 Subject: [PATCH] Usage of Blockmodels with poisson covariates to correct sequencing effort --- blockmodels_correct_sampling_effort.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 blockmodels_correct_sampling_effort.R diff --git a/blockmodels_correct_sampling_effort.R b/blockmodels_correct_sampling_effort.R new file mode 100644 index 0000000..8b29eb4 --- /dev/null +++ b/blockmodels_correct_sampling_effort.R @@ -0,0 +1,16 @@ +library(blockmodels) +library(phyloseq) +library(biomformat) +source("utils.R") + +the_data <- import_biom("data/ravel/ravel.biom") + + +per_taxa_networks <- collapse_otu_at_taxo(the_data) + +covar_mat <- t(colSums(per_taxa_networks[[2]]) %*% t(rep(1, nrow(per_taxa_networks[[2]])))) + +fitted_model <- BM_poisson_covariates("LBM", adj = per_taxa_networks[[2]], covariates = list(covar_mat)) +fitted_model$estimate() + +fitted_model$model_parameters[[which.max(fitted_model$ICL)]]