Skip to contents

This function calculates the Principal Coordinates based on different methods such as Metric Multi-Dimensional Scaling (MDS), Non-Metric Multi-Dimensional Scaling (NMDS)

Usage

mStat_calculate_PC(dist.obj, method = c("mds"), k = 2, dist.name = NULL)

Arguments

dist.obj

Distance matrix between samples, usually calculated using mStat_calculate_beta_diversity function. If NULL, beta diversity will be automatically computed from data.obj using mStat_calculate_beta_diversity.

method

A character vector specifying which methods to use for calculating PCoA. Supported methods are "mds" (MDS), "nmds" (NMDS)

k

An integer specifying the number of principal coordinates to retain. Default is 2.

dist.name

A character vector specifying which beta diversity indices to calculate. Supported indices are "BC" (Bray-Curtis), "Jaccard", "UniFrac" (unweighted UniFrac), "GUniFrac" (generalized UniFrac), "WUniFrac" (weighted UniFrac), and "JS" (Jensen-Shannon divergence). If a name is provided but the corresponding object does not exist within dist.obj, it will be computed internally. If the specific index is not supported, an error message will be returned. to be used from the dist.obj list. Default is 'BC'.

Value

A list containing the PCoA results for each specified method and distance matrix. The results are named with the method's abbreviation.

Examples

if (FALSE) { # \dontrun{
library(vegan)
data(peerj32.obj)
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'))
} # }