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

Compute per-cell scores for a given feature set. More...

#include <ScoreFeatureSet.hpp>

Classes

struct  Defaults
 Default parameters. More...
 
struct  Results
 Feature set scoring results. More...
 

Public Member Functions

ScoreFeatureSetset_block_weight_policy (WeightPolicy b=Defaults::block_weight_policy)
 
ScoreFeatureSetset_num_threads (int n=Defaults::num_threads)
 
ScoreFeatureSetset_scale (bool s=Defaults::scale)
 
template<typename T , typename IDX , typename X , typename Block >
Results run_blocked (const tatami::Matrix< T, IDX > *mat, const X *features, const Block *block) const
 
template<typename T , typename IDX , typename X >
Results run (const tatami::Matrix< T, IDX > *mat, const X *features) const
 

Detailed Description

Compute per-cell scores for a given feature set.

Per-cell scores are defined as the column means of the rank-1 approximation of the input matrix for the subset of features in the set. The assumption here is that the primary activity of the feature set can be quantified by the largest component of variance amongst its features. (If this was not the case, one could argue that this feature set is not well-suited to capture the biology attributed to it.) In effect, the rotation vector defines weights for all features in the set, focusing on genes that contribute to the primary activity. This is based on the GSDecon package from Jason Hackney and is implemented using SimplePca.

For multi-block analyses, we extend this approach by performing the PCA on the residuals generated after centering each block in ResidualPca. Each cell is projected onto this rotation vector, and the feature set score for each cell is then defined from the ensuing rank-1 approximation. This approach avoids comparing cells between blocks and favors blocks where the feature set has greater (relative) activity. In addition, blocks can be weighted so that they contribute equally to the rotation vector, regardless of the number of cells - see ResidualPca::set_weight_policy() for more details.

For a typical log-expression input matrix, the per-cell scores can be interpreted as the mean log-expression across all features in the set. The importance of each feature is quantified by the absolute value of the weights.

Member Function Documentation

◆ set_block_weight_policy()

ScoreFeatureSet & scran::ScoreFeatureSet::set_block_weight_policy ( WeightPolicy  b = Defaults::block_weight_policy)
inline
Parameters
bPolicy to use when dealing with multiple blocks containing different numbers of cells.
Returns
A reference to this ScoreFeatureSet instance.

◆ set_num_threads()

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

◆ set_scale()

ScoreFeatureSet & scran::ScoreFeatureSet::set_scale ( bool  s = Defaults::scale)
inline
Parameters
sWhether to scale features to unit variance.
Returns
A reference to this ScoreFeatureSet object.

◆ run_blocked()

template<typename T , typename IDX , typename X , typename Block >
Results scran::ScoreFeatureSet::run_blocked ( const tatami::Matrix< T, IDX > *  mat,
const X *  features,
const Block *  block 
) const
inline
Template Parameters
TFloating point type for the data.
IDXInteger type for the indices.
XInteger type for the feature filter.
BlockInteger type for the block assignments.
Parameters
[in]matPointer to the input matrix. Columns should contain cells while rows should contain genes.
[in]featuresPointer to an array of length equal to the number of rows in mat, specifying the features in the set of interest. Non-zero values indicate that the corresponding row is part of the feature set.
[in]blockPointer to an array of length equal to the number of columns in mat. This should contain the blocking factor as 0-based block assignments (i.e., for n blocks, block identities should run from 0 to n-1 with at least one entry for each block.) If this is NULL, all cells are assumed to belong to the same block.
Returns
A Results object containing the per-cell scores and per-feature weights.

◆ run()

template<typename T , typename IDX , typename X >
Results scran::ScoreFeatureSet::run ( const tatami::Matrix< T, IDX > *  mat,
const X *  features 
) const
inline

An overload of run() where all cells are assumed to belong to the same block.

Template Parameters
TFloating point type for the data.
IDXInteger type for the indices.
XInteger type for the feature filter.
Parameters
[in]matPointer to the input matrix. Columns should contain cells while rows should contain genes.
[in]featuresPointer to an array of length equal to the number of rows in mat, specifying the features in the set of interest. Non-zero values indicate that the corresponding row is part of the feature set.
Returns
A Results object containing the per-cell scores and per-feature weights.

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