filter_genes: Preprocessing function to filter genes

View source: R/filter_genes.R

filter_genesR Documentation

Preprocessing function to filter genes

Description

Preprocessing function to filter low-expressed genes and/or mitochondrial genes for 'nnSVG'.

Usage

filter_genes(
  spe,
  filter_genes_ncounts = 3,
  filter_genes_pcspots = 0.5,
  filter_mito = TRUE
)

Arguments

spe

SpatialExperiment: Input data, assumed to be formatted as a SpatialExperiment object with an assay slot named counts containing raw expression counts.

filter_genes_ncounts

numeric: Filtering parameter for low-expressed genes. Filtering retains genes containing at least filter_genes_ncounts expression counts in at least filter_genes_pcspots percent of the total number of spatial locations (spots). Defaults: filter_genes_ncounts = 3, filter_genes_pcspots = 0.5, i.e. keep genes with at least 3 counts in at least 0.5 percent of spots. Set to NULL to disable.

filter_genes_pcspots

numeric: Second filtering parameter for low-expressed genes. Set to NULL to disable. See filter_genes_ncounts for details.

filter_mito

logical: Whether to filter out mitochondrial genes, identified by gene names starting with "MT" or "mt". This requires that the rowData slot of the input object contains a column named gene_name. Default = TRUE. Set to FALSE to disable.

Details

Preprocessing function to filter low-expressed genes and/or mitochondrial genes for 'nnSVG'.

This function can be used to filter out low-expressed genes and/or mitochondrial genes before additional preprocessing (calculating logcounts or deviance residuals) and running 'nnSVG'.

We use this function in the examples and vignettes in the 'nnSVG' package, and provide default filtering parameter values that are appropriate for 10x Genomics Visium data.

The use of this function is optional. Users can also perform filtering and preprocessing separately, and run nnSVG on a preprocessed SpatialExperiment object.

Value

Returns SpatialExperiment with filtered genes (rows) removed.

Examples

library(SpatialExperiment)
library(STexampleData)

# load example dataset from STexampleData package
spe <- Visium_humanDLPFC()

# preprocessing steps

# keep only spots over tissue
spe <- spe[, colData(spe)$in_tissue == 1]
dim(spe)

# filter low-expressed and mitochondrial genes
spe <- filter_genes(spe)
dim(spe)


lmweber/nnSVG documentation built on March 24, 2024, 1:08 p.m.