clusterSVG: clusterSVG

Description Usage Arguments Details Value Examples

View source: R/clusterSVG.R

Description

Clustering to identify major cell types as input for nnSVG

Usage

1
2
3
4
5
clusterSVG(
  spe,
  assay_name = c("binomial_deviance_residuals", "logcounts"),
  filter_mito = TRUE
)

Arguments

spe

SpatialExperiment Input data, assumed to be a SpatialExperiment object with an assay slot containing either deviance residuals or log-transformed normalized counts, e.g. from preprocessSVG.

assay_name

character Name of assay containing preprocessed expression values to use for clustering, i.e. either deviance residuals or log-transformed normalized counts. Assumed to be either binomial_deviance_residuals or logcounts. Default = binomial_deviance_residuals.

filter_mito

logical Whether to filter mitochondrial genes. Assumes the rowData slot of spe contains a column named gene_name, which can be used to identify mitochondrial genes. Default = TRUE. Set to FALSE to disable.

Details

Convenience function to perform clustering to identify major cell types as input for nnSVG. Cluster labels representing major cell types generated by this function can be provided to nnSVG as a matrix of covariates to include them within the statistical model. nnSVG will then identify spatially variable genes (SVGs) after taking variation due to major cell types into account.

Alternatively, cell types can be identified using manually guided analyses or a different clustering algorithm, or nnSVG can also be run without taking cell types into account (x = NULL).

The most appropriate type of analysis (i.e. whether or not to take into account variation due to cell types) will depend on the biological context of your dataset.

Value

Returns a SpatialExperiment object with cluster labels stored in a column in colData, which can then be extracted and provided to nnSVG as a matrix of covariates.

Examples

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

spe <- Visium_humanDLPFC()

# subset genes for faster runtime in this example
set.seed(123)
spe <- spe[sample(seq_len(1000)), ]

# set seed for reproducibility
set.seed(123)
spe <- preprocessSVG(spe)

# set seed for reproducibility
set.seed(123)
spe <- clusterSVG(spe)

# show results
colData(spe)

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