RunMDS: Run MDS

View source: R/RunMDS.R

RunMDSR Documentation

Run MDS

Description

Compute a multidimensional scaling (MDS) dimensionality reduction on a Seurat object, using the provided distance metric. By default, using 30 dimensions in the reduced space, based on the variable features of the current default assay and data layer, with results stored under the name "mds".

Usage

RunMDS(
  object,
  distance = NA,
  n.dims = 30,
  features.use = NA,
  assay = NA,
  layer = "data",
  reduction.name = "mds",
  key = "MDS_",
  batch_size = 400,
  n.cores = 1,
  seed = 42
)

Arguments

object

Seurat object.

distance

Distance function, e.g. FractionDifferingVariants for variants or stats::dist() for common distances applying to continuous data. NA will use FractionDifferingVariants if the assay used is "VAR", euclidean dist otherwise.

n.dims

numeric(1). The number of dimensions in the reduction (Default:30).

features.use

character(n). The features to use to compute the reduction. NA for most variable features of assay (Default: NA).

assay

character(1). The assay to use. NA uses "VAR" if available, otherwise the DefaultAssay (Default:NA).

layer

character(1). The Seurat object assay layer to use (Default:"data").

reduction.name

character(1). The name under which the dimensionality reduction will be stored under (Default: "mds").

key

character(1). The key (prefix to column numbers) used to name the MDS coordinates (Default: "MDS_")

batch_size

numeric(1). The number of cells processed for each batch of the divide and conquer MDS. The batches are then realigned and merged. Smaller batches provide faster runs, larger batches provide more accurate results (Default: 400).

n.cores

numeric(1). The number of cores to use for parallel processing (Default: 1). Unix only.

seed

numeric(1). Random seed set at the beginning of the run for reproducible results (Default:42).

Details

Wrapper of the bigmds divide and conquer method, see bigmds::divide_conquer_mds() for details and references.

For usage on variant data in vartrix-like sparse matrix conventions, use the custom distance function FractionDifferingVariants().

For use on continuous rather than discrete data, typically consider stats::dist().

Value

Returns the Seurat object.

Examples

DefaultAssay(MySeuratObject) <- "VAR" # variant calls, sparse matrix with values 1,2,3 for ref/alt/heterozygous in vartrix conventions. Assuming VariableFeatures have been set to most informative variants for this assay. Will also use VAR by default if assay=NA, so no need to explicitely change the default assay.
MySeuratObject <- RunMDS(MySeuratObject)
DimPlot(MySeuratObject, reduction="mds")
MySeuratObject <- RunUMAP(MySeuratObject,reduction="mds",dims=1:30)
DimPlot(MySeuratObject, reduction="umap")

nbroguiere/burgertools documentation built on Jan. 30, 2024, 3:48 a.m.