preprocess_transform: Apply a preprocess transform model to a cell_data_set.

View source: R/projection.R

preprocess_transformR Documentation

Apply a preprocess transform model to a cell_data_set.

Description

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

Usage

preprocess_transform(
  cds,
  reduction_method = c("PCA", "LSI"),
  block_size = NULL,
  cores = 1
)

Arguments

cds

a cell_data_set to be transformed.

reduction_method

a previously loaded transform model that is used to reduce the dimensions of the count matrix in the cell_data_set. The "PCA" and "LSI" transforms are supported. The default is "PCA".

block_size

a numeric value for the DelayedArray block size used only in this function. Default is NULL, which does not affect the current block size.

cores

the number of cores to use for the matrix multiplication. The default is 1.

Value

a cell_data_set with a preprocess reduced count matrix.

Preprocessing notes

Filtering:

apply the same filters to the query and reference data set. For example, use the same UMI cutoff value for both data sets. You can check the cutoff value by finding the range of UMI values before applying normalization using range(counts(cds)).

Size factors:

use the same method and round_exprs parameters to calculate the Size_Factor values for both data sets. See the estimate_size_factors() help for additional information.

Troubleshooting:

if the projection fails, try comparing histograms of various values of the reference and query data sets. For example, in order to examine the size factor values use hist(colData(cds)[['Size_Factor']], breaks=100).

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)
    save_transform_models(cds1, 'tm')
    cds2 <- cds[,!cell_set]
    cds2 <- load_transform_models(cds2, 'tm')
    cds2 <- preprocess_transform(cds2, 'PCA')
  
## End(Not run)


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