SpatialData.plotSpatialData.plot is one of several companion packages to
spatialdataR, an R interface to scverse/Python’s
spatialdata framework (Marconato et
al. (2024)), providing a
visualization suit for SpatialData objects in ggplot2-style. This
allows layering of elements into composite plots using +, where each
layer can be customized using familiar aesthetics (e.g., fill or
size).
SpatialDatasets.if (!requireNamespace("BiocManager", quietly=TRUE))
install.packages("BiocManager")
# install the development version from GitHub
BiocManager::install("HelenaLC/SpatialData.plot")
In order to demonstrate the package’s basic functionality, we here
spatialdataR packagelibrary(spatialdataR)
library(SpatialData.plot)
zs <- file.path("extdata", "blobs.zarr")
zs <- system.file(zs, package="spatialdataR")
(sd <- readSpatialData(zs))
#> class: SpatialData
#> - images(2): blobs_image blobs_multiscale_image
#> - labels(2): blobs_labels blobs_multiscale_labels
#> - points(1):
#> - blobs_points (200)
#> - shapes(3):
#> - blobs_circles (5,circle)
#> - blobs_multipolygons (2,polygon)
#> - blobs_polygons (5,polygon)
#> - tables(1):
#> - table (3,10) [blobs_labels]
#> coordinate systems(5):
#> - global(8): blobs_image blobs_multiscale_image ... blobs_polygons
#> blobs_points
#> - scale(1): blobs_labels
#> - translation(1): blobs_labels
#> - affine(1): blobs_labels
#> - sequence(1): blobs_labels
plotSpatialData(sd) +
plotImage() +
plotLabel(a=2/3, pal="gold") +
plotShape(col="white", lwd=2) +
plotPoint(col="genes", size=1)

Figure 1