Skip to contents

Assigns 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 QPTIFFImage returned by bgnorm_pixels (contains both the adjusted pixel intensities and the embedded BgnormResult objects), or a SpatialExperiment with metadata(x)$bgnorm_results populated by bgnorm_sce.

markers

Character vector of markers to display, or NULL for all markers in x.

resolution

Positive integer; pixel downsample factor for raster output. Ignored for SpatialExperiment.

point_size

Base point size for SpatialExperiment scatter.

pixels

Integer c(width, height) for scattermore rasterisation. Default c(1024L, 1024L).

flip_y

Logical; reverse y-axis for SpatialExperiment? Default TRUE.

large_data_threshold

Cell count threshold for automatic scattermore use. Default 10000L.

ncol

Number of facet columns.

Value

A ggplot object.

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"))