runNMDS: Perform non-metric MDS on sample-level data

View source: R/runNMDS.R

runNMDSR Documentation

Perform non-metric MDS on sample-level data

Description

Perform non-metric multi-dimensional scaling (nMDS) on samples, based on the data in a SingleCellExperiment object.

Usage

getNMDS(x, ...)

## S4 method for signature 'ANY'
getNMDS(
  x,
  FUN = vegdist,
  nmds.fun = nmdsFUN,
  nmdsFUN = c("isoMDS", "monoMDS"),
  ncomponents = 2,
  ntop = 500,
  subset.row = subset_row,
  subset_row = NULL,
  scale = FALSE,
  transposed = FALSE,
  keep.dist = keep_dist,
  keep_dist = FALSE,
  ...
)

## S4 method for signature 'SummarizedExperiment'
getNMDS(
  x,
  ...,
  assay.type = assay_name,
  assay_name = exprs_values,
  exprs_values = "counts",
  FUN = vegdist
)

## S4 method for signature 'SingleCellExperiment'
getNMDS(
  x,
  ...,
  assay.type = assay_name,
  assay_name = exprs_values,
  exprs_values = "counts",
  dimred = NULL,
  ndimred = n_dimred,
  n_dimred = NULL,
  FUN = vegdist
)

calculateNMDS(x, ...)

addNMDS(x, ..., altexp = NULL, name = "NMDS")

runNMDS(x, ...)

Arguments

x

For getNMDS, a numeric matrix of expression values where rows are features and columns are cells. Alternatively, a TreeSummarizedExperiment containing such a matrix.

For addNMDS a SingleCellExperiment

...

additional arguments to pass to FUN and nmds.fun.

FUN

a function or character value with a function name returning a dist object

nmds.fun

a character value to choose the scaling implementation, either “isoMDS” for MASS::isoMDS or “monoMDS” for vegan::monoMDS

nmdsFUN

Deprecated. Use nmds.fun instead.

ncomponents

Numeric scalar indicating the number of NMDS dimensions to obtain.

ntop

Numeric scalar specifying the number of features with the highest variances to use for dimensionality reduction.

subset.row

Vector specifying the subset of features to use for dimensionality reduction. This can be a character vector of row names, an integer vector of row indices or a logical vector.

subset_row

Deprecated. Use subset.row instead.

scale

Logical scalar, should the expression values be standardized?

transposed

Logical scalar, is x transposed with cells in rows?

keep.dist

Logical scalar indicating whether the dist object calculated by FUN should be stored as ‘dist’ attribute of the matrix returned/stored by getNMDS/ addNMDS.

keep_dist

Deprecated. Use keep.dist instead.

assay.type

a single character value for specifying which assay to use for calculation.

assay_name

a single character value for specifying which assay to use for calculation. (Please use assay.type instead. At some point assay_name will be disabled.)

exprs_values

a single character value for specifying which assay to use for calculation. (Please use assay.type instead.)

dimred

String or integer scalar specifying the existing dimensionality reduction results to use.

ndimred

Integer scalar or vector specifying the dimensions to use if dimred is specified.

n_dimred

Deprecated. Use ndimred instead.

altexp

String or integer scalar specifying an alternative experiment containing the input data.

name

String specifying the name to be used to store the result in the reducedDims of the output.

Details

Either MASS::isoMDS or vegan::monoMDS are used internally to compute the NMDS components. If you supply a custom FUN, make sure that the arguments of FUN and nmds.fun do not collide.

Value

For getNMDS, a matrix is returned containing the MDS coordinates for each sample (row) and dimension (column).

Author(s)

Felix Ernst

See Also

MASS::isoMDS, vegan::monoMDS for NMDS component calculation.

plotMDS, to quickly visualize the results.

Examples

# generate some example data
mat <- matrix(1:60, nrow = 6)
df <- DataFrame(n = c(1:6))
tse <- TreeSummarizedExperiment(assays = list(counts = mat),
                                rowData = df)
#
getNMDS(tse)

#
data(esophagus)
esophagus <- addNMDS(esophagus, FUN = vegan::vegdist, name = "BC")
esophagus <- addNMDS(esophagus, FUN = vegan::vegdist, name = "euclidean",
                     method = "euclidean")
reducedDims(esophagus)

FelixErnst/mia documentation built on June 19, 2024, 3:51 a.m.