Produces a lower-triangular grid of scatter biplots for every pair of channels in an unmixed dataset, with 1-D histograms on the diagonal, and saves the result as a single large-format PDF.
For \(n\) channels the grid is \(n \times n\) panels. The upper
triangle and all cells above the diagonal are left blank, giving
\(n(n-1)/2\) scatter panels and \(n\) histogram panels. Panel
\((i, j)\) (row \(i\), column \(j\)) shows column \(j\) on the
x-axis and row \(i\) on the y-axis, consistent with the convention used
by unmixed.mxn.plot(): the named fluorophore always appears on x.
Data are downsampled once to max.points events before any panel is drawn
so all panels share an identical cell population. Axis minima are
auto-scaled per channel from the 1st percentile of the data, floored at
the user-supplied x.min / y.min.
Usage
unmixed.nxn.plot(
unmixed.data,
asp,
channels = NULL,
gate.boundary = NULL,
scatter.param = asp$default.scatter.parameter,
max.points = 50000,
title = "nxn_biplot",
biplot.size = 3,
x.min = -1000,
y.min = -1000,
x.width.basis = -1000,
y.width.basis = -1000,
use.hex = TRUE,
hex.bins = 64,
color.palette = "viridis",
hist.fill = "steelblue",
file.type = "jpg",
dpi = 150,
max.canvas.px = 20000,
output.dir = "."
)Arguments
- unmixed.data
Either a character string giving the path to an unmixed FCS file, or a numeric matrix / data.frame whose columns are fluorophore channels and whose rows are cells.
- asp
The AutoSpectral parameter list, created by
get.autospectral.param().- channels
Optional character vector. Subset of columns to include. When
NULL(default) all columns are used. Large panels sets (\(n > 20\)) will produce very large PDFs; consider subsetting.- gate.boundary
Optional gate boundary, as returned by
define.gate.landmarks(),define.gate.density(), ordo.gate()— a list containing at least numericxandycomponents describing the polygon vertices. When supplied andscatter.paramcolumns are present in the data, events are gated withapply.gate()before downsampling tomax.points. Whenscatter.paramcolumns are absent, gating is skipped with a warning. DefaultNULL(no gating).- scatter.param
Character vector of length 2 giving the names of the two scatter columns to gate on when
gate.boundaryis supplied. Defaultasp$default.scatter.parameter. Ignored ifgate.boundaryisNULL.- max.points
Integer. Total number of events retained after a single random downsample applied before any panel is drawn. Default
5e4.- title
Character string used as the PDF filename stem. Default
"nxn_biplot".- biplot.size
Numeric. Edge length in inches of each individual panel (both scatter and histogram panels). The saved PDF will be
n * biplot.size\(\times\)n * biplot.sizeinches. Default3.- x.min
Numeric. Floor for the auto-scaled x-axis minimum (data units). The actual minimum used is
min(auto, x.min). Default-1000.- y.min
Numeric. Floor for the auto-scaled y-axis minimum (data units). Default
-1000.- x.width.basis
Numeric. Width basis for the biexponential x-axis transform. Default
-1000.- y.width.basis
Numeric. Width basis for the biexponential y-axis transform. Default
-1000.- use.hex
Logical. When
TRUE(default), scatter panels are rendered withggplot2::geom_hex()for speed. WhenFALSE, reverts toscattermore::geom_scattermore()+ggplot2::stat_density_2d().- hex.bins
Integer. Number of bins for
geom_hexin each dimension. Ignored whenuse.hex = FALSE. Default64.- color.palette
Character string. Viridis palette name (
"viridis","magma","inferno","plasma","cividis","rocket","mako","turbo") or"rainbow"to use the package default gradient. Applies to scatter panels. Default"viridis".- hist.fill
Character string. Fill color for the diagonal histogram bars. Default
"steelblue".- file.type
Character string specifying the output file format. One of
"jpg"(default),"tiff","png", or"pdf". Raster formats are strongly recommended here: for large channel counts the triangle holds hundreds to thousands of panels, and a vector"pdf"records every hexagon/point as a separate drawn object, making it extremely slow to render and write.- dpi
Numeric. Resolution in dots per inch for raster
file.typevalues. Ignored for"pdf". Default150.- max.canvas.px
Numeric. Safety cap on the predicted raster width/ height in pixels (
n * biplot.size * dpi). If the requested combination would exceed this,dpiis automatically reduced (with a warning) rather than attempting to allocate an oversized raster. Ignored for"pdf". Default20000.- output.dir
Character string. Directory for the output file. Created automatically if absent. Default
".".
Value
The combined cowplot::plot_grid() object is returned invisibly.
The figure is always written to output.dir.