scran
C++ library for basic single-cell RNA-seq analyses
|
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 | |
ScoreFeatureSet & | set_block_weight_policy (WeightPolicy b=Defaults::block_weight_policy) |
ScoreFeatureSet & | set_num_threads (int n=Defaults::num_threads) |
ScoreFeatureSet & | set_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 |
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.
|
inline |
b | Policy to use when dealing with multiple blocks containing different numbers of cells. |
ScoreFeatureSet
instance.
|
inline |
n | Number of threads to use. |
ScoreFeatureSet
object.
|
inline |
s | Whether to scale features to unit variance. |
ScoreFeatureSet
object.
|
inline |
T | Floating point type for the data. |
IDX | Integer type for the indices. |
X | Integer type for the feature filter. |
Block | Integer type for the block assignments. |
[in] | mat | Pointer to the input matrix. Columns should contain cells while rows should contain genes. |
[in] | features | Pointer 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] | block | Pointer 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. |
Results
object containing the per-cell scores and per-feature weights.
|
inline |
An overload of run()
where all cells are assumed to belong to the same block.
T | Floating point type for the data. |
IDX | Integer type for the indices. |
X | Integer type for the feature filter. |
[in] | mat | Pointer to the input matrix. Columns should contain cells while rows should contain genes. |
[in] | features | Pointer 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. |
Results
object containing the per-cell scores and per-feature weights.