This function trains a multinomial logistic regression model using ranked gene expression. Optionally performs cross-validation to select the optimal regularization parameter.
Arguments
- data
A gene expression matrix with genes as rows and cells (or spatial spots) as columns. Can be a
Seuratobject, aSummarizedExperimentobject, a dense numeric matrix, or a sparsedgCMatrix.- labels
A vector of cell type labels (one per column of
data).- alpha
Elastic net mixing parameter. 1 = LASSO, 0 = Ridge. Default is
0.1.- cv
Logical. If
TRUE, performs cross-validation usingcv.glmnet. Default isFALSE.- nfolds
Number of folds for cross-validation (only used if
cv = TRUE). Default is5.- ...
Additional arguments passed to
computeRankedMatrix.
Examples
# Read in single-cell reference data
seu_sc <- readRDS(system.file("extdata", "seu_sc.rds",
package = "RankMap"
))
# Extract normalized expression data
mat <- extractData(seu_sc)
# Train a model
set.seed(42)
model <- trainRankModel(mat, seu_sc$cell_type)
# Train a model with cross-validation
model <- trainRankModel(
data = mat,
labels = seu_sc$cell_type,
cv = TRUE,
nfolds = 3
)