Create lbm per taxa level
This commit is contained in:
parent
5cf922d69f
commit
bf571317f4
1 changed files with 35 additions and 0 deletions
35
lbm-per-taxa.R
Normal file
35
lbm-per-taxa.R
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
library(microbiome)
|
||||
library(sbm)
|
||||
|
||||
source("load-europe.R")
|
||||
|
||||
base_otu <- cpd_phyloseq_europe
|
||||
|
||||
taxoEstimateBipartiteSBM <- function(phyloseq_obj, taxonomic_level = "kingdom") {
|
||||
taxolevel_otu <- microbiome::aggregate_taxa(phyloseq_obj, taxonomic_level)
|
||||
taxolevel_mat <- phyloseq::otu_table(taxolevel_otu) |> as.matrix()
|
||||
|
||||
taxolevel_lbm <- estimateBipartiteSBM(netMat = taxolevel_mat, model = "poisson", dimLabels = c(row = taxonomic_level, col = "sample"))
|
||||
|
||||
rownames(taxolevel_lbm$probMemberships[[1]]) <- rownames(taxolevel_mat)
|
||||
rownames(taxolevel_lbm$probMemberships[[2]]) <- colnames(taxolevel_mat)
|
||||
|
||||
return(taxolevel_lbm)
|
||||
}
|
||||
|
||||
kingdom_lbm <- taxoEstimateBipartiteSBM(
|
||||
phyloseq_obj = base_otu,
|
||||
taxonomic_level = "kingdom"
|
||||
)
|
||||
|
||||
kingdom_lbm$memberships
|
||||
|
||||
phylum_lbm <- taxoEstimateBipartiteSBM(
|
||||
phyloseq_obj = base_otu,
|
||||
taxonomic_level = "phylum"
|
||||
)
|
||||
|
||||
phylum_lbm$memberships
|
||||
|
||||
mydf <- otu_table(aggregate_taxa(cpd_phyloseq_europe, "phylum"))
|
||||
library(ggplot2)
|
||||
Loading…
Add table
Reference in a new issue