Mixed cell type prediction with NNLS (experimental)
celltype-prediction-mixed.Rd
This function can be used to obtain proportion estimates for a mixture of cell types and unknown factors. The input spatial expression matrix is first deconvolved using Non-negative Matrix Factorization (NMF) with the rank set to number of cell types + k additional factors. The estimated factor expression profiles are are then compared with the cell type expression profiles by computing pairwise correlation scores. Factor expression profiles with the lowest correlation scores are kept and combined with the cell type expression profiles to predict proportions directly from the spatial data using Non-negative Least Squares (NNLS).
Usage
RunMixedNNLS(object, ...)
# Default S3 method
RunMixedNNLS(
object,
singlecell_matrix,
groups,
k = 10L,
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'
RunMixedNNLS(
object,
singlecell_object,
groups = NULL,
k = 10L,
features = NULL,
singlecell_assay = "RNA",
spatial_assay = "Spatial",
slot = "data",
min_prop = 0.01,
nCells_per_group = 50L,
minCells_per_celltype = 10L,
assay_name = "celltypepropsmixed",
dimred_name = "nnlsmixed",
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. ForSeurat
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 thesinglecell_object
meta.data slot.- k
An integer specifying the number of factors to compute
- 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 obtainnCells_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 thenfeatures
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
andspatial_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 aDimReduc
object. This will also provide the cell gene loadings for each cell type. However, the proportions will instead be named "factor_1", "factor_2", ...
default method
Input object
is a matrix-like object with 10x Visium data. The function returns
a matrix with estimated proportions of dimensions (nCellTypes + k) x nSpots,
where nCellTypes is the number of cell types, k is the number of factors 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/factor expression profile matrix W
.