scviva.tools.vision.apply_rbfpca#
- scviva.tools.vision.apply_rbfpca(X, n_components=2, sigma=0.33)[source]#
RBF-kernel PCA 2D projection.
Mirrors R VISION’s
applyRBFPCA. Builds a log-distance Gaussian kernel matrix K from pairwise Euclidean distances, row-normalises and z-scores each row, then returns the projection onto the topn_componentseigenvectors ofK @ K.T.- Parameters:
- Return type:
- Returns:
ndarray of shape (n_cells, n_components)
Notes
The row z-scoring step is a deliberate deviation from what R VISION actually executes, not from what it appears to intend. R’s line reads
kMat <- as.matrix(kMat, 1, function(x) (x - mean(x)) / sd(x)), which looks like anapply()-style per-row z-score – butkMatis already a matrix, soas.matrix.default()returns it unchanged and silently discards the extra arguments. R’s RBFPCA therefore never actually z-scores its kernel matrix. This implementation performs the z-score for real, matching the evident intent of that R line rather than R’s actual (apparently unintentional) runtime behavior; the two projections are not numerically equivalent as a result.