
Batch spatial feature plots for genes and/or metadata columns
PlotSpatialFeaturePlots.RdLoops over features (gene names or numeric metadata columns) and
produces Seurat::SpatialFeaturePlot() panels for each image in the
object. A shared color scale (0 → max) is applied across all images for
the same feature. Panels are arranged in a grid and a shared legend is
attached.
Usage
PlotSpatialFeaturePlots(
seurat_object,
features,
layout_method = "auto",
row.by = NULL,
images_to_plot = NULL,
remove_outliers = FALSE,
outlier_prob = 0.01,
size_override = NULL,
colors = c("#053061", "#2166AC", "#D1E5F0", "#FDDBC7", "#F4A582", "#D6604D", "#B2182B",
"#67001F"),
na.value = "transparent",
calcptsizesc = 100,
legend.side = "right",
legend.direction = "vertical",
join_plots = FALSE,
join_nrow = NULL,
join_ncol = NULL,
output_dir = NULL,
object_name = "",
image.alpha = 0.5,
alpha = 1,
subset_name = "",
file_name = NULL,
width = NULL,
height = NULL,
timestamp = FALSE
)
GenerateSpatialFeatureMaps(
seurat_object,
features,
layout_method = "auto",
row.by = NULL,
images_to_plot = NULL,
remove_outliers = FALSE,
outlier_prob = 0.01,
size_override = NULL,
colors = c("#053061", "#2166AC", "#D1E5F0", "#FDDBC7", "#F4A582", "#D6604D", "#B2182B",
"#67001F"),
na.value = "transparent",
calcptsizesc = 100,
legend.side = "right",
legend.direction = "vertical",
join_plots = FALSE,
join_nrow = NULL,
join_ncol = NULL,
output_dir = NULL,
object_name = "",
image.alpha = 0.5,
alpha = 1,
subset_name = "",
file_name = NULL,
width = NULL,
height = NULL,
timestamp = FALSE
)Arguments
- seurat_object
A Seurat object with spatial images.
- features
Character vector of gene names or numeric metadata column names.
- layout_method
Character.
"auto"(default) or"metadata".- row.by
Character or
NULL. Slide-level metadata column for grouping images into rows (required whenlayout_method = "metadata").- images_to_plot
Character vector or
NULL. Subset of image names to include.NULLuses all images.- remove_outliers
Logical. Crop outlier cells before plotting. Default
FALSE.- outlier_prob
Numeric. Quantile to trim when
remove_outliers = TRUE. Default0.01.- size_override
Scalar or named numeric list. A plain number (e.g.
size_override = 1.5) applies to all images; a named list applies per image. Overrides auto-sizing.- colors
Character vector. Gradient colors from low to high.
- calcptsizesc
Numeric. Scaling constant for auto point-size calculation. Default
100.- legend.side
Character. Where to place the legend panel relative to the image grid:
"right"(default),"left","bottom", or"top".- legend.direction
Character. Internal layout of legend entries:
"vertical"(default, entries stacked) or"horizontal"(entries arranged in rows). Also controls colorbar orientation.- join_plots
Logical. When
featureshas more than one gene, combine all per-feature figures into a single page/PDF instead of one each. DefaultFALSE.- join_nrow, join_ncol
Integer or
NULL. Grid layout forjoin_plots.NULLauto-arranges into a near-square grid.- output_dir
Character or
NULL. Output directory for PDFs. Returns last plot whenNULL.- object_name
Character. Label appended to PDF filenames. Default
"".- subset_name
Character. Optional second label appended to PDF filenames after
object_name. Default"".- file_name
Character or
NULL. Base name (no extension) for the saved PDF.NULL(default) auto-deduces fromobject_name,subset_name,row.by, and the feature name(s).- width, height
Numeric or
NULL. Override the auto-calculated PDF dimensions in inches.NULL(default) auto-sizes to fit the image grid and legend.- timestamp
Logical. When
TRUE, append a_YYYYMMDD-HHMMSSstamp to the saved file name so repeated runs are versioned instead of overwriting the previous PDF. DefaultFALSE.
Value
Invisibly returns the last plot when output_dir = NULL. When
join_plots = TRUE, invisibly returns the combined tiled figure.