Skip to contents

This function can be used to project cell type expression profiles onto a 10x Visium gene expression matrix to obtain cell type proportion estimates.

Usage

RunNNLS(object, ...)

# Default S3 method
RunNNLS(
  object,
  singlecell_matrix,
  groups,
  nCells_per_group = 50L,
  minCells_per_celltype = 10L,
  min_prop = 0.01,
  L1 = 0.01,
  seed = 1337L,
  return_expression_profiles = FALSE,
  verbose = TRUE,
  ...
)

# S3 method for class 'Seurat'
RunNNLS(
  object,
  singlecell_object,
  groups = NULL,
  features = NULL,
  singlecell_assay = "RNA",
  spatial_assay = "Spatial",
  slot = "data",
  min_prop = 0.01,
  nCells_per_group = 50L,
  minCells_per_celltype = 10L,
  assay_name = "celltypeprops",
  dimred_name = "nnls",
  return_as_dimred = FALSE,
  L1 = 0.01,
  seed = 1337L,
  verbose = TRUE,
  ...
)

Arguments

object

A matrix-like object with 10x Visium data

...

Arguments passed to other methods

singlecell_matrix

A matrix-like object with scRNA-seq data

groups

A character vector of length ncol(singlecell_matrix) with cell type labels. For Seurat objects, one can omit groups in which case the current identity is used instead. Alternatively, a string can be provided specifying a column to use from the singlecell_object meta.data slot.

nCells_per_group

Each cell type is down sampled to this number before computing cell type expression profiles. This is mainly used to speed up computation. Note that if a cell type has fewer than nCells_per_group cells, the cells will be sampled with replacement to obtain nCells_per_group cells.

minCells_per_celltype

Minimum number of cells allowed per cell type

min_prop

Minimum proportion allowed. Any proportion values lower than this threshold will be removed and the remaining proportions will be rescaled.

L1

lasso penalty

seed

An integer to set seed for reproducibility

return_expression_profiles

Logical specifying if the expression profile matrix should also be returned

verbose

Print messages

singlecell_object

A Seurat object with single-cell gene expression data

features

Features to use for computation. If no features are provided, the intersection of variable features between sc_object and st_object will be used. Note that the intersect can be quite small, in which case you can increase the number of variable features by rerunning FindVariableFeatures and increase the number with the nfeatures argument.

singlecell_assay

Assay in single cell data object to use for deconvolution

spatial_assay

Assay in Visium data object to use for deconvolution

slot

Name of slot in singlecell_assay and spatial_assay to use for deconvolution

assay_name

Sets the name of the returned Assay object. Only active if return.as.dimred = FALSE.

dimred_name

Sets the name of the returned DimReduc object. Only active if return.as.dimred = TRUE.

return_as_dimred

By default, the results are returned as an Assay named "celltypeprops", where each feature is named after the cell type IDs. Alternatively, you can return the results as a DimReduc object. This will also provide the cell gene loadings for each cell type. However, the proportions will instead be named "factor_1", "factor_2", ...

Value

An object with cell type proportion estimates

Details

This method is suitable for paired 10x Visium and scRNA-seq data. In other words, the scRNA-seq data should represent the cell types present in the 10x Visium spatial transcriptomics data. Redundant cell types (i.e. cells that are present in the scRNA-seq data but not in the data 10x Visium) or missing cell types (i.e. cells that are present in the 10x Visium data but not in the data scRNA-seq data) might affect the results.

Preferably, the scRNA-seq data should be composed of the same cell types as the tissue section(s) processed by 10x Visium and be collected from the same tissue specimen. This method is intended to be used as a fast cell type mapping which is useful for data driven exploration.

We encourage users to explore alternative methods such as stereoscope, cell2location or RCTD.

The method uses the NNLS implementation from the RcppML R package developed by Zachary DeBruine.

Examples

A tutorial can be found on our package website. Got to tutorials -> Cell type mapping

default method

Input object is a matrix-like object with 10x Visium data. The function returns a matrix with estimated cell type proportions of dimensions nCellTypes x nSpots, where nCellTypes is the number of cell types and nSpots is the number of spots. If return_expression_profiles=TRUE, the returned object will be a list with estimated proportions prop and the cell type expression profile matrix W.

Seurat method

Input object is a Seurat object with 10x Visium data. The function returns the Seurat object with either a new Assay or DimReduc object containing estimated cell type proportions.

Author

Ludvig Larsson