spatial_patterns {spatialDE} | R Documentation

## Group spatially variable genes into spatial patterns using automatic expression histology (AEH)

### Description

Group spatially variable genes into spatial patterns using automatic expression histology (AEH)

### Usage

    spatial_patterns(
      x,
      coordinates,
      de_results,
      qval_thresh = 0.05,
      n_patterns,
      length,
      verbose = FALSE
    )

### Arguments

`x` | `matrix`-like object of normalized counts. E.g. resulting from `regress_out()`.
`coordinates` | `data.frame` with sample coordinates. Each row is a sample, the columns with coordinates must be named 'x' and 'y'.
`de_results` | `data.frame` resulting from `run()`.
`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` | `logical` controlling the display of the progress bar.

### Value

`list` of two dataframe (pattern_results, patterns): `pattern_results` dataframe with pattern membership information for each gene. `patterns` the posterior mean underlying expression fro genes in given spatial patterns.

### 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

### Examples

    set.seed(42)
    mock <- mockSVG(size = 10, tot_genes = 500, de_genes = 10)
    stabilized <- stabilize(mock$counts)
    sample_info <- mock$coordinates
    sample_info$total_counts <- colSums(mock$counts)
    regressed <- regress_out(counts = stabilized, sample_info = sample_info)

    ## Run SpatialDE
    de_results <- run(x = regressed, coordinates = mock$coordinates)

    ## Run Spatial_patterns
    sp <- spatial_patterns(
        x = regressed,
        coordinates = mock$coordinates,
        de_results = de_results,
        qval_thresh = NULL,
        n_patterns = 5, length = 1.5
    )

    sp$pattern_results
    sp$patterns

[Package spatialDE version 1.0.0 Index]