Skip to main content

CollapsingOps

Trait CollapsingOps 

Source
pub trait CollapsingOps {
    // Required methods
    fn collapse_columns(
        &self,
        knn_batches: Option<usize>,
        knn_cells: Option<usize>,
        reference_batch_names: Option<&[Box<str>]>,
        num_opt_iter: Option<usize>,
    ) -> Result<CollapsedOut>;
    fn build_hnsw_per_batch<T>(
        &mut self,
        proj_kn: &DMatrix<f32>,
        col_to_batch: &[T],
    ) -> Result<()>
       where T: Sync + Send + Hash + Eq + Clone + ToString;
    fn collect_basic_stat(&self, stat: &mut CollapsedStat) -> Result<()>;
    fn collect_batch_stat(&self, stat: &mut CollapsedStat) -> Result<()>;
    fn collect_matched_stat(
        &self,
        knn_batches: usize,
        knn_cols: usize,
        reference_indices: Option<&[usize]>,
        stat: &mut CollapsedStat,
    ) -> Result<()>;
}
Expand description

Given a feature/projection matrix (factor x cells), we assign each cell to a sample and return pseudobulk (collapsed) matrices

(1) Register batches if needed (2) collapse columns/cells into samples

Required Methods§

Source

fn collapse_columns( &self, knn_batches: Option<usize>, knn_cells: Option<usize>, reference_batch_names: Option<&[Box<str>]>, num_opt_iter: Option<usize>, ) -> Result<CollapsedOut>

Collapse columns/cells into samples as allocated by assign_columns_to_samples

§Arguments
  • cells_per_group - number of cells per sample (None: no down sampling)
  • knn_batches - number of nearest neighbour batches
  • knn_cells - number of nearest neighbors for building HNSW (default: 10)
  • reference - reference batch for counterfactual inference
  • num_opt_iter - number of optimization iterations (default: 100)
Source

fn build_hnsw_per_batch<T>( &mut self, proj_kn: &DMatrix<f32>, col_to_batch: &[T], ) -> Result<()>
where T: Sync + Send + Hash + Eq + Clone + ToString,

Register batch information and build a HnswMap object for each batch for fast nearest neighbor search within each batch and store them in the SparseIoVec

§Arguments
  • proj_kn - random projection matrix
  • col_to_batch - map: cell -> batch
Source

fn collect_basic_stat(&self, stat: &mut CollapsedStat) -> Result<()>

Source

fn collect_batch_stat(&self, stat: &mut CollapsedStat) -> Result<()>

Source

fn collect_matched_stat( &self, knn_batches: usize, knn_cols: usize, reference_indices: Option<&[usize]>, stat: &mut CollapsedStat, ) -> Result<()>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§