Spatial GMM class assignment plot for a QPTIFFImage or SpatialExperiment
Source:R/plot_utils.R
plot_pixel_classes.RdAssigns each pixel/cell to its most probable GMM component and renders the
result. For a QPTIFFImage produced by
bgnorm_pixels: pseudocoloured raster (pixel-level data, three
components). For a
SpatialExperiment: scatter plot at spatial
coordinates using the bgnorm results from
metadata(spe)$bgnorm_results (two components). Multi-sample
SpatialExperiments are automatically detected via the
sample_id column in colData and faceted accordingly.
Usage
plot_pixel_classes(
x,
markers = NULL,
resolution = 1L,
point_size = 1,
pixels = c(1024L, 1024L),
flip_y = TRUE,
large_data_threshold = 10000L,
ncol = NULL
)Arguments
- x
A
QPTIFFImagereturned bybgnorm_pixels(contains both the adjusted pixel intensities and the embeddedBgnormResultobjects), or aSpatialExperimentwithmetadata(x)$bgnorm_resultspopulated bybgnorm_sce.- markers
Character vector of markers to display, or
NULLfor all markers inx.- resolution
Positive integer; pixel downsample factor for raster output. Ignored for
SpatialExperiment.- point_size
Base point size for
SpatialExperimentscatter.- pixels
Integer
c(width, height)for scattermore rasterisation. Defaultc(1024L, 1024L).- flip_y
Logical; reverse y-axis for
SpatialExperiment? DefaultTRUE.- large_data_threshold
Cell count threshold for automatic scattermore use. Default
10000L.- ncol
Number of facet columns.
Examples
path <- system.file("extdata", "PA_HNC_sample.ome.tiff", package = "bgnormR")
img <- read_qptiff(path)
#> Reading TIFF directory structure ...
#> Reading OME-TIFF metadata ...
#> Reading IFD page layouts ...
#> Loading 5 channel(s) ...
#> Loading 5 channel(s) ...
res <- bgnorm_pixels(img, sample_prop = 0.1)
plot_pixel_classes(res, markers = c("PanCK", "CD20"))