Learn R Programming

SVG (version 1.0.0)

CalSVG: Unified Interface for SVG Detection

Description

A unified interface to run different spatially variable gene (SVG) detection methods. This function provides a consistent API for all supported methods.

Usage

CalSVG(
  expr_matrix,
  spatial_coords,
  method = c("meringue", "seurat", "binspect", "sparkx", "nnsvg", "markvario"),
  n_threads = 1L,
  verbose = TRUE,
  ...
)

Value

A data.frame containing SVG detection results. The exact columns depend on the method used, but typically include:

  • gene: Gene identifiers

  • pval or p.value: Raw p-values

  • padj or p.adj: Adjusted p-values (multiple testing corrected)

  • Method-specific statistics (e.g., Moran's I, LR statistic, odds ratio)

Arguments

expr_matrix

Numeric matrix of gene expression values. Rows are genes, columns are spatial locations (spots/cells). Should be normalized (e.g., log-transformed counts).

spatial_coords

Numeric matrix of spatial coordinates. Rows are spatial locations, columns are x and y (and optionally z) coordinates. Row names should match column names of expr_matrix.

method

Character string specifying the SVG detection method. One of: "meringue", "seurat", "binspect", "sparkx", "nnsvg", "markvario".

n_threads

Integer. Number of threads for parallel computation. Default is 1. Set to higher values for faster computation on multi-core systems.

verbose

Logical. Whether to print progress messages. Default is TRUE.

...

Additional arguments passed to the specific method function.

Details

This function serves as a wrapper around the individual method functions:

  • method = "meringue": Calls CalSVG_MERINGUE

  • method = "seurat": Calls CalSVG_Seurat

  • method = "binspect": Calls CalSVG_binSpect

  • method = "sparkx": Calls CalSVG_SPARKX

  • method = "nnsvg": Calls CalSVG_nnSVG

  • method = "markvario": Calls CalSVG_MarkVario

For method-specific parameters, please refer to the documentation of individual method functions.

See Also

CalSVG_MERINGUE, CalSVG_binSpect, CalSVG_SPARKX, CalSVG_nnSVG

Examples

Run this code
# \donttest{
# Simulate example data
set.seed(42)
n_genes <- 20
n_spots <- 100
expr_matrix <- matrix(rpois(n_genes * n_spots, lambda = 10),
                      nrow = n_genes, ncol = n_spots)
rownames(expr_matrix) <- paste0("gene_", seq_len(n_genes))
colnames(expr_matrix) <- paste0("spot_", seq_len(n_spots))

spatial_coords <- cbind(x = runif(n_spots, 0, 100),
                        y = runif(n_spots, 0, 100))
rownames(spatial_coords) <- colnames(expr_matrix)

# Run SPARK-X method (no external dependencies)
results <- CalSVG(expr_matrix, spatial_coords, method = "sparkx",
                  kernel_option = "single", verbose = FALSE)
head(results)
# }

Run the code above in your browser using DataLab