This function subsets the results of a Principal Coordinates Analysis (PCoA) by specified sample IDs.
Arguments
- pc.obj
A list of PCoA results, usually calculated using the
mStat_calculate_PC
function.- 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 PCoA result in pc.obj by the sample IDs. If a result is `NA` or `NULL`, it remains unchanged.
Examples
if (FALSE) { # \dontrun{
# Load required libraries
library(vegan)
data(peerj32.obj)
# Calculate PCoA
dist.obj <- mStat_calculate_beta_diversity(peerj32.obj, dist.name = c('BC'))
pc.obj <- mStat_calculate_PC(dist.obj, method = c('mds'), k = 2, dist.name = c('BC'))
# Select sample IDs
sample_ids <- sample(colnames(peerj32.obj$feature.tab), 10)
# Subset PCoA object by sample IDs
subsetted_pc.obj <- mStat_subset_PC(pc.obj, sample_ids)
} # }