Run SpotSweeper spatially aware spot-level quality control on a spatial
Seurat object. The wrapper computes standard spot QC metrics, runs local
outlier detection for each metric, optionally runs regional artifact
detection per sample, and writes scop-style pass/fail metadata that can be
visualized with SpatialSpotPlot().
Usage
RunSpotSweeper(
srt,
assay = NULL,
layer = "counts",
coord.cols = c("col", "row"),
image = NULL,
sample.by = NULL,
metrics = NULL,
directions = NULL,
n_neighbors = 36,
cutoff = 3,
log = TRUE,
run_artifact = TRUE,
mito_pattern = c("MT-", "Mt-", "mt-"),
mito_gene = NULL,
mito_percent = NULL,
mito_sum = NULL,
n_order = 5,
shape = c("hexagonal", "square"),
prefix = "SpotSweeper",
tool_name = "SpotSweeper",
return_filtered = FALSE,
store_results = TRUE,
workers = 1,
verbose = TRUE,
...
)Arguments
- srt
A
Seuratobject.- assay
Assay used for expression. If
NULL, the default assay is used.- layer
Assay layer used for expression values.
- coord.cols
Metadata coordinate columns used when no Seurat image is available.
- image
Name of the Seurat spatial image. If
NULL, the first image is used when present.- sample.by
Optional metadata column identifying samples or images. If
NULL, all spots are treated as one sample.- metrics
QC metrics used by
SpotSweeper::localOutliers(). IfNULL,nCount_<assay>,nFeature_<assay>, andpercent.mitoare used.- directions
Outlier direction for each metric. If
NULL, count and feature metrics use"lower"and mitochondrial metrics use"higher".- n_neighbors
Number of nearest spatial neighbors for local outlier detection.
- cutoff
Modified z-score cutoff passed to local outlier detection.
- log
Whether SpotSweeper should log1p-transform local outlier metrics.
- run_artifact
Whether to run
SpotSweeper::findArtifacts()per sample.- mito_pattern
Regex prefixes used to identify mitochondrial genes.
- mito_gene
Optional explicit mitochondrial gene vector. When provided,
mito_patternis ignored.- mito_percent
Metadata column used as mitochondrial percent for artifact detection. If
NULL,percent.mitois used.- mito_sum
Metadata column used as mitochondrial counts for artifact detection. If
NULL, mitochondrial counts are computed.- n_order, shape
Parameters passed to
SpotSweeper::findArtifacts().- prefix
Prefix used for metadata columns.
- tool_name
Name used to store detailed results in
srt@tools.- return_filtered
Whether to return only spots passing SpotSweeper QC.
- store_results
Whether to store detailed results in
srt@tools.- workers
Number of workers passed to SpotSweeper local outlier detection.
- verbose
Whether to print progress messages.
- ...
Additional named arguments passed to matching SpotSweeper backend functions when those arguments are supported by the installed version.
Value
A Seurat object with SpotSweeper QC metadata. When
store_results = TRUE, detailed results are stored in
srt@tools[[tool_name]].
Examples
data(visium_human_pancreas_sub)
spatial <- visium_human_pancreas_sub
spatial$SpotSweeper_QC <- factor(
ifelse(seq_len(ncol(spatial)) %% 9 == 0, "Fail", "Pass"),
levels = c("Pass", "Fail")
)
spatial$SpotSweeper_nCount_Spatial_z <- as.numeric(scale(spatial$nCount_Spatial))
SpatialSpotPlot(
spatial,
group.by = "SpotSweeper_QC",
overlay_image = FALSE,
coord.cols = c("x", "y")
)
SpatialSpotPlot(
spatial,
group.by = "SpotSweeper_nCount_Spatial_z",
overlay_image = FALSE,
coord.cols = c("x", "y")
)
if (
isTRUE(check_r("MicTott/SpotSweeper", verbose = FALSE)) &&
requireNamespace("SpatialExperiment", quietly = TRUE)
) {
spatial <- RunSpotSweeper(
spatial,
assay = "Spatial",
coord.cols = c("x", "y"),
n_neighbors = 12,
run_artifact = FALSE,
verbose = FALSE
)
SpatialSpotPlot(
spatial,
group.by = "SpotSweeper_QC",
overlay_image = FALSE,
coord.cols = c("x", "y")
)
}
#> Error in check_r("MicTott/SpotSweeper", verbose = FALSE): could not find function "check_r"