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

TreeSummarizedExperiment.

...

additional arguments to pass to FUN and nmds.fun.

FUN

Function or Character scalar. A value with a function name returning a dist object

nmds.fun

Character scalar. A 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. Indicates the number of DPCoA dimensions to obtain. (Default: 2)

ntop

Numeric scalar. Specifies the number of features with the highest variances to use for dimensionality reduction. Alternatively NULL, if all features should be used. (Default: NULL)

subset.row

Character Vector. Specifies 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. (Default: NULL)

subset_row

Deprecated. Use subset.row instead.

scale

Logical scalar. Should the expression values be standardized? (Default: FALSE)

transposed

Logical scalar. Specifies if x is transposed with cells in rows. (Default: FALSE)

keep.dist

Logical scalar. Indicates whether the dist object calculated by FUN should be stored as ‘dist’ attribute of the matrix returned/stored by getNMDS/ addNMDS. (Default: FALSE)

keep_dist

Deprecated. Use keep.dist instead.

assay.type

Character scalar. Specifies which assay to use for calculation. (Default: "counts")

assay_name

Deprecated. Use assay.type instead.

exprs_values

Deprecated. Use assay.type instead.

dimred

Character scalar or integer scalar. Specifies the existing dimensionality reduction results to use.

ndimred

integer vector. Specifies the dimensions to use if dimred is specified.

n_dimred

Deprecated. Use ndimred instead.

altexp

Character scalar or integer scalar. Specifies an alternative experiment containing the input data. (Default: NULL)

name

Character scalar. A name for the column of the colData where results will be stored. (Default: "NMDS")

Details

For addNMDS a SingleCellExperiment

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).

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 Nov. 18, 2024, 5:02 a.m.