Transfer cell scores between matrices using gene weights
Source:R/H_extrapolate.R
transfer_scores.RdGiven reference (mat_A) and target (mat_B) cell-by-gene matrices with the
same set and order of genes (columns), this function optionally quantile
normalizes the target to match the reference per feature, standardizes the
target using the reference mean and standard deviation, filters small-magnitude
gene weights, and computes cell scores via matrix multiplication
\(B_{standardized} \\times W\).
Usage
transfer_scores(
mat_A,
mat_B,
gs_ct,
use_quantile_normalization = TRUE,
gs_weight_threshold = 0,
verbose = TRUE
)Arguments
- mat_A
Numeric matrix of shape cells-by-genes (reference). Column order must correspond to genes in
gs_ct.- mat_B
Numeric matrix of shape cells-by-genes (target). Must have the same genes (columns) and order as
mat_A.- gs_ct
Numeric matrix of gene weights of shape genes-by-K, where K is the number of signatures or cell types. Column names, if present, are used in verbose messages.
- use_quantile_normalization
Logical; whether to quantile-normalize
mat_Btomat_Aper feature before standardization (defaultTRUE).- gs_weight_threshold
Numeric; absolute threshold used to zero out small gene weights in
gs_ct(default0).- verbose
Logical; whether to print progress messages (default
TRUE).
Details
If
use_quantile_normalization = TRUE,mat_Bis quantile-normalized to the distribution ofmat_Afor each gene.Columns of the normalized
mat_Bare then centered and scaled using the column means and standard deviations computed frommat_A(with a small safeguard for near-zero standard deviations).Gene weights in
gs_ctare thresholded by absolute value per column; values withabs(weight) < gs_weight_thresholdare set to 0.Final cell scores are obtained as the matrix product of the standardized
mat_Bwith the filtered weight matrixgs_ct.
This function assumes that mat_A, mat_B, and gs_ct are aligned
on the same set and ordering of genes (columns of mat_A/mat_B, rows of
gs_ct). Callers are responsible for subsetting/reordering if needed.