This function visualizes the clusters for one given sample at the spot-level
using (by default) the histology information on the background. This is the
function that does all the plotting behind vis_clus()
. To visualize
gene-level (or any continuous variable) use vis_gene_p()
.
vis_clus_p(
spe,
d,
clustervar,
sampleid = unique(spe$sample_id)[1],
colors,
spatial,
title,
image_id = "lowres",
alpha = NA,
point_size = 2,
auto_crop = TRUE,
na_color = "#CCCCCC40"
)
A
SpatialExperiment-class
object. See fetch_data()
for how to download some example objects or
read10xVisiumWrapper()
to read in spaceranger --count
output files and
build your own spe
object.
A data.frame()
with the sample-level information. This is
typically obtained using cbind(colData(spe), spatialCoords(spe))
.
A character(1)
with the name of the colData(spe)
column that has the cluster values.
A character(1)
specifying which sample to plot from
colData(spe)$sample_id
(formerly colData(spe)$sample_name
).
A vector of colors to use for visualizing the clusters
from clustervar
. If the vector has names, then those should match the
values of clustervar
.
A logical(1)
indicating whether to include the histology
layer from geom_spatial()
. If you plan to use
ggplotly() then it's best to set this to FALSE
.
The title for the plot.
A character(1)
with the name of the image ID you want to
use in the background.
A numeric(1)
in the [0, 1]
range that specifies the
transparency level of the data on the spots.
A numeric(1)
specifying the size of the points. Defaults
to 1.25
. Some colors look better if you use 2
for instance.
A logical(1)
indicating whether to automatically crop
the image / plotting area, which is useful if the Visium capture area is
not centered on the image and if the image is not a square.
A character(1)
specifying a color for the NA values.
If you set alpha = NA
then it's best to set na_color
to a color that has
alpha blending already, which will make non-NA values pop up more and the NA
values will show with a lighter color. This behavior is lost when alpha
is
set to a non-NA
value.
A ggplot2 object.
Other Spatial cluster visualization functions:
frame_limits()
,
vis_clus()
,
vis_grid_clus()
if (enough_ram()) {
## Obtain the necessary data
if (!exists("spe")) spe <- fetch_data("spe")
spe_sub <- spe[, spe$sample_id == "151673"]
## Use the manual color palette by Lukas M Weber
## Don't plot the histology information
p <- vis_clus_p(
spe = spe_sub,
d = as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE),
clustervar = "layer_guess_reordered",
sampleid = "151673",
colors = libd_layer_colors,
title = "151673 LIBD Layers",
spatial = FALSE
)
print(p)
## Clean up
rm(spe_sub)
}
#> 2024-07-26 23:49:58.923234 loading file /github/home/.cache/R/BiocFileCache/e60656c8edd_Human_DLPFC_Visium_processedData_sce_scran_spatialLIBD.Rdata%3Fdl%3D1