runSVGsBRISC: runSVGsBRISC

Description Usage Arguments Details Value Examples

View source: R/runSVGsBRISC.R

Description

Run method to identify spatially variable genes (SVGs) using BRISC.

Usage

1
runSVGsBRISC(spe, x = NULL, lr_test = TRUE, n_threads = 1, verbose = FALSE)

Arguments

spe

SpatialExperiment Input object, assumed to be a SpatialExperiment containing an assay named logcounts and spatial coordinates accessible with spatialCoords().

x

numeric matrix Matrix of covariates, with number of rows (spots) matching the number of columns (spots) in spe. Default = NULL, which specifies an intercept-only model. See BRISC documentation for details.

lr_test

logical Whether to return log likelihoods and calculate likelihood ratio tests compared to the null model without spatial terms. If TRUE, will calculate log likelihoods for the null models, calculate likelihood ratio tests using the asymptotic chi-squared distribution with 2 degrees of freedom, and calculate adjusted p-values using the Benjamini-Hochberg method. Default = TRUE.

n_threads

integer Number of threads for parallelization. Default = 1.

verbose

logical Whether to display verbose output from BRISC. Default = FALSE.

Details

Run method to identify spatially variable genes (SVGs) using BRISC ("bootstrap for rapid inference on spatial covariances") methodology (Saha and Datta 2018).

This function runs BRISC separately for each gene, using parallelization for faster runtime using one core per BRISC run. The main outputs of interest are the covariance parameter estimates stored in 'Theta' in the BRISC output (sigma.sq, tau.sq, phi). We use these estimates to perform inference on the 'sigma.sq' parameter, and to calculate an effect size estimate defined as the proportion of spatial variance out of total variance, 'prop_sv' = 'sigma.sq / (sigma.sq + tau.sq)'.

Significant SVGs can then be identified as those with a highly significant p-value from 'sigma.sq' and large effect size 'prop_sv'.

Assumes the input object is a SpatialExperiment containing an assay named logcounts, which has been filtered to exclude very low-expressed genes, e.g. as prepared with preprocessSVGs.

Value

Returns output values stored as new columns in rowData in the spe SpatialExperiment object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
library(SpatialExperiment)
library(STexampleData)
library(spatzli)

spe <- Visium_humanDLPFC()

spe <- preprocessSVGs(spe)

# subset 1 gene
spe_1 <- spe[1, ]
system.time({
  spe_1 <- runSVGsBRISC(spe_1, verbose = TRUE)
})

# subset 100 genes and use parallelization
# spe_100 <- spe[1:100, ]
# spe_100 <- runSVGsBRISC(spe_100, n_threads = 4)

lmweber/spatzli documentation built on Feb. 2, 2022, 1:09 p.m.