Skip to contents

This function can recover SEs from scRNA-seq data or single-cell spatial data by assigning each single cell to an SE or NonSE.

Usage

RecoverSE(
  dat,
  celltypes = NULL,
  scale = TRUE,
  ncell.per.run = 500,
  Ws = NULL,
  min.score = 0.6,
  ncores = 1
)

Arguments

dat

A numeric (sparse) matrix of gene expression data, from single-cell spatial transcriptomics or scRNA-seq data.

celltypes

Character vector specifying the cell type annotations for cells included in the gene expression `dat`. If you're using the default model, cell types including B, CD4T, CD8T, NK, Plasma, Macrophage, DC, Fibroblast, Endothelial are expected.

scale

Logical indicating whether to perform unit-variance normalization (default: TRUE). Change it with caution.

ncell.per.run

Integer specifying the maximum number of cells per NMF prediction run to avoid memory issues.

Ws

A list of cell-type-specific W matrices used to recover SE-specific cell states. Each element in the list should be named after the corresponding cell type and contain a W matrix from an NMF model.

min.score

A numeric threshold (0-1) specifying the minimum prediction score for SE classification; cells with lower scores are assigned to NonSE.

ncores

Integer specifying the number of CPU cores to use for parallel processing (default: 1).

Value

A data frame with four columns, including CID (cell id), CellType (cell type), SE (spatial ecotype), and PredScore (prediction probability for the assigned SE).

Examples

# see https://digitalcytometry.github.io/spatialecotyper/articles/Recovery_scRNA.html
# see https://digitalcytometry.github.io/spatialecotyper/articles/Recovery_Spatial.html