|
| double | compute_variable_weight (const double s, const VariableWeightParameters ¶ms) |
| |
| template<typename GetBlockSize_ , typename SetBlockWeight_ > |
| void | compute_weights (const std::size_t num_blocks, GetBlockSize_ get_block_size, const WeightPolicy policy, const VariableWeightParameters &variable, SetBlockWeight_ set_block_weight) |
| |
| template<typename Size_ , typename Weight_ > |
| void | compute_weights (const std::size_t num_blocks, const Size_ *const sizes, const WeightPolicy policy, const VariableWeightParameters &variable, Weight_ *const weights) |
| |
| template<typename Weight_ = double, typename Size_ > |
| std::vector< Weight_ > | compute_weights (const std::vector< Size_ > &sizes, const WeightPolicy policy, const VariableWeightParameters &variable) |
| |
Blocking utilities for libscran.
Assign a variable weight to each block of cells, for use in computing a weighted average across blocks. The weight for each block is calculated from the size of that block.
Blocks that are "large enough" (i.e., above the upper bound) are considered to be equally trustworthy and receive the same weight, ensuring that each block contributes equally to the weighted average. By comparison, very small blocks receive lower weight as their statistics are generally less stable.
- Parameters
-
| s | Size of the block, in terms of the number of cells in that block. |
| params | Parameters for the weight calculation, consisting of the lower and upper bounds. |
- Returns
- Weight of the block, to use for computing a weighted average across blocks.
template<typename GetBlockSize_ , typename SetBlockWeight_ >
| void scran_blocks::compute_weights |
( |
const std::size_t | num_blocks, |
|
|
GetBlockSize_ | get_block_size, |
|
|
const WeightPolicy | policy, |
|
|
const VariableWeightParameters & | variable, |
|
|
SetBlockWeight_ | set_block_weight ) |
Compute weights for multiple blocks based on their size and the weighting policy. For variable weights, this function will call compute_variable_weight() for each block.
Weights should be interpreted as relative values within a single compute_weights() call, i.e., weights from different calls may not be comparable. They are typically used to compute a weighted average of statistics across blocks.
Empty blocks (i.e., size zero) will always be assigned a weight of zero. This is guaranteed for all policy and valid parametrizations of variable.
- Template Parameters
-
| GetBlockSize_ | Function that accepts a size_t and returns a number. |
| SetBlockWeight_ | Function that accepts a size_t and the block weight. The return value is ignored. |
- Parameters
-
| num_blocks | Number of blocks. |
| get_block_size | Function that accepts a block index in [0, num_blocks) and returns the size of that block. |
| policy | Policy for weighting blocks of different sizes. |
| variable | Parameters for the variable block weights. |
| set_block_weight | Function that accepts a block index in [0, num_blocks) and the associated block weight. It is expected to store the block weight in some data structure. |