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,
...
)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.
Value
A data.frame containing SVG detection results. The exact columns depend on the method used, but typically include:
gene: Gene identifierspvalorp.value: Raw p-valuespadjorp.adj: Adjusted p-values (multiple testing corrected)Method-specific statistics (e.g., Moran's I, LR statistic, odds ratio)
Details
This function serves as a wrapper around the individual method functions:
method = "meringue": CallsCalSVG_MERINGUEmethod = "seurat": CallsCalSVG_Seuratmethod = "binspect": CallsCalSVG_binSpectmethod = "sparkx": CallsCalSVG_SPARKXmethod = "nnsvg": CallsCalSVG_nnSVGmethod = "markvario": CallsCalSVG_MarkVario
For method-specific parameters, please refer to the documentation of individual method functions.
Examples
# \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)
#> gene p.value p.adj stat_linear pval_linear
#> 1 gene_9 4.440892e-16 3.195435e-14 5.688811 5.153065e-16
#> 2 gene_1 5.773160e-15 1.970518e-13 5.616795 5.713384e-15
#> 3 gene_13 8.215650e-15 1.970518e-13 5.925955 8.188767e-15
#> 4 gene_15 2.005129e-11 3.606967e-10 4.080433 2.005131e-11
#> 5 gene_7 7.587642e-11 1.091934e-09 3.971108 7.587649e-11
#> 6 gene_20 1.442864e-10 1.730349e-09 4.718315 1.442863e-10
# }