reduce_dimension: Compute a projection of a cell_data_set object into a lower...

View source: R/reduce_dimensions.R

reduce_dimensionR Documentation

Compute a projection of a cell_data_set object into a lower dimensional space with non-linear dimension reduction methods


Monocle3 aims to learn how cells transition through a biological program of gene expression changes in an experiment. Each cell can be viewed as a point in a high-dimensional space, where each dimension describes the expression of a different gene. Identifying the program of gene expression changes is equivalent to learning a trajectory that the cells follow through this space. However, the more dimensions there are in the analysis, the harder the trajectory is to learn. Fortunately, many genes typically co-vary with one another, and so the dimensionality of the data can be reduced with a wide variety of different algorithms. Monocle3 provides two different algorithms for dimensionality reduction via reduce_dimension (UMAP and tSNE). The function reduce_dimension is the second step in the trajectory building process after preprocess_cds.

UMAP is implemented from the package uwot.


  max_components = 2,
  reduction_method = c("UMAP", "tSNE", "PCA", "LSI", "Aligned"),
  preprocess_method = NULL,
  umap.metric = "cosine",
  umap.min_dist = 0.1,
  umap.n_neighbors = 15L,
  umap.fast_sgd = FALSE,
  umap.nn_method = "annoy",
  verbose = FALSE,
  cores = 1,
  build_nn_index = FALSE,
  nn_control = list(),



the cell_data_set upon which to perform this operation.


the dimensionality of the reduced space. Default is 2.


A character string specifying the algorithm to use for dimensionality reduction. Currently "UMAP", "tSNE", "PCA", "LSI", and "Aligned" are supported.


A string indicating the preprocessing method used on the data. Options are "PCA" and "LSI". Default is "LSI".


A string indicating the distance metric to be used when calculating UMAP. Default is "cosine". See uwot package's umap for details.


Numeric indicating the minimum distance to be passed to UMAP function. Default is 0.1.See uwot package's umap for details.


Integer indicating the number of neighbors to use during kNN graph construction. Default is 15L. See uwot package's umap for details.


Logical indicating whether to use fast SGD. Default is TRUE. See uwot package's umap for details.


String indicating the nearest neighbor method to be used by UMAP. Default is "annoy". See uwot package's umap for details.


Logical, whether to emit verbose output.


Number of cores to use for computing the UMAP.


logical When this argument is set to TRUE, preprocess_cds builds the nearest neighbor index from the reduced dimension matrix for later use. Default is FALSE.


An optional list of parameters used to make the nearest neighbor index. See the set_nn_control help for detailed information. The default metric is cosine for reduction_methods PCA, LSI, and Aligned, and is euclidean for reduction_methods tSNE and UMAP. Note: distances in tSNE space reflect spatial differences poorly so using nearest neighbors with it may be meaningless.


additional arguments to pass to the dimensionality reduction function.


an updated cell_data_set object


UMAP: McInnes, L, Healy, J, UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction, ArXiv e-prints 1802.03426, 2018

tSNE: Laurens van der Maaten and Geoffrey Hinton. Visualizing data using t-SNE. J. Mach. Learn. Res., 9(Nov):2579– 2605, 2008.


    cell_metadata <- readRDS(system.file('extdata',
    gene_metadata <- readRDS(system.file('extdata',
    expression_matrix <- readRDS(system.file('extdata',
    cds <- new_cell_data_set(expression_data=expression_matrix,

    cds <- preprocess_cds(cds)
    cds <- reduce_dimension(cds)

cole-trapnell-lab/monocle3 documentation built on April 7, 2024, 9:24 p.m.