getMDS | R Documentation |
Perform multi-dimensional scaling (MDS) also know as Principal Coordinate
Analysis (PCoA). These functions are wrappers for
scater::calculateMDS
.
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", ...)
x |
a |
... |
additional arguments.
|
name |
|
assay.type |
|
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.
getMDS
returns a MDS results.
addMDS
returns a x
with MDS results added to its
reducedDim(x, name)
.
scater::calculateMDS
and
getDissimilarity
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.