Browse code

Reduce further the runtimes of examples

Gabriele Sales authored on 10/02/2023 08:14:04
Showing 1 changed files
... ...
@@ -72,9 +72,9 @@ Expression Histology, using the
72 72
 \href{https://github.com/Teichlab/SpatialDE}{\strong{SpatialDE}} Python package.
73 73
 }
74 74
 \examples{
75
-## Mock up a SpatialExperiment object wit 25 cells, 100 genes
75
+## Mock up a SpatialExperiment object wit 100 cells and 3 genes
76 76
 set.seed(42)
77
-spe <- mockSVG(size = 5, tot_genes = 100, de_genes = 10, return_SPE = TRUE)
77
+spe <- mockSVG(size = 10, tot_genes = 3, de_genes = 1, return_SPE = TRUE)
78 78
 
79 79
 ## Run spatialDE
80 80
 de_results <- spatialDE(spe)
Browse code

Reduce the complexity of the spatialPatterns example

Gabriele Sales authored on 27/01/2023 16:20:04
Showing 1 changed files
... ...
@@ -72,9 +72,9 @@ Expression Histology, using the
72 72
 \href{https://github.com/Teichlab/SpatialDE}{\strong{SpatialDE}} Python package.
73 73
 }
74 74
 \examples{
75
-## Mock up a SpatialExperiment object wit 100 cells, 200 genes
75
+## Mock up a SpatialExperiment object wit 25 cells, 100 genes
76 76
 set.seed(42)
77
-spe <- mockSVG(size = 10, tot_genes = 200, de_genes = 20, return_SPE = TRUE)
77
+spe <- mockSVG(size = 5, tot_genes = 100, de_genes = 10, return_SPE = TRUE)
78 78
 
79 79
 ## Run spatialDE
80 80
 de_results <- spatialDE(spe)
Browse code

Refactor plots function

davidecrs authored on 14/06/2021 07:57:10
Showing 1 changed files
... ...
@@ -101,5 +101,5 @@ The individual steps performed by this function: \code{\link[=stabilize]{stabili
101 101
 \code{\link[=regress_out]{regress_out()}} and \code{\link[=spatial_patterns]{spatial_patterns()}}.
102 102
 }
103 103
 \author{
104
-Davide Corso, Milan Malfait
104
+Davide Corso, Milan Malfait, Lambda Moses
105 105
 }
Browse code

Add 'matrix' methods for `spatialPatterns()` and `modelSearch()`

Milan Malfait authored on 01/06/2021 11:28:59
Showing 1 changed files
... ...
@@ -2,30 +2,46 @@
2 2
 % Please edit documentation in R/aeh.R
3 3
 \name{spatialPatterns}
4 4
 \alias{spatialPatterns}
5
+\alias{spatialPatterns,matrix-method}
5 6
 \alias{spatialPatterns,SpatialExperiment-method}
6 7
 \title{Automatic expression histology in \strong{SpatialDE}}
7 8
 \usage{
8 9
 spatialPatterns(x, de_results, ...)
9 10
 
11
+\S4method{spatialPatterns}{matrix}(
12
+  x,
13
+  de_results,
14
+  coordinates,
15
+  qval_thresh = 0.05,
16
+  n_patterns,
17
+  length,
18
+  verbose = FALSE
19
+)
20
+
10 21
 \S4method{spatialPatterns}{SpatialExperiment}(
11 22
   x,
12 23
   de_results,
13
-  assay_type = "counts",
14 24
   qval_thresh = 0.05,
15 25
   n_patterns,
16 26
   length,
27
+  assay_type = "counts",
17 28
   verbose = FALSE
18 29
 )
19 30
 }
20 31
 \arguments{
21
-\item{x}{\linkS4class{SpatialExperiment} object.}
32
+\item{x}{A numeric \code{matrix} of counts where genes are rows and cells are columns.
33
+
34
+Alternatively, a \linkS4class{SpatialExperiment} object.}
22 35
 
23 36
 \item{de_results}{\code{data.frame} resulting from \code{\link[=run]{run()}} or \code{\link[=spatialDE]{spatialDE()}}.}
24 37
 
25 38
 \item{...}{For the generic, arguments to pass to specific methods.}
26 39
 
27
-\item{assay_type}{A \code{character} string specifying the assay from \code{x} to use
28
-as input. Defaults to \code{"counts"}.}
40
+\item{coordinates}{A \code{data.frame} with sample coordinates. Each row is a
41
+sample, the columns with coordinates should be named 'x' and 'y'.
42
+
43
+For the \emph{SpatialExperiment} method, coordinates are taken from
44
+\code{spatialCoords(x)}.}
29 45
 
30 46
 \item{qval_thresh}{\code{numeric} scalar, specifying the q-value significance
31 47
 threshold to filter \code{de_results}. Only rows in \code{de_results} with
... ...
@@ -37,6 +53,9 @@ threshold to filter \code{de_results}. Only rows in \code{de_results} with
37 53
 
38 54
 \item{verbose}{A \code{logical} controlling the display of a progress bar from the
39 55
 Python package.}
56
+
57
+\item{assay_type}{A \code{character} string specifying the assay from \code{x} to use
58
+as input. Defaults to \code{"counts"}.}
40 59
 }
41 60
 \value{
42 61
 A \code{list} of two \code{data.frame}s (pattern_results, patterns):
Browse code

Include `de_results` argument in the generics

This argument should always be present for specific methods of `spatialPatterns()` and `modelSearch()`

Milan Malfait authored on 01/06/2021 10:59:37
Showing 1 changed files
... ...
@@ -5,12 +5,12 @@
5 5
 \alias{spatialPatterns,SpatialExperiment-method}
6 6
 \title{Automatic expression histology in \strong{SpatialDE}}
7 7
 \usage{
8
-spatialPatterns(x, ...)
8
+spatialPatterns(x, de_results, ...)
9 9
 
10 10
 \S4method{spatialPatterns}{SpatialExperiment}(
11 11
   x,
12
-  assay_type = "counts",
13 12
   de_results,
13
+  assay_type = "counts",
14 14
   qval_thresh = 0.05,
15 15
   n_patterns,
16 16
   length,
... ...
@@ -20,13 +20,13 @@ spatialPatterns(x, ...)
20 20
 \arguments{
21 21
 \item{x}{\linkS4class{SpatialExperiment} object.}
22 22
 
23
+\item{de_results}{\code{data.frame} resulting from \code{\link[=run]{run()}} or \code{\link[=spatialDE]{spatialDE()}}.}
24
+
23 25
 \item{...}{For the generic, arguments to pass to specific methods.}
24 26
 
25 27
 \item{assay_type}{A \code{character} string specifying the assay from \code{x} to use
26 28
 as input. Defaults to \code{"counts"}.}
27 29
 
28
-\item{de_results}{\code{data.frame} resulting from \code{\link[=run]{run()}} or \code{\link[=spatialDE]{spatialDE()}}.}
29
-
30 30
 \item{qval_thresh}{\code{numeric} scalar, specifying the q-value significance
31 31
 threshold to filter \code{de_results}. Only rows in \code{de_results} with
32 32
 \code{qval < qval_thresh} will be kept. To disable, set \code{qval_thresh = NULL}.}
Browse code

Update `spatialPatterns()`: documentation + code style

Milan Malfait authored on 01/06/2021 10:44:35
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,86 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/aeh.R
3
+\name{spatialPatterns}
4
+\alias{spatialPatterns}
5
+\alias{spatialPatterns,SpatialExperiment-method}
6
+\title{Automatic expression histology in \strong{SpatialDE}}
7
+\usage{
8
+spatialPatterns(x, ...)
9
+
10
+\S4method{spatialPatterns}{SpatialExperiment}(
11
+  x,
12
+  assay_type = "counts",
13
+  de_results,
14
+  qval_thresh = 0.05,
15
+  n_patterns,
16
+  length,
17
+  verbose = FALSE
18
+)
19
+}
20
+\arguments{
21
+\item{x}{\linkS4class{SpatialExperiment} object.}
22
+
23
+\item{...}{For the generic, arguments to pass to specific methods.}
24
+
25
+\item{assay_type}{A \code{character} string specifying the assay from \code{x} to use
26
+as input. Defaults to \code{"counts"}.}
27
+
28
+\item{de_results}{\code{data.frame} resulting from \code{\link[=run]{run()}} or \code{\link[=spatialDE]{spatialDE()}}.}
29
+
30
+\item{qval_thresh}{\code{numeric} scalar, specifying the q-value significance
31
+threshold to filter \code{de_results}. Only rows in \code{de_results} with
32
+\code{qval < qval_thresh} will be kept. To disable, set \code{qval_thresh = NULL}.}
33
+
34
+\item{n_patterns}{\code{integer} The number of spatial patterns}
35
+
36
+\item{length}{\code{numeric} The characteristic length scale of the clusters}
37
+
38
+\item{verbose}{A \code{logical} controlling the display of a progress bar from the
39
+Python package.}
40
+}
41
+\value{
42
+A \code{list} of two \code{data.frame}s (pattern_results, patterns):
43
+\itemize{
44
+\item \code{pattern_results}: \code{data.frame} with pattern membership information for each
45
+gene.
46
+\item \code{patterns} the posterior mean underlying expression from genes in given
47
+spatial patterns.
48
+}
49
+}
50
+\description{
51
+Group spatially variable genes into spatial patterns using Automatic
52
+Expression Histology, using the
53
+\href{https://github.com/Teichlab/SpatialDE}{\strong{SpatialDE}} Python package.
54
+}
55
+\examples{
56
+## Mock up a SpatialExperiment object wit 100 cells, 200 genes
57
+set.seed(42)
58
+spe <- mockSVG(size = 10, tot_genes = 200, de_genes = 20, return_SPE = TRUE)
59
+
60
+## Run spatialDE
61
+de_results <- spatialDE(spe)
62
+
63
+spatial_patterns <- spatialPatterns(spe, de_results = de_results,
64
+    qval_thresh = NULL, n_patterns = 4L, length = 1.5,
65
+    verbose = FALSE
66
+)
67
+
68
+head(spatial_patterns$pattern_results)
69
+head(spatial_patterns$patterns)
70
+
71
+}
72
+\references{
73
+Svensson, V., Teichmann, S. & Stegle, O. SpatialDE: identification of
74
+spatially variable genes. Nat Methods 15, 343–346 (2018).
75
+\url{https://doi.org/10.1038/nmeth.4636}
76
+
77
+\href{https://pypi.org/project/SpatialDE/1.1.3/}{\strong{SpatialDE 1.1.3}}: the version
78
+of the Python package used under the hood.
79
+}
80
+\seealso{
81
+The individual steps performed by this function: \code{\link[=stabilize]{stabilize()}},
82
+\code{\link[=regress_out]{regress_out()}} and \code{\link[=spatial_patterns]{spatial_patterns()}}.
83
+}
84
+\author{
85
+Davide Corso, Milan Malfait
86
+}