Skip to contents

This function subsets an alpha diversity object by a specified set of sample IDs.

Usage

mStat_subset_alpha(alpha.obj, samIDs)

Arguments

alpha.obj

Alpha diversity object generated by mStat_calculate_alpha_diversity.

samIDs

A vector of sample IDs to subset by. This can be a logical vector, a numeric vector, or a character vector of sample IDs.

Value

A list of subsetted alpha diversity indices.

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)
} # }