Skip to main content

Module refine_multilevel

Module refine_multilevel 

Source
Expand description

BBKNN-based Poisson refinement over multi-level pb-sample partitions.

Given a hash-initialized hierarchy of pb-sample → group mappings and a PbSampleLayout (HNSW over centroids, batch assignments), refine each level from coarsest to finest by proposing moves that keep each pb-sample under the same parent group (sibling-constrained) and are drawn from the batch-balanced KNN neighborhood. Moves are scored by a DC-Poisson log-likelihood with NB Fisher-info feature weighting (see crate::alg::dc_poisson::FeatureWeighting), on pb-sample profiles divided by their batch’s per-gene factor (Profiles::rescale_batches): a group pools the pb-samples of several batches, and on raw profiles a pb-sample would fit the group that holds most of its own batch. The factors are fitted within the groups of the coarsest level, so that batches of different cell-type composition are not corrected for their composition; what differs between batches within one such group is taken for a batch factor (see refine_assignments).

Candidate-set construction is BBKNN-specific and lives here (BbknnProposer). The generic scoring core lives in crate::alg::dc_poisson and is shared with other front-ends (e.g. pinto’s spatial-graph proposer).

Entry point: refine_assignments.

Re-exports§

pub use crate::alg::collapse_data::GeneSums;
pub use crate::alg::dc_poisson::compact_labels;
pub use crate::alg::dc_poisson::RefineParams;

Structs§

BbknnProposer
Proposes move candidates for pb-samples via cross-batch BBKNN.
RefineInputs
Fixed inputs describing what to refine. batch_knn_lookup is the per-batch HNSW over cells, typically obtained from SparseIoVec::batch_knn_lookup() after build_hnsw_per_batch. k_per_batch is the BBKNN fan-out — up to this many distinct pb-samples are drawn from each non-own batch as move candidates.
RefinedAssignment
Per-level refined pb-sample → group mapping.

Functions§

refine_assignments
Top-down BBKNN + Poisson refinement.