Skip to contents

Plots a histogram of log2-transformed pixel (or cell) intensities and overlays the component-wise density curves from the fitted GMM. One facet per marker. Accepts a QPTIFFImage returned by bgnorm_pixels (bgnorm results are carried as an attribute) or a SummarizedExperiment / SpatialExperiment with bgnorm results in metadata(x)$bgnorm_results. Multi-sample SpatialExperiments are automatically detected via sample_id in colData and produce facets by sample_id x marker.

Usage

plot_distributions(x, results = NULL, markers = NULL, ncol = NULL)

Arguments

x

A QPTIFFImage returned by bgnorm_pixels or a SummarizedExperiment / SpatialExperiment.

results

Optionally, the QPTIFFImage returned by bgnorm_pixels when x is the raw (unadjusted) QPTIFFImage. Ignored for SummarizedExperiment input.

markers

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

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_distributions(res)