This function subsets a list of distance matrices by a specified set of sample IDs.
Arguments
- dist.obj
Distance matrix between samples, usually calculated using
mStat_calculate_beta_diversity
function. If NULL, beta diversity will be automatically computed fromdata.obj
usingmStat_calculate_beta_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.
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 distance matrix in dist.obj by the sample IDs. If a matrix is `NA` or `NULL`, it remains unchanged.
Examples
if (FALSE) { # \dontrun{
# Load required libraries
library(vegan)
data(peerj32.obj)
# Calculate beta diversity
dist.obj <- mStat_calculate_beta_diversity(peerj32.obj, dist.name = c('BC', 'Jaccard'))
# Select sample IDs
sample_ids <- sample(colnames(peerj32.obj$feature.tab), 10)
# Subset distance object by sample IDs
subsetted_dist.obj <- mStat_subset_dist(dist.obj, sample_ids)
} # }