Compute the median and MAD from an array of values.
Pretty much as it says on the can; computes the median of an array of values first, and uses the median to then compute the median absolute deviation (MAD) from that array. We support calculation of medians and MADs for separate "blocks" of observations in the same array. These statistics can be used in FilterOutliers to obtain filter thresholds for removing outliers.
Whether to compute the median and MAD after log-transformation of the values. This is useful for defining thresholds based on fold changes from the center. If true, all values are assumed to be non-negative.
static std::vector< int > scran::ComputeMedianMad::compute_block_starts
(
size_t
n,
const Block *
block
)
inlinestatic
Template Parameters
Block
Integer type, containing the block IDs.
Parameters
n
Number of observations.
[in]
block
Pointer to an array of block identifiers. If provided, the array should be of length equal to n. Values should be integer IDs in where is the number of blocks. If a null pointer is supplied, all observations are assumed to belong to the same block.
Returns
Vector of indices specifying the start position for each block on the workspace buffer, if observations from successive blocks were arranged contiguously onto the buffer.
Optional pointer to an array of block identifiers. If provided, the array should be of length equal to ncells. Values should be integer IDs in where is the number of blocks. If a null pointer is supplied, all observations are assumed to belong to the same block.
starts
Vector of start positions for the observations from each block, typically generated by calling compute_block_starts() on n and block.
[in]
metrics
Pointer to an array of observations of length n.
buffer
Pointer to an array of length n, to be used as a workspace.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Template Parameters
Block
Integer type, containing the block IDs.
Input
Type of observation, numeric.
Parameters
n
Number of observations.
[in]
block
Optional pointer to an array of block identifiers. If provided, the array should be of length equal to ncells. Values should be integer IDs in where is the number of blocks. If a null pointer is supplied, all observations are assumed to belong to the same block.
[in]
metrics
Pointer to an array of observations of length n.
Returns
Median and the MAD for each block in metrics.
The documentation for this class was generated from the following file: