sigdots_prepare() makes the expression matrix x that sigdots() takes from a matrix of
raw counts. It is the preparation used in the SigDoTS paper's simulations; any other
normalisation and gene selection (Seurat's, scran's, ...) can be used instead.
Arguments
- counts
The raw counts: one row per gene and one column per spot, as most tools return them, with the gene names as row names and the spot identifiers as column names. A matrix or a sparse
Matrix.- n_genes
The number of genes to keep (a whole number, 2000 by default). All genes are kept when there are fewer.
- scale_factor
Each spot's counts are scaled to this total before the log transform (10,000 by default).
Value
A numeric matrix with one row per spot and one column per selected gene (the spot
identifiers as row names, the gene names as column names), ready for sigdots().
Details
Three steps:
Normalisation: the counts of each spot are divided by the spot's total count and multiplied by
scale_factor.Log transform: log(1 + value), as
Seurat::NormalizeData()does by default.Gene selection: the variance of every gene's log-normalised values across the spots is computed, and the
n_genesgenes with the largest variance are kept, in decreasing order of variance.
The values are not scaled to variance 1. A sparse dgCMatrix stays sparse until the
selected genes are turned into the dense result. Spots with a total count of 0 stop the
function; remove them first.
