... | ... |
@@ -11,7 +11,7 @@ |
11 | 11 |
#' @slot W a matrix, specifying the covariate matrix of the linear model. |
12 | 12 |
#' @slot alpha a matrix, specifying the coefficients of the linear model. |
13 | 13 |
#' @slot gmean a numeric, specifying the mean estimate for each gene in the linear model. |
14 |
-#' @slot psi a numeric, specifying the over-dispersion parameter for each geneif a negative binomial model was used (or a vector of NAs if another gene model is used). |
|
14 |
+#' @slot psi a numeric, specifying the over-dispersion parameter for each gene if a negative binomial model was used (or a vector of NAs if another gene model is used). |
|
15 | 15 |
#' @slot isbio a logical, specifying the columns of the covariate matrix that represent biology. |
16 | 16 |
#' @slot loglik a numeric, specifying the log-likelihood of the model at each external iteration. |
17 | 17 |
#' |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-#' Spatially-dependent normalisation for spatial transcriptomics datas |
|
1 |
+#' Spatially-dependent normalisation for spatial transcriptomics data |
|
2 | 2 |
#' |
3 | 3 |
#' Performs normalisation of spatial transcriptomics data using spatially-dependent spot- and gene- specific size factors. |
4 | 4 |
#' |
... | ... |
@@ -15,8 +15,8 @@ |
15 | 15 |
#' @param maxit.psi a numeric, specifying the maximum number of IRLS iterations to estimate the dispersion parameter (default is 25). |
16 | 16 |
#' @param maxn.psi a numeric, specifying the maximum number of cells/spots to sample for dispersion estimation (default is 500). |
17 | 17 |
#' @param tol a numeric, specifying the tolerance for convergence (default is 1e-4). |
18 |
-#' @param overwrite a logical, specifying wether to force recomputation and overwrite an existing fit (default FALSE). Note that if df.tps, batch, lambda.a, or gene.model are changed, the model is recomputed and overwritten. |
|
19 |
-#' @param verbose a logical, specifying wether to show update messages (default TRUE). |
|
18 |
+#' @param overwrite a logical, specifying whether to force recomputation and overwrite an existing fit (default FALSE). Note that if df.tps, batch, lambda.a, or gene.model are changed, the model is recomputed and overwritten. |
|
19 |
+#' @param verbose a logical, specifying whether to show update messages (default TRUE). |
|
20 | 20 |
#' @param ... other parameters fitting parameters. |
21 | 21 |
#' |
22 | 22 |
#' @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'. |
... | ... |
@@ -10,7 +10,7 @@ SpaNorm is a spatially aware library size normalisation method that removes libr |
10 | 10 |
SpaNorm uses a unique approach to spatially constraint modelling approach to model gene expression (e.g., counts) and remove library size effects, while retaining biology. It achieves this through three key innovations: |
11 | 11 |
|
12 | 12 |
1. Computing spatially smooth functions (using thin plate splines) to represent the gene- and location-/cell-/spot- specific size factors. |
13 |
-1. Optmial decomposition of spatial variation into spatially smooth library size associated (technical) and library size independent (biology) variation using generalized linear models (GLMs). |
|
13 |
+1. Optimal decomposition of spatial variation into spatially smooth library size associated (technical) and library size independent (biology) variation using generalized linear models (GLMs). |
|
14 | 14 |
1. Adjustment of data using percentile adjusted counts (PAC) (Salim et al., 2022), as well as other adjustment approaches (e.g., Pearson). |
15 | 15 |
|
16 | 16 |
## Installation |
... | ... |
@@ -120,7 +120,7 @@ HumanDLPFC = SpaNorm(HumanDLPFC) |
120 | 120 |
HumanDLPFC |
121 | 121 |
``` |
122 | 122 |
|
123 |
-The above output (which can be switched off by setting `verbose = FALSE`), shows the two steps of normalisation. In the model fitting step, `r round(0.25 * ncol(HumanDLPFC))` cells/spots are used to fit the negative binomial (NB) model. Subsequent output shows that this fit is performed by alternating between estimation of the dispersion parameter and estimation of the NB parameters by fixing the dispersion. The output also shows that each intermmediate fit converges, and so does the final fit. The accuracy of the fit can be controlled by modifying the tolerance parameter `tol` (default `1e-4`). |
|
123 |
+The above output (which can be switched off by setting `verbose = FALSE`), shows the two steps of normalisation. In the model fitting step, `r round(0.25 * ncol(HumanDLPFC))` cells/spots are used to fit the negative binomial (NB) model. Subsequent output shows that this fit is performed by alternating between estimation of the dispersion parameter and estimation of the NB parameters by fixing the dispersion. The output also shows that each intermediate fit converges, and so does the final fit. The accuracy of the fit can be controlled by modifying the tolerance parameter `tol` (default `1e-4`). |
|
124 | 124 |
|
125 | 125 |
Next, data is adjusted using the fit model. The following approaches are implemented for count data: |
126 | 126 |
|
... | ... |
@@ -144,9 +144,9 @@ p_logpac = plotSpatial( |
144 | 144 |
p_region + p_logpac |
145 | 145 |
``` |
146 | 146 |
|
147 |
-# Computing alternative adjusments using a precomputed SpaNorm fit |
|
147 |
+# Computing alternative adjustments using a precomputed SpaNorm fit |
|
148 | 148 |
|
149 |
-As no appropriate slot exists for storing model parameters, we currently save them in the metadata slot with the name "SpaNorm". This also means that subsetting features (i.e., genes) or observatins (i.e., cells/spots/loci) does not subset the model. In such an instance, the SpaNorm function will realise that the model no longer matches the data and restimates when called. If instead the model is valid for the data, the existing fit is extracted and reused. |
|
149 |
+As no appropriate slot exists for storing model parameters, we currently save them in the metadata slot with the name "SpaNorm". This also means that subsetting features (i.e., genes) or observations (i.e., cells/spots/loci) does not subset the model. In such an instance, the SpaNorm function will realise that the model no longer matches the data and re-estimates when called. If instead the model is valid for the data, the existing fit is extracted and reused. |
|
150 | 150 |
|
151 | 151 |
The fit can be manually retrieved as below for users wishing to reuse the model outside the SpaNorm framework. Otherwise, calling `SpaNorm()` on an object containing the fit will automatically use it. |
152 | 152 |
|
... | ... |
@@ -226,7 +226,7 @@ p_logpac_2 + p_logpac_6 |
226 | 226 |
|
227 | 227 |
# Enhancing signal |
228 | 228 |
|
229 |
-As the counts for the MOBP gene are very low, we see artefacts in the adjusted counts. As we have a model for the genes, we can increase the signal by adjusting all means by a constant factor. Applying a scale factor of 4 shows how the adjusted data are more continuous, with significant enrichment in the white matter. |
|
229 |
+As the counts for the MOBP gene are very low, we see artifacts in the adjusted counts. As we have a model for the genes, we can increase the signal by adjusting all means by a constant factor. Applying a scale factor of 4 shows how the adjusted data are more continuous, with significant enrichment in the white matter. |
|
230 | 230 |
|
231 | 231 |
```{r fig.width=7.5, fig.height=4.25} |
232 | 232 |
# scale.factor = 1 (default) |