scran
C++ library for basic single-cell RNA-seq analyses
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
scran::SummarizeEffects Class Reference

Summarize pairwise effects into summary statistics per group. More...

#include <SummarizeEffects.hpp>

Classes

struct  Defaults
 Default parameter settings. More...
 

Public Member Functions

SummarizeEffectsset_num_threads (int n=Defaults::num_threads)
 
SummarizeEffectsset_compute_min (bool c=Defaults::compute_min)
 
SummarizeEffectsset_compute_mean (bool c=Defaults::compute_mean)
 
SummarizeEffectsset_compute_median (bool c=Defaults::compute_median)
 
SummarizeEffectsset_compute_max (bool c=Defaults::compute_max)
 
SummarizeEffectsset_compute_min_rank (bool c=Defaults::compute_min_rank)
 
template<typename Stat >
void run (size_t ngenes, size_t ngroups, const Stat *effects, std::vector< std::vector< Stat * > > summaries) const
 
template<typename Stat >
std::vector< std::vector< std::vector< Stat > > > run (size_t ngenes, size_t ngroups, const Stat *effects) const
 

Detailed Description

Summarize pairwise effects into summary statistics per group.

This class computes the statistics that are used for marker detection in ScoreMarkers. Briefly, given n groups, each group is involved in n - 1 pairwise comparisons and thus has n - 1 effect sizes, as computed by PairwiseEffects. For each group, we compute summary statistics - e.g., the minimum, median, mean - of the effect sizes across all of that group's comparisons. Users can then sort by any of these summaries to obtain a ranking of potential marker genes for each group.

The choice of summary statistic dictates the interpretation of the ranking. Given a group X:

The exact definition of "large" and "small" depends on the choice of effect size from PairwiseEffects. For Cohen's d, LFC and delta-detected, the value must be positive to be considered "large", and negative to be considered "small". For the AUC, a value greater than 0.5 is considered "large" and less than 0.5 is considered "small".

The interpretation above is also contingent on the log-fold change threshold used in PairwiseEffects. For positive thresholds, small effects cannot be unambiguously interpreted as downregulation, as the effect is already adjusted to account for the threshold. As a result, only large effects can be interpreted as evidence for upregulation.

NaN effect sizes are allowed, e.g., if two groups do not exist in the same block for a blocked analysis in PairwiseEffects. This class will ignore NaN values when computing each summary. If all effects are NaN for a particular group, the summary statistic will also be NaN.

All choices of summary statistics are enumerated by differential_analysis::summary.

Member Function Documentation

◆ set_num_threads()

SummarizeEffects & scran::SummarizeEffects::set_num_threads ( int  n = Defaults::num_threads)
inline
Parameters
nNumber of threads to use.
Returns
A reference to this SummarizeEffects object.

◆ set_compute_min()

SummarizeEffects & scran::SummarizeEffects::set_compute_min ( bool  c = Defaults::compute_min)
inline
Parameters
cWhether to report the minimum of the pairwise effects.
Returns
A reference to this SummarizeEffects object.

This has no effect on the run() overload that accepts a summaries vector. For this method, the minimum is calculated if summaries[differential_analysis::MIN] is of non-zero length.

◆ set_compute_mean()

SummarizeEffects & scran::SummarizeEffects::set_compute_mean ( bool  c = Defaults::compute_mean)
inline
Parameters
cWhether to report the mean of the pairwise effects.
Returns
A reference to this SummarizeEffects object.

This has no effect on the run() overload that accepts a summaries vector. For this method, the minimum is calculated if summaries[differential_analysis::MEAN] is of non-zero length.

◆ set_compute_median()

SummarizeEffects & scran::SummarizeEffects::set_compute_median ( bool  c = Defaults::compute_median)
inline
Parameters
cWhether to report the median of the pairwise effects.
Returns
A reference to this SummarizeEffects object.

This has no effect on the run() overload that accepts a summaries vector. For this method, the minimum is calculated if summaries[differential_analysis::MEDIAN] is of non-zero length.

◆ set_compute_max()

SummarizeEffects & scran::SummarizeEffects::set_compute_max ( bool  c = Defaults::compute_max)
inline
Parameters
cWhether to report the maximum of the pairwise effects.
Returns
A reference to this SummarizeEffects object.

This has no effect on the run() overload that accepts a summaries vector. For this method, the minimum is calculated if summaries[differential_analysis::MAX] is of non-zero length.

◆ set_compute_min_rank()

SummarizeEffects & scran::SummarizeEffects::set_compute_min_rank ( bool  c = Defaults::compute_min_rank)
inline
Parameters
cWhether to report the min-rank of the pairwise effects.
Returns
A reference to this SummarizeEffects object.

This has no effect on the run() overload that accepts a summaries vector. For this method, the minimum is calculated if summaries[differential_analysis::MIN_RANK] is of non-zero length.

◆ run() [1/2]

template<typename Stat >
void scran::SummarizeEffects::run ( size_t  ngenes,
size_t  ngroups,
const Stat *  effects,
std::vector< std::vector< Stat * > >  summaries 
) const
inline

Summarize the effect sizes for the pairwise comparisons to obtain a set of summary statistics for each gene in each group.

If summaries is of length 0, no summaries are computed. If any of the inner vectors of summaries are of length 0, the corresponding summary statistic is not computed.

Template Parameters
StatFloating point type for the statistics.
Parameters
ngenesNumber of genes.
ngroupsNumber of groups.
[in]effectsPointer to a 3-dimensional array containing the pairwise statistics, see PairwiseEffects::Results for details.
[out]summariesVector of vector of pointers to arrays of length equal to the number of genes. The vector should be of length equal to differential_analysis::n_summaries (see differential_analysis::summary). Each inner vector corresponds to a summary statistic - i.e., minimum, mean, median, maximum and min-rank - and should be of length equal to the number of groups. Each pointer corresponds to a group, and points to an array that is used to store the associated summary statistic across all genes for that group.

◆ run() [2/2]

template<typename Stat >
std::vector< std::vector< std::vector< Stat > > > scran::SummarizeEffects::run ( size_t  ngenes,
size_t  ngroups,
const Stat *  effects 
) const
inline

Summarize the effect sizes for the pairwise comparisons to obtain a set of summary statistics for each gene in each group.

If summaries is of length 0, no summaries are computed. If any of the inner vectors of summaries are of length 0, the corresponding summary statistic is not computed.

Template Parameters
StatFloating point type for the statistics.
Parameters
ngenesNumber of genes.
ngroupsNumber of groups.
[in]effectsPointer to a 3-dimensional array containing the pairwise statistics, see PairwiseEffects::Results for details.
Returns
A vector of vectors of vectors containing summary effects for each gene in each group. The vector is of length equal to differential_analysis::n_summaries (see differential_analysis::summary). Each inner vector corresponds to a summary statistic - i.e., minimum, mean, median, maximum and min-rank - and is of length equal to the number of groups. Each pointer corresponds to a group, and points to an array containing the associated summary statistic across all genes for that group.

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