tatami_stats
Matrix statistics for tatami
Loading...
Searching...
No Matches
Classes | Functions
tatami_stats::grouped_medians Namespace Reference

Functions for computing dimension-wise grouped medians. More...

Classes

struct  Options
 Grouped median calculation options. More...
 

Functions

template<typename Value_ , typename Index_ , typename Group_ , class GroupSizes_ , typename Output_ >
void apply (bool row, const tatami::Matrix< Value_, Index_ > *p, const Group_ *group, const GroupSizes_ &group_sizes, Output_ **output, const Options &mopt)
 
template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ >
std::vector< std::vector< Output_ > > by_row (const tatami::Matrix< Value_, Index_ > *p, const Group_ *group, const Options &mopt)
 
template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ >
std::vector< std::vector< Output_ > > by_row (const tatami::Matrix< Value_, Index_ > *p, const Group_ *group)
 
template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ >
std::vector< std::vector< Output_ > > by_column (const tatami::Matrix< Value_, Index_ > *p, const Group_ *group, const Options &mopt)
 
template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ >
std::vector< std::vector< Output_ > > by_column (const tatami::Matrix< Value_, Index_ > *p, const Group_ *group)
 

Detailed Description

Functions for computing dimension-wise grouped medians.

Function Documentation

◆ apply()

template<typename Value_ , typename Index_ , typename Group_ , class GroupSizes_ , typename Output_ >
void tatami_stats::grouped_medians::apply ( bool  row,
const tatami::Matrix< Value_, Index_ > *  p,
const Group_ *  group,
const GroupSizes_ &  group_sizes,
Output_ **  output,
const Options mopt 
)

Compute per-group medians for each element of a chosen dimension of a tatami::Matrix.

Template Parameters
Value_Type of the matrix value, should be numeric.
Index_Type of the row/column indices.
Group_Type of the group assignments for each column.
GroupSizes_Vector-like class that has size() and [ methods.
Output_Type of the output value. This should be floating-point to store potential averages.
Parameters
rowWhether to compute group-wise medians within each row. If false, medians are computed in each column instead.
pPointer to a tatami::Matrix.
[in]groupPointer to an array of length equal to the number of columns (if row = true) or rows (otherwise). Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups.
group_sizesVector-like object of length \(N\), specifying the number of columns assigned to each group. This can be created by calling tatami_stats::tabulate_groups() on group.
[out]outputPointer to an array of pointers of length equal to the number of groups. Each inner pointer should reference an array of length equal to the number of rows (if row = true) or columns (otherwise). On output, this will contain the row/column medians for each group (indexed according to the assignment in group).
moptMedian calculation options.

◆ by_row() [1/2]

template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ >
std::vector< std::vector< Output_ > > tatami_stats::grouped_medians::by_row ( const tatami::Matrix< Value_, Index_ > *  p,
const Group_ *  group,
const Options mopt 
)

Wrapper around apply() for row-wise grouped medians.

Template Parameters
Output_Type of the output.
Value_Type of the matrix value.
Index_Type of the row/column indices.
Group_Type of the group assignments for each row.
Parameters
pPointer to a tatami::Matrix.
[in]groupPointer to an array of length equal to the number of columns. Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups.
moptMedian calculation options.
Returns
Vector of length equal to the number of groups. Each entry is a vector of length equal to the number of rows, containing the row-wise medians for the corresponding group.

◆ by_row() [2/2]

template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ >
std::vector< std::vector< Output_ > > tatami_stats::grouped_medians::by_row ( const tatami::Matrix< Value_, Index_ > *  p,
const Group_ *  group 
)

Overload with default options.

Template Parameters
Output_Type of the output.
Value_Type of the matrix value.
Index_Type of the row/column indices.
Group_Type of the group assignments for each column.
Parameters
pPointer to a tatami::Matrix.
[in]groupPointer to an array of length equal to the number of columns. Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups.
Returns
Vector of length equal to the number of groups. Each entry is a vector of length equal to the number of rows, containing the row-wise medians for the corresponding group.

◆ by_column() [1/2]

template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ >
std::vector< std::vector< Output_ > > tatami_stats::grouped_medians::by_column ( const tatami::Matrix< Value_, Index_ > *  p,
const Group_ *  group,
const Options mopt 
)

Wrapper around apply() for column-wise grouped medians.

Template Parameters
Output_Type of the output.
Value_Type of the matrix value.
Index_Type of the column/column indices.
Group_Type of the group assignments for each column.
Parameters
pPointer to a tatami::Matrix.
[in]groupPointer to an array of length equal to the number of rows. Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups.
moptMedian calculation options.
Returns
Vector of length equal to the number of groups. Each entry is a vector of length equal to the number of columns, containing the column-wise medians for the corresponding group.

◆ by_column() [2/2]

template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ >
std::vector< std::vector< Output_ > > tatami_stats::grouped_medians::by_column ( const tatami::Matrix< Value_, Index_ > *  p,
const Group_ *  group 
)

Overload with default options.

Template Parameters
Output_Type of the output.
Value_Type of the matrix value.
Index_Type of the column/column indices.
Group_Type of the group assignments for each column.
Parameters
pPointer to a tatami::Matrix.
[in]groupPointer to an array of length equal to the number of rows. Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups.
Returns
Vector of length equal to the number of groups. Each entry is a vector of length equal to the number of columns, containing the column-wise medians for the corresponding group.