ggspavis 1.13.0
The ggspavis
package contains a set of visualization functions for spatial transcriptomics data, designed to work with the SpatialExperiment Bioconductor object class.
Load some example datasets from the STexampleData or spatialLIBD package and create some example plots to demonstrate ggspavis
.
library(ggspavis)
library(STexampleData)
library(patchwork)
library(scater)
First we start with a demo for a 10x Genomics Visium mouse brain dataset. We generate visualizations of library size and expression levels of selected genes. Both plotVisium()
and plotSpots()
reflect the spatial coordinates of spots, with the former also overlaying spots on the H&E histology image. Note that plotVisium()
accepts a SpatialExperiment
class object, while other functions in the package accept either SpatialExperiment
or SingleCellExperiment
class objects.
# load data in SpatialExperiment format
spe <- Visium_mouseCoronal()
rownames(spe) <- rowData(spe)$gene_name
colData(spe)$sum <- colSums(counts(spe))
With plotVisium()
annotated by a continuous variable, you can adjust palette, legend position, scaling of the variable, and whether to highlight spots that are in tissue, etc.
Note that we also use the patchwork
package to display multiple figures in panels here.
p1 <- plotVisium(spe, annotate = "sum", highlight = "in_tissue",
legend_position = "none")
p2 <- plotVisium(spe, annotate = "sum", highlight = "in_tissue",
pal = "darkred") +
guides(fill = guide_colorbar(title = "Libsize"))
# display panels using patchwork
p1 | p2