scran_aggregate
Aggregate expression values across cells
Loading...
Searching...
No Matches
scran_aggregate Namespace Reference

Aggregate single-cell expression values. More...

Classes

struct  AggregateAcrossCellsBuffers
 Buffers for aggregate_across_cells(). More...
 
struct  AggregateAcrossCellsOptions
 Options for aggregate_across_cells(). More...
 
struct  AggregateAcrossCellsResults
 Results of aggregate_across_cells(). More...
 
struct  AggregateAcrossGenesBuffers
 Buffers for aggregate_across_genes(). More...
 
struct  AggregateAcrossGenesOptions
 Options for aggregate_across_genes(). More...
 
struct  AggregateAcrossGenesResults
 Results of aggregate_across_genes(). More...
 

Functions

template<typename Data_ , typename Index_ , typename Group_ , typename Sum_ , typename Detected_ >
void aggregate_across_cells (const tatami::Matrix< Data_, Index_ > &input, const Group_ *const group, const AggregateAcrossCellsBuffers< Sum_, Detected_ > &buffers, const AggregateAcrossCellsOptions &options)
 
template<typename Sum_ = double, typename Detected_ = int, typename Data_ , typename Index_ , typename Group_ >
AggregateAcrossCellsResults< Sum_, Detected_ > aggregate_across_cells (const tatami::Matrix< Data_, Index_ > &input, const Group_ *const group, const AggregateAcrossCellsOptions &options)
 
template<typename Data_ , typename Index_ , typename Gene_ , typename Weight_ , typename Sum_ >
void aggregate_across_genes (const tatami::Matrix< Data_, Index_ > &input, const std::vector< std::tuple< std::size_t, const Gene_ *, const Weight_ * > > &gene_sets, const AggregateAcrossGenesBuffers< Sum_ > &buffers, const AggregateAcrossGenesOptions &options)
 
template<typename Sum_ = double, typename Data_ , typename Index_ , typename Gene_ , typename Weight_ >
AggregateAcrossGenesResults< Sum_ > aggregate_across_genes (const tatami::Matrix< Data_, Index_ > &input, const std::vector< std::tuple< std::size_t, const Gene_ *, const Weight_ * > > &gene_sets, const AggregateAcrossGenesOptions &options)
 
template<typename Factor_ , typename Output_ >
std::vector< Factor_ > clean_factor (const std::size_t n, const Factor_ *const factor, Output_ *const cleaned)
 
template<typename Factor_ , typename Combined_ >
std::vector< std::vector< Factor_ > > combine_factors (const std::size_t n, const std::vector< const Factor_ * > &factors, Combined_ *const combined)
 
template<typename Factor_ , typename Number_ , typename Combined_ >
std::vector< std::vector< Factor_ > > combine_factors_unused (const std::size_t n, const std::vector< std::pair< const Factor_ *, Number_ > > &factors, Combined_ *const combined)
 

Detailed Description

Aggregate single-cell expression values.

Function Documentation

◆ aggregate_across_cells() [1/2]

template<typename Data_ , typename Index_ , typename Group_ , typename Sum_ , typename Detected_ >
void scran_aggregate::aggregate_across_cells ( const tatami::Matrix< Data_, Index_ > & input,
const Group_ *const group,
const AggregateAcrossCellsBuffers< Sum_, Detected_ > & buffers,
const AggregateAcrossCellsOptions & options )

Aggregate expression values across groups of cells for each gene. We report the sum of expression values and the number of cells with detected (i.e., positive) expression values in each group. This is typically used to create pseudo-bulk expression profiles for cluster/sample combinations. Expression values are generally expected to be counts so that the sums can be used as if they were counts from bulk data, e.g., for differential analyses with edgeR.

Template Parameters
Data_Type of data in the input matrix, should be numeric.
Index_Integer type of index in the input matrix.
Group_Integer type of the group assignments.
Sum_Numeric type of the sum, often the same as Data_.
Detected_Numeric type (usually integer) of the number of detected cells.
Parameters
inputThe input matrix, usually containing non-negative counts. Rows are features and columns are cells.
[in]groupPointer to an array of length equal to the number of columns of input, containing the assigned group for each cell. All entries should be integers in \([0, N)\) where \(N\) is the number of unique groups.
optionsFurther options.

◆ aggregate_across_cells() [2/2]

template<typename Sum_ = double, typename Detected_ = int, typename Data_ , typename Index_ , typename Group_ >
AggregateAcrossCellsResults< Sum_, Detected_ > scran_aggregate::aggregate_across_cells ( const tatami::Matrix< Data_, Index_ > & input,
const Group_ *const group,
const AggregateAcrossCellsOptions & options )

Overload of aggregate_across_cells() that allocates memory for the results.

Template Parameters
Sum_Numerict ype of the sum.
Detected_Numeric type (usually integer) of the number of detected cells.
Data_Type of data in the input matrix, should be numeric.
Index_Integer type of index in the input matrix.
Group_Integer type of the group assignments.
Parameters
inputThe input matrix, usually containing non-negative counts. Rows are features and columns are cells.
[in]groupPointer to an array of length equal to the number of columns of input, containing the assigned group for each cell. All entries should be integers in \([0, N)\) where \(N\) is the number of unique groups.
optionsFurther options.
Returns
Results of the aggregation, where the available statistics depend on AggregateAcrossCellsOptions.

◆ aggregate_across_genes() [1/2]

template<typename Data_ , typename Index_ , typename Gene_ , typename Weight_ , typename Sum_ >
void scran_aggregate::aggregate_across_genes ( const tatami::Matrix< Data_, Index_ > & input,
const std::vector< std::tuple< std::size_t, const Gene_ *, const Weight_ * > > & gene_sets,
const AggregateAcrossGenesBuffers< Sum_ > & buffers,
const AggregateAcrossGenesOptions & options )

Aggregate expression values across gene sets for each cell. This involves computing the sum/mean of expression values for any number of gene sets. The aim is to quantify the activity of signatures, pathways or regulons in each cell. Each gene in each set can also be weighted based on any a priori assumptions of their importance to the corresponding pathway.

Template Parameters
Data_Type of data in the input matrix, should be numeric.
Index_Integer type of index in the input matrix.
Gene_Integer type of the indices of genes in each set.
Weight_Floating-point type of the weights of genes in each set.
Sum_Floating-point type of the sum.
Parameters
inputMatrix of expression values where rows are features and columns are cells. This is usually normalized and possibly log-transformed, but the exact nature of the values depends on the application.
gene_setsVector of gene sets. Each tuple corresponds to a set and contains (i) the number of genes in the set, (ii) a pointer to the row indices of the genes in the set, and (iii) a pointer to the weights of the genes in the set. The weight pointer may be NULL, in which case all weights are set to 1.
[out]buffersCollection of buffers in which to store the sum/mean for each gene set and cell.
optionsFurther options.

◆ aggregate_across_genes() [2/2]

template<typename Sum_ = double, typename Data_ , typename Index_ , typename Gene_ , typename Weight_ >
AggregateAcrossGenesResults< Sum_ > scran_aggregate::aggregate_across_genes ( const tatami::Matrix< Data_, Index_ > & input,
const std::vector< std::tuple< std::size_t, const Gene_ *, const Weight_ * > > & gene_sets,
const AggregateAcrossGenesOptions & options )

Overload of aggregate_across_genes() that allocates memory for the results.

Template Parameters
Sum_Floating-point type of the sum.
Data_Type of data in the input matrix, should be numeric.
Index_Integer type of index in the input matrix.
Gene_Integer type of the indices of genes in each set.
Weight_Floating-point type of the weights of genes in each set.
Parameters
inputMatrix of expression values where rows are features and columns are cells.
gene_setsVector of gene sets. Each tuple corresponds to a set and contains (i) the number of genes in the set, (ii) a pointer to the row indices of the genes in the set, and (iii) a pointer to the weights of the genes in the set. The weight pointer may be NULL, in which case all weights are set to 1.
optionsFurther options.
Returns
Results of the aggregation.