
Build per-cell RGB colours from the first three principal components of an embedding
cells_pca_rgb.RdConvenience helper for the common embedding-visualisation workflow:
stack a list-column (or matrix) of equal-length numeric vectors,
run a 3-component PCA, percentile-clip the scores per channel to
tame outliers, and pack into integer RGB suitable for a5_view()
with fill_identity = TRUE. Output is handed off to cells_rgb().
Arguments
- x
A list of numeric vectors of identical length (e.g. an arrow list-column of embeddings) or a numeric matrix with rows = cells and columns = features. Must not contain
NA.- clip
Length-2 numeric percentile range applied per principal component to clip outliers before colour mapping. Default
c(0.02, 0.98). Set toNULLto skip clipping.- scale
Passed to
irlba::prcomp_irlba(..., scale. = scale). Standardises features to unit variance before PCA. DefaultTRUE.- rgb_pcs
Length-3 signed integer vector specifying which PC maps to each colour channel, in red/green/blue order. The default
c(1, 2, 3)assigns PC1 to red, PC2 to green and PC3 to blue. Negative values flip the sign of the corresponding PC, useful because PCA components are arbitrary up to sign — e.g.c(1, -2, 3)uses-PC2for green. Must be a signed permutation of1:3.
Value
Packed RGB values (class a5_rgb, as from cells_rgb()), the
same length as the number of rows in x.