scoreCells() provides a lightweight correlation- and signature-based
fallback for regimes where a full PhiSpace model is not meaningful, such as
single-class references or references with very few classes. It stores score
matrices in reducedDim() slots with one column per reference class.
scoreCells(
reference,
query,
class_col = NULL,
assay_ref = "logcounts",
assay_query = "logcounts",
signature_genes = NULL,
signature_method = c("mean", "findMarkers"),
marker_test = c("t", "wilcox", "binom"),
marker_pval_type = "any",
marker_direction = c("up", "down", "any"),
n_top_genes = 300,
n_signature_genes = 100,
remove_housekeeping = TRUE,
housekeeping_patterns = c("^Rpl", "^Rps", "^mt-", "^MT-", "^Mrpl", "^Mrps"),
housekeeping_genes = NULL,
shared_genes_only = TRUE,
scoring = c("both", "correlation", "signature"),
cor_method = c("spearman", "pearson"),
zscore_signature = TRUE,
score_prefix = "scoreCells",
BPPARAM = BiocParallel::SerialParam(),
verbose = TRUE
)A SingleCellExperiment or SpatialExperiment object.
A SingleCellExperiment or SpatialExperiment object to score.
Character or NULL. Column in colData(reference) defining
reference classes. If NULL, all reference cells are treated as one class.
Character. Assay in reference used for scoring.
Character. Assay in query used for scoring.
NULL, a character vector, or a named list of
character vectors. If NULL, signatures are generated from reference.
A character vector is accepted for a single-class reference. A
multi-class reference requires a named list whose names exactly match the
reference classes. Supplied signatures are used as-is after removing
duplicates and genes unavailable in either assay; marker-selection and
housekeeping-removal arguments are ignored.
Character. Signature selection method. "mean"
(default) uses mean-expression ranking for every class. "findMarkers"
uses scran::findMarkers() for multi-class references and falls back to
mean-expression ranking for single-class references. scran deprecates
findMarkers() in Bioconductor 3.24, so this option will be removed when
scran removes the function.
Character. Test type passed to scran::findMarkers().
Character. pval.type passed to
scran::findMarkers().
Character. Direction used when selecting markers:
"up", "down", or "any".
Integer. Candidate gene pool per class before removing housekeeping genes.
Integer. Number of final signature genes per class.
Logical. Whether to remove housekeeping genes from class signatures.
Character vector of regex patterns identifying housekeeping genes.
Character vector of additional housekeeping genes.
If NULL, a small built-in list is used.
Logical. If TRUE, use the intersection of
reference and query genes. If FALSE, reference and query row names must be
identical.
Character. Which score matrices to compute: "both",
"correlation", or "signature".
Character. Correlation method: "spearman" or "pearson".
Logical. Whether to z-score signature scores. For multi-class references, z-scoring is across classes within each cell. For a single-class reference, z-scoring is across cells.
Character. Prefix for output reducedDim() names.
BiocParallel parameter object passed to
scran::findMarkers().
Logical. Whether to emit progress messages.
The modified query object with score matrices stored in
reducedDim() slots and run details stored in metadata(query)$scoreCells.
A correlation score measures similarity between a query cell and a reference
class centroid in the relative expression pattern across that class's
effective signature genes. Different classes can therefore be scored using
different genes. Correlations are NA for query cells with fewer than two
complete observations or zero expression variance across the relevant
signature.
A signature score is the average query expression across the same effective
signature genes, optionally z-scored. When scoring = "both", the
correlation and signature branches use exactly the same genes for each
class.
set.seed(1)
ref <- logNormTransf(scuttle::mockSCE(ncells = 200, ngenes = 300))
query <- logNormTransf(scuttle::mockSCE(ncells = 100, ngenes = 300))
query <- scoreCells(ref, query, class_col = "Cell_Cycle",
signature_method = "mean", n_signature_genes = 20,
verbose = FALSE)
reducedDimNames(query)