Usage
SpaNorm(
spe,
sample.p = 0.25,
gene.model = c("nb"),
adj.method = c("auto", "logpac", "pearson", "medbio", "meanbio"),
scale.factor = 1,
df.tps = 6,
lambda.a = 1e-04,
batch = NULL,
tol = 1e-04,
step.factor = 0.5,
maxit.nb = 50,
maxit.psi = 25,
maxn.psi = 500,
overwrite = FALSE,
backend = c("auto", "cpu", "gpu"),
BPPARAM = BiocParallel::SerialParam(),
verbose = TRUE,
assay = NULL,
...
)
## S4 method for signature 'SpatialExperiment'
SpaNorm(
spe,
sample.p = 0.25,
gene.model = c("nb"),
adj.method = c("auto", "logpac", "pearson", "medbio", "meanbio"),
scale.factor = 1,
df.tps = 6,
lambda.a = 1e-04,
batch = NULL,
tol = 1e-04,
step.factor = 0.5,
maxit.nb = 50,
maxit.psi = 25,
maxn.psi = 500,
overwrite = FALSE,
backend = c("auto", "cpu", "gpu"),
BPPARAM = BiocParallel::SerialParam(),
verbose = TRUE,
assay = NULL,
...
)
## S4 method for signature 'Seurat'
SpaNorm(
spe,
sample.p = 0.25,
gene.model = c("nb"),
adj.method = c("auto", "logpac", "pearson", "medbio", "meanbio"),
scale.factor = 1,
df.tps = 6,
lambda.a = 1e-04,
batch = NULL,
tol = 1e-04,
step.factor = 0.5,
maxit.nb = 50,
maxit.psi = 25,
maxn.psi = 500,
overwrite = FALSE,
backend = c("auto", "cpu", "gpu"),
BPPARAM = BiocParallel::SerialParam(),
verbose = TRUE,
assay = NULL,
...
)
Details
SpaNorm works by first fitting a spatial regression model for library size to the data. Normalised data can then be computed using various adjustment approaches. When a negative binomial gene-model is used, the data can be adjusted using the following approaches: ‘logpac’, ‘pearson’, ‘medbio’, and ‘meanbio’.
The df.tps parameter specifies the degrees of freedom for the thin-plate spline. If only 1 value is provided, it specifies the degrees of freedom of the biology with the degrees of freedom of the library size being half of that. If 2 values are provided, the first value specifies the degrees of freedom of the biology and the second value specifies the degrees of freedom of the library size. For rectangular tissues, df.tps specifies the degrees of freedom along the length, with the degrees of freedom along the width calculated ceiling(width / length * df.tps).
Similarly, the lambda.a parameter specifies the smoothing parameter for regularizing regression coefficients. If only 1 value is provided, it specifies the lambda.a for both the biology and library size functions. If 2 values are provided, the first value specifies the lambda.a for the biology and the second value specifies the lambda.a for the library size. Batch effects are not regularised.
If the counts assay is a DelayedArray (e.g. disk-backed via HDF5Array), the normalisation step is automatically performed block-wise so the full matrix is never realised in memory at once; the results are identical to the in-memory path. The block size follows DelayedArray’s global auto block size, which can be tuned with DelayedArray::setAutoBlockSize().
Batch effects can be specified using the batch parameter. If this parameter is a vector, a design matrix will be created within the function using model.matrix. If a custom design is provided in the form of a numeric matrix, this should ideally be created using model.matrix. The batch matrix should be created with an intercept term. The SpaNorm function will automatically detect the intercept term and remove the relevant column. Alternatively, users can subset the model matrix to remove this column manually. Please note that the model formula should include the intercept term and that the intercept column should be subset out after.