find_variable_genes: Find Variable Genes Using Variance or Deviance-Based Metrics

View source: R/feature_selection.R

find_variable_genesR Documentation

Find Variable Genes Using Variance or Deviance-Based Metrics

Description

Identifies highly variable genes from a sparse gene expression matrix using one of two methods: variance-stabilizing transformation (VST) or deviance-based modeling. The VST method uses a C++-accelerated approach to compute standardized variance, while the deviance-based method models gene variability across libraries using negative binomial deviances.

Usage

find_variable_genes(
  gene_expression_matrix,
  method = "vst",
  n_threads = 1,
  verbose = FALSE,
  ...
)

Arguments

gene_expression_matrix

A sparse gene expression matrix (of class Matrix) with gene names as row names.

method

Character string, either "vst" or "sum_deviance". The default is "sum_deviance". "vst" uses a variance-stabilizing transformation to identify variable genes. "sum_deviance" computes per-library deviances and combines them with a row variance metric.

n_threads

If OpenMP is available for your device, the function suggests using multi-thread processing for even faster computation (only for sum_deviance method).

verbose

Logical. If TRUE, prints progress and informational messages. Default is FALSE.

...

Additional arguments (currently unused).

Value

A data.table containing gene names (column events) and computed metrics. For the deviance method, this includes sum_deviance and variance columns.

Examples

library(Matrix)
# loading the toy dataset
toy_obj <- load_toy_M1_M2_object()

# getting high variable genes
HVG_VST <- find_variable_genes(toy_obj$gene_expression, method = "vst")
# sum_deviance method
HVG_DEV <- find_variable_genes(toy_obj$gene_expression, method = "sum_deviance")

# Using multi-threading for faster computation (sum_deviance method only)
HVG_DEV_MT <- find_variable_genes(toy_obj$gene_expression, 
                                  method = "sum_deviance", 
                                  n_threads = 4) # 4 threads

# printing the results
print(HVG_VST[order(-standardize_variance)])
print(HVG_DEV[order(-sum_deviance)])


splikit documentation built on May 13, 2026, 9:08 a.m.