Add MAGIC imputation weights to a MarchRProject
add_impute_weights.RdComputes diffusion-based imputation weights using the MAGIC algorithm (van Dijk et al., Cell 2018). Weights describe each cell as a linear combination of neighboring cells in reduced-dimension space, enabling smoothed visualization of sparse gene scores or accessibility signals.
Arguments
- proj
(MarchRProject) Project containing a dimensionality reduction.
- embedding_name
(character) Name of the dimensionality reduction to use (e.g.,
"IterativeLSI","RNA_PCA"). Uses smart selection if not specified.- dims_to_use
(integer; optional) Which dimensions to use. Default is all available dimensions.
- td
(integer) Diffusion time - number of matrix power iterations. Higher values produce more smoothing. Default is 3 (matching ArchR).
- ka
(integer) Auto-tune parameter - normalize distances by the ka-th nearest neighbor distance to equalize effective neighborhood sizes across density variations. Default is 4.
- knn_method
(function) BPCells KNN method. Default is
knn_hnsw(k = 15L). Put KNN-specific arguments such ask,metric, orefinside the partial function. SeeBPCells::knn_hnsw()andBPCells::knn_annoy().- epsilon
(numeric) Kernel bandwidth. Distances are transformed via
exp(-(d/epsilon)^2). Set to 0 for unweighted KNN. Default is 1.- sample_cells
(integer; optional) Maximum block size for sub-sampling cells. If total cells exceed this, they are split into blocks for memory efficiency. Default is 5000. Set to NULL to use all cells in one block.
- n_rep
(integer) Number of imputation replicates to average. Default is 2.
- seed
(integer) Random seed. Default is 1.
- verbose
(logical) Print progress messages. Default
getOption("MarchR.verbose", FALSE).
Details
ArchR correspondence: This function corresponds to ArchR's addImputeWeights().
MarchR uses BPCells KNN (knn_hnsw/knn_annoy) instead of nabor::knn()
See also
get_impute_weights for retrieving weights
impute_matrix for applying imputation to a matrix
BPCells::knn_hnsw, BPCells::knn_annoy for KNN methods