spatialPatterns {spatialDE} | R Documentation

## Automatic expression histology in SpatialDE

### Description

Group spatially variable genes into spatial patterns using Automatic Expression Histology, using the SpatialDE Python package.

### Usage

    spatialPatterns(x, de_results, ...)

    ## S4 method for signature 'matrix'
    spatialPatterns(
      x,
      de_results,
      coordinates,
      qval_thresh = 0.05,
      n_patterns,
      length,
      verbose = FALSE
    )

    ## S4 method for signature 'SpatialExperiment'
    spatialPatterns(
      x,
      de_results,
      qval_thresh = 0.05,
      n_patterns,
      length,
      assay_type = "counts",
      verbose = FALSE
    )

### Arguments

`x` | A numeric `matrix` of counts where genes are rows and cells are columns. Alternatively, a SpatialExperiment object.
`de_results` | `data.frame` resulting from `run()` or `spatialDE()`.
`...` | For the generic, arguments to pass to specific methods.
`coordinates` | A `data.frame` with sample coordinates. Each row is a sample, the columns with coordinates should be named 'x' and 'y'. For the SpatialExperiment method, coordinates are taken from `spatialCoords(x)`.
`qval_thresh` | `numeric` scalar, specifying the q-value significance threshold to filter `de_results`. Only rows in `de_results` with `qval < qval_thresh` will be kept. To disable, set `qval_thresh = NULL`.
`n_patterns` | `integer` The number of spatial patterns
`length` | `numeric` The characteristic length scale of the clusters
`verbose` | A `logical` controlling the display of a progress bar from the Python package.
`assay_type` | A `character` string specifying the assay from `x` to use as input. Defaults to `"counts"`.

### Value

A `list` of two `data.frame`s (pattern_results, patterns):

- `pattern_results`: `data.frame` with pattern membership information for each gene.

- `patterns` the posterior mean underlying expression from genes in given spatial patterns.

### Author(s)

Davide Corso, Milan Malfait, Lambda Moses

### References

Svensson, V., Teichmann, S. & Stegle, O. SpatialDE: identification of spatially variable genes. Nat Methods 15, 343–346 (2018). https://doi.org/10.1038/nmeth.4636

SpatialDE 1.1.3: the version of the Python package used under the hood.

### See Also

The individual steps performed by this function: `stabilize()`, `regress_out()` and `spatial_patterns()`.

### Examples

    ## Mock up a SpatialExperiment object wit 100 cells, 200 genes
    set.seed(42)
    spe <- mockSVG(size = 10, tot_genes = 200, de_genes = 20, return_SPE = TRUE)

    ## Run spatialDE
    de_results <- spatialDE(spe)

    spatial_patterns <- spatialPatterns(spe, de_results = de_results,
        qval_thresh = NULL, n_patterns = 4L, length = 1.5,
        verbose = FALSE
    )

    head(spatial_patterns$pattern_results)
    head(spatial_patterns$patterns)

[Package spatialDE version 1.0.0 Index]