addMDS: Perform multi-dimensional scaling (MDS)

getMDSR Documentation

Perform multi-dimensional scaling (MDS)

Description

Perform multi-dimensional scaling (MDS) also know as Principal Coordinate Analysis (PCoA). These functions are wrappers for scater::calculateMDS.

Usage

getMDS(x, ...)

addMDS(x, ...)

## S4 method for signature 'SingleCellExperiment'
addMDS(x, name = "MDS", ...)

## S4 method for signature 'SingleCellExperiment'
getMDS(x, assay.type = "counts", ...)

## S4 method for signature 'TreeSummarizedExperiment'
getMDS(x, assay.type = "counts", ...)

Arguments

x

a SummarizedExperiment object.

...

additional arguments.

  • FUN: Function. A function that is applied to calculate dissimilarity. (Default: getDissimilarity)

    \item \code{subset.result}: \code{Logical result}. Specifies whether to
    subset \code{x} to match the result if some samples were removed during
    calculation. (Default: \code{TRUE})
    
name

Character scalar. A name for the reducedDim() where results will be stored. (Default: "MDS")

assay.type

Character scalar. Specifies the name of assay used in calculation. (Default: "counts")

Details

These functions are wrappers for scater::calculateMDS and scater::runMDS. While getMDS returns the results, addMDS adds them to reducedDim(x). The difference is that these functions apply microbiome-specific options such as getDissimilarity function by default.

See scater::calculateMDS for details.

Value

getMDS returns a MDS results. addMDS returns a x with MDS results added to its reducedDim(x, name).

See Also

scater::calculateMDS and getDissimilarity

Examples

library(mia)
library(scater)
library(patchwork)

data(GlobalPatterns)
tse <- GlobalPatterns

# Calculate PCoA with Bray-Curtis dissimilarity
tse <- transformAssay(tse, method = "relabundance")
tse <- addMDS(tse, assay.type = "relabundance", method = "bray")

# Calculate PCoA with Unifrac and rarefaction. (Note: increase iterations)
tse <- addMDS(tse, method = "unifrac", name = "unifrac")

# Calculate PCoA with Unifrac and rarefaction. (Note: increase iterations)
tse <- addMDS(tse, method = "unifrac", name = "unifrac_rare", niter = 2L)

# Visualize results
p1 <- plotReducedDim(tse, "unifrac", colour_by = "SampleType") +
    labs(title = "Not rarefied")
p2 <- plotReducedDim(tse, "unifrac_rare", colour_by = "SampleType") +
    labs(title = "Rarefied")
p1 + p2


FelixErnst/mia documentation built on Feb. 17, 2025, 1:31 a.m.