
SpatialArtifacts: Detect and Classify Spatial Artifacts
Source:R/SpatialArtifacts_package.R
SpatialArtifacts-package.RdSpatialArtifacts provides a robust, data-driven two-step workflow to
identify, classify, and handle spatial artifacts in spatial transcriptomics
data across multiple platforms including 10x Genomics Visium (Standard and
HD). It combines median absolute deviation (MAD)-based outlier detection
with morphological image processing to flag problematic regions such as
edge dryspots and interior artifacts caused by incomplete reagent coverage.
Main Functions
detectEdgeArtifacts: The primary wrapper function to detect potential artifact spots. Automatically routes to platform-specific methods based on theplatformargument. Outputs three columns tocolData:*_edge,*_problem_id, and*_problem_size.classifyEdgeArtifacts: Hierarchically classifies detected artifacts by location (edge vs. interior) and size (large vs. small). Outputs a single*_classificationcolumn.
Typical Workflow
# Step 1: Detect artifacts
spe <- detectEdgeArtifacts(spe, platform = "visium", qc_metric = "sum_gene")
# Step 2: Classify artifacts
spe <- classifyEdgeArtifacts(spe, min_spots = 20)Platform-Specific Usage
detectEdgeArtifacts requires users to specify their platform:
Standard Visium (
platform = "visium"): Uses hexagonal grid layout. The defaultshifted = FALSEis correct for standard Space Rangerarray_row/array_coloutputs.Visium HD (
platform = "visiumhd"): Uses square grid layout. Requires theresolutionparameter ("16um"or"8um"). Parameters are specified in physical units (micrometers).
Input Data
All functions accept a SpatialExperiment
object. QC metrics (e.g., library size, detected genes) should be
precomputed, for example using
addPerCellQCMetrics.
Author
Maintainer: Harriet Jiali He jhe46@jh.edu (ORCID)
Authors:
Jacqueline R. Thompson jthom338@jh.edu
Michael Totty mtotty2@jh.edu
Stephanie C. Hicks shicks19@jhu.edu (ORCID) [funder]