This function subsets an alpha diversity object by a specified set of sample IDs.
Details
The function first checks if samIDs is logical or numeric, and if so, converts it to a character vector of sample IDs. Then, it subsets each alpha diversity index in alpha.obj by the sample IDs.
Examples
if (FALSE) { # \dontrun{
# Load required libraries
library(MicrobiomeStat)
library(vegan)
# Create example OTU table
otu.tab <- matrix(data = rpois(100, 5), nrow = 10, ncol = 10)
rownames(otu.tab) <- paste0("Taxon_", 1:10)
colnames(otu.tab) <- paste0("Sample_", 1:10)
# Calculate alpha diversity indices
alpha.obj <- mStat_calculate_alpha_diversity(x = otu.tab, alpha.name = c("shannon", "simpson",
"observed_species", "chao1", "ace", "pielou"))
# Subset alpha diversity object by sample IDs
sample_ids <- sample(colnames(otu.tab), 5)
subsetted_alpha.obj <- mStat_subset_alpha(alpha.obj, sample_ids)
} # }