scran_norm
Scaling normalization of single-cell data
|
This repository contains functions to perform scaling normalization and log-transformation of a gene-by-cell count matrix. Normalization removes per-cell scaling biases such as differences in capture efficiency and sequencing depth, while the log-transformation provides some variance stabilization and allows differences in values to be interpreted as log-fold changes. The code itself was originally derived from the scran R package, factored out into a separate C++ library for easier re-use.
Given a measure of the per-cell scaling bias - for example, the sum of counts for a cell - we can convert them into centered size factors:
Alternatively, in the presence of blocks, we adjust our centering so that the mean size factor in each block is no less than 1. This avoids inflated variances from applying small size factors to low-coverage blocks.
If our size factors might contain invalid values (i.e., zero, negative, or non-finite), we can sanitize them prior to the construction of the log-normalized matrix:
Finally, we convert our tatami::Matrix
of counts into a log-transformed normalized matrix:
Check out the reference documentation for more details.
FetchContent
If you're using CMake, you just need to add something like this to your CMakeLists.txt
:
Then you can link to scran_norm to make the headers available during compilation:
find_package()
To install the library, use:
By default, this will use FetchContent
to fetch all external dependencies. If you want to install them manually, use -DSCRAN_NORM_FETCH_EXTERN=OFF
. See the tags in extern/CMakeLists.txt
to find compatible versions of each dependency.
If you're not using CMake, the simple approach is to just copy the files in include/
- either directly or with Git submodules - and include their path during compilation with, e.g., GCC's -I
. This requires the external dependencies listed in extern/CMakeLists.txt
, which also need to be made available during compilation.