@gauriipaul @trispham1223 @gugulethusk @graceekalle
Although there are many definitions of the core microbiome, this code will give you the core microbiome for the “Common core” shown below from Risely (2020).
In this example, we define the core as being found in at least 70% of samples (common but also arbitrary) in a given group. Note that this analysis requires the microbiome library.
More here: Core microbiome
In this code, I used the oral contraceptive dataset.
# Install (if needed) and load microbiome library
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(version = "3.21")
library(BiocManager)
BiocManager::install("microbiome")
library(microbiome)
# Load in library objects
oc<-readRDS("oc.RDS")
oc_counts<-readRDS("oc_counts.RDS")
oc_no948N2<-readRDS("oc_no948N2.RDS")
oc_no948N2_counts<-readRDS("oc_no948N2_counts.RDS")
#Subset phyloseq object into the categories you want to look for the core microbiome in (ex. healthy vs disease state samples)
#Using count data
user_samples <- subset_samples(oc_counts, treatment=="User")
control_samples <- subset_samples(oc_counts, treatment=="Control")
# Calculate compositional version of the data
# (relative abundances)
rel.user_samples <- microbiome::transform(user_samples, "compositional")
rel.control_samples <- microbiome::transform(control_samples, "compositional")
#names of core microbiome:
#setting to found in 70%
core.taxa.standard.user_samples <- core_members(rel.user_samples, detection = 0, prevalence = 70/100)
core.taxa.standard.control_samples <- core_members(rel.control_samples, detection = 0, prevalence = 70/100)
core.taxa.standard.user_samples
core.taxa.standard.control_samples
The results are given as a list of ASVs.
> core.taxa.standard.user_samples
[1] "ASV_581" "ASV_1164" "ASV_1496" "ASV_2803" "ASV_2894" "ASV_3930" "ASV_4663" "ASV_5156"
> core.taxa.standard.control_samples
[1] "ASV_148" "ASV_481" "ASV_581" "ASV_1164" "ASV_1496" "ASV_1794" "ASV_2478" "ASV_2678" "ASV_2894"
[10] "ASV_3088" "ASV_3561" "ASV_4056"