reduce_dimension_transform: Apply a reduce_dimension transform model to a cell_data_set.

View source: R/projection.R

reduce_dimension_transformR Documentation

Apply a reduce_dimension transform model to a cell_data_set.

Description

Applies a previously calculated reduce_dimension transform model to a new preprocess transformed matrix. For more information read the help information for save_transform_models.

Usage

reduce_dimension_transform(
  cds,
  preprocess_method = NULL,
  reduction_method = c("UMAP")
)

Arguments

cds

a cell_data_set to be transformed.

preprocess_method

the reduced dimension matrix to be transformed using the reduction_method transform model. The default is NULL, which uses the preprocess_method that was used when the reduce_dimension model was built.

reduction_method

a previously loaded reduce_dimension transform model that is used to reduce the dimensions of the preprocessed matrix in the cell_data_set. Only "UMAP" is supported.

Value

a cell_data_set with a transformed reduced count matrix.

Examples

  ## Not run: 
    cell_metadata <- readRDS(system.file('extdata',
                                         'worm_embryo/worm_embryo_coldata.rds',
                                         package='monocle3'))
    gene_metadata <- readRDS(system.file('extdata',
                                         'worm_embryo/worm_embryo_rowdata.rds',
                                         package='monocle3'))
    expression_matrix <- readRDS(system.file('extdata',
                                             'worm_embryo/worm_embryo_expression_matrix.rds',
                                             package='monocle3'))
    cds <- new_cell_data_set(expression_data=expression_matrix,
                             cell_metadata=cell_metadata,
                             gene_metadata=gene_metadata)
    ncell <- nrow(colData(cds))
    cell_sample <- sample(seq(ncell), 2 * ncell / 3)
    cell_set <- seq(ncell) %in% cell_sample
    cds1 <- cds[,cell_set]
    cds1 <- preprocess_cds(cds1)
    cds1 <- reduce_dimension(cds1)
    save_transform_models(cds1, 'tm')
    cds2 <- cds[,!cell_set]
    cds2 <- load_transform_models(cds2, 'tm')
    cds2 <- preprocess_transform(cds2, 'PCA')
    cds2 <- reduce_dimension_transform(cds2)
  
## End(Not run)


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