
Score cells with the models trained by train_weights()
hitype_score_models.RdScores each cell with the linear predictors of the per-cell-type models
persisted by train_weights() with return_models = TRUE (methods
"glmnet" and "lr" only): for a cell with expression x of the model
features, the score of cell type t is
eta_t = (Intercept)_t + sum_f coef_tf * (x_f - center_f) / scale_f,
where center/scale are the per-gene centering/scaling recorded when
the models were trained. Genes of the model features missing from
exprs contribute 0; extra genes of exprs are ignored.
Arguments
- exprs
Input scRNA-seq expression matrix (genes x cells, the same convention as
hitype_score()).- models
The model bundle returned by
train_weights()withreturn_models = TRUE(themodelselement).- margin
Cells whose top-minus-second score (
margins) is belowmarginare assigned"Unknown"instead of their top cell type.0(default) assigns every cell.
Value
A list with:
scoresA matrix (cells x cell types) of the linear predictors, with the cell types in the order of the model bundle.
assignmentsA named vector with the top-scoring cell type of every cell (or
"Unknown"for cells below themargin).marginsA named numeric vector with the top-minus-second score of every cell.