
Per-cell ScType assignment with optional kNN smoothing
rs_sc_type_assign_cells.Rd
Assigns cell types per cell instead of per cluster. If a graph is provided,
the score matrix is smoothed via label spreading over that graph before the
per-cell argmax. If cluster labels are provided, the per-cluster composition
and the hybrid assignment (pure clusters keep the cluster-level call, mixed
clusters fall back to the per-cell calls) are returned on top.
Arguments
- sc_type_res
List. The ScType results, see
rs_sc_type().- from, to
Optional integer vectors. 1-indexed(!) edges of the sNN graph, each edge listed once; the graph is symmetrised on the way in. If either is
NULL, no smoothing is applied.- weights
Optional numeric vector. Edge weights, same length as
from. Reciprocal weights are averaged. IfNULL, the graph is unweighted.- cluster_labels
Optional integer vector. 0-indexed(!) cluster assignment, of length of the scored cells.
- params
List. The output of
params_sctype_cells().
Value
A list with
cell_types - String vector. The cell types.
assignments - Integer vector. 1-based index into
cell_typesper cell,0Ldenoting Unknown.scores - Numeric vector. Winning score per cell.
margins - Numeric vector. Best minus second best score per cell.
agreement - Numeric vector. Fraction of graph neighbours sharing the call.
NULLif no graph was provided.hybrid_assignments - Integer vector, as
assignments.NULLif nocluster_labelswere provided.composition - List with the per-cluster composition (
cluster_id,n_cells,n_unknown,dominant,second,purity,second_fraction,entropy,cluster_mixedand the clusters x cell types count matrixcounts).dominantandseconduse the same 1-based encoding asassignments.NULLif nocluster_labelswere provided.