mumosa
Multi-modal analyses of single-cell data
Loading...
Searching...
No Matches
mumosa::BlockedIndicesFactory< Index_, Block_ > Class Template Reference

Factory for creating nearest-neighbor search indices for each block. More...

#include <blocked.hpp>

Classes

struct  Buffers
 Temporary buffers for build(). More...
 

Public Member Functions

 BlockedIndicesFactory (const Index_ num_cells, const Block_ *block)
 
const std::vector< Index_ > & sizes () const
 
template<typename Input_ >
Buffers< Input_ > create_buffers () const
 
template<typename Input_ , typename Distance_ , class Matrix_ = knncolle::Matrix<Index_, Input_>>
void build (const std::size_t num_dim, const Input_ *const data, const knncolle::Builder< Index_, Input_, Distance_, Matrix_ > &builder, std::vector< std::shared_ptr< const knncolle::Prebuilt< Index_, Input_, Distance_ > > > &output, Buffers< Input_ > &work) const
 
template<typename Input_ , typename Distance_ , class Matrix_ = knncolle::Matrix<Index_, Input_>>
std::vector< std::shared_ptr< const knncolle::Prebuilt< Index_, Input_, Distance_ > > > build (const std::size_t num_dim, const Input_ *const data, const knncolle::Builder< Index_, Input_, Distance_, Matrix_ > &builder) const
 

Detailed Description

template<typename Index_, typename Block_>
class mumosa::BlockedIndicesFactory< Index_, Block_ >

Factory for creating nearest-neighbor search indices for each block.

Unlike build_blocked_indices(), this class handles the scenario where cells from the same block do not occupy contiguous columns, i.e., cells from different blocks are intermingled.

Template Parameters
Index_Integer type of the number of cells.
Block_Integer type of the block assignments.

Constructor & Destructor Documentation

◆ BlockedIndicesFactory()

template<typename Index_ , typename Block_ >
mumosa::BlockedIndicesFactory< Index_, Block_ >::BlockedIndicesFactory ( const Index_ num_cells,
const Block_ * block )
inline
Parameters
num_cellsNumber of cells.
[in]blockPointer to an array of length equal to num_cells, containing the block assignment for each cell. Each value should be a non-negative integer in \([0, B)\) where \(B\) is the number of blocks. The lifetime of the underlying array should be no less than the last call to build().

Member Function Documentation

◆ sizes()

template<typename Index_ , typename Block_ >
const std::vector< Index_ > & mumosa::BlockedIndicesFactory< Index_, Block_ >::sizes ( ) const
inline
Returns
Vector of length equal to the number of blocks, containing the number of cells in each block. This can be used in create_workspace().

◆ create_buffers()

template<typename Index_ , typename Block_ >
template<typename Input_ >
Buffers< Input_ > mumosa::BlockedIndicesFactory< Index_, Block_ >::create_buffers ( ) const
inline
Returns
A collection of buffers that can be re-used for multiple calls to build().

◆ build() [1/2]

template<typename Index_ , typename Block_ >
template<typename Input_ , typename Distance_ , class Matrix_ = knncolle::Matrix<Index_, Input_>>
void mumosa::BlockedIndicesFactory< Index_, Block_ >::build ( const std::size_t num_dim,
const Input_ *const data,
const knncolle::Builder< Index_, Input_, Distance_, Matrix_ > & builder,
std::vector< std::shared_ptr< const knncolle::Prebuilt< Index_, Input_, Distance_ > > > & output,
Buffers< Input_ > & work ) const
inline
Template Parameters
Input_Numeric type of the input data.
Distance_Floating-point type of the distances.
Matrix_Class of the input data matrix for the neighbor search. This should satisfy the knncolle::Matrix interface.
Parameters
num_dimNumber of dimensions.
[in]dataPointer to an array of length equal to the product of num_dim and num_obs. This contains the embedding matrix for a modality, stored in column-major layout where each row is a dimension and each column is a cell. The block assignment for each cell should be the same as that in block.
builderAlgorithm to use for the neighbor search.
[out]outputVector in which to store the nearest-neighbor search indices constructed by builder. On output, this will have length equal to the number of blocks, where a new search index is constructed for each non-empty block. An empty block will be represented by a null pointer.
workTemporary buffers, typically created with create_buffers().

◆ build() [2/2]

template<typename Index_ , typename Block_ >
template<typename Input_ , typename Distance_ , class Matrix_ = knncolle::Matrix<Index_, Input_>>
std::vector< std::shared_ptr< const knncolle::Prebuilt< Index_, Input_, Distance_ > > > mumosa::BlockedIndicesFactory< Index_, Block_ >::build ( const std::size_t num_dim,
const Input_ *const data,
const knncolle::Builder< Index_, Input_, Distance_, Matrix_ > & builder ) const
inline

Overload of build() that handles some of the memory allocation.

Template Parameters
Input_Numeric type of the input data.
Distance_Floating-point type of the distances.
Matrix_Class of the input data matrix for the neighbor search. This should satisfy the knncolle::Matrix interface.
Parameters
num_dimNumber of dimensions.
[in]dataPointer to an array of length equal to the product of num_dim and num_obs. This contains the embedding matrix for a modality, stored in column-major layout where each row is a dimension and each column is a cell.
builderAlgorithm to use for the neighbor search.
Returns
Vector in which to store the nearest-neighbor search indices constructed by builder. This has length equal to the number of blocks, where a new search index is constructed for each non-empty block. Empty blocks are represented by null pointers.

The documentation for this class was generated from the following file: