Identifies spatially variable genes using the mark variogram approach,
as implemented in Seurat's FindSpatiallyVariableFeatures function
with selection.method = "markvariogram".
Usage
CalSVG_MarkVario(
expr_matrix,
spatial_coords,
r_metric = 5,
normalize = TRUE,
n_threads = 1L,
verbose = TRUE
)Arguments
- expr_matrix
Numeric matrix of gene expression values.
- spatial_coords
Numeric matrix of spatial coordinates.
- r_metric
Numeric. Distance at which to evaluate the variogram. Default is 5. Larger values capture broader spatial patterns.
- normalize
Logical. Whether to normalize the variogram. Default is TRUE.
- n_threads
Integer. Number of parallel threads. Default is 1.
- verbose
Logical. Print progress messages. Default is TRUE.
Value
A data.frame with SVG detection results. Columns:
gene: Gene identifierr.metric.X: Variogram value at distance r_metricrank: Rank by variogram value (ascending, lower = more spatially variable)
Details
Method Overview:
The mark variogram measures how the correlation between gene expression
values changes with distance. It is computed using the spatstat package's
markvario function.
Interpretation:
Lower variogram values indicate stronger spatial autocorrelation
Values near 1 indicate random spatial distribution
Values < 1 indicate positive spatial autocorrelation (clustering)
Note: Requires the spatstat package suite to be installed:
spatstat.geom and spatstat.explore.
References
Baddeley, A. et al. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC.
Examples
# \donttest{
# Load example data
data(example_svg_data)
expr <- example_svg_data$logcounts[1:5, ]
coords <- example_svg_data$spatial_coords
# Requires spatstat packages
if (requireNamespace("spatstat.geom", quietly = TRUE) &&
requireNamespace("spatstat.explore", quietly = TRUE)) {
results <- CalSVG_MarkVario(expr, coords, verbose = FALSE)
head(results)
}
#> gene r.metric.value rank
#> 1 gene_1 0.1719543 1
#> 2 gene_5 0.2447607 2
#> 3 gene_2 0.3518392 3
#> 4 gene_4 0.5295117 4
#> 5 gene_3 0.6837665 5
# }