Cycles through all fluorophores defined in control.def.file,
identifying variation in their spectral profiles via SOM clustering on
scatter-matched, per-event background-corrected data.
For each fluorophore the autofluorescence reference is derived in
situ from the paired universal-negative file (or internally from the lower
25\
used to project out autofluorescence and identify the empirical peak
detector. All positive events are scatter-matched to unstained events and
their per-event background is subtracted before SOM clustering. This gives a
comprehensive, population-level picture of true fluorophore spectral
variability without requiring a pre-computed af.spectra matrix.
The output is saved as an .rds file and per-fluorophore variant plots are produced if requested.
Usage
get.spectral.variants(
control.dir,
control.def.file,
asp,
spectra,
figures = TRUE,
output.dir = NULL,
parallel = FALSE,
verbose = TRUE,
threads = NULL,
n.cells = 10000L,
som.dim = 10L,
k.neighbors = 3L,
sim.threshold = 0.985,
variant.fill.color = "red",
variant.fill.alpha = 0.7,
median.line.color = "black",
median.linewidth = 1,
stained.sample = NULL,
optimize.necessity.threshold = 0.01,
...
)Arguments
- control.dir
Character. Path to the single-stained control FCS files.
- control.def.file
Character. Path to the control definition CSV. Must pass
check.control.file().- asp
The AutoSpectral parameter list from
get.autospectral.param().- spectra
Numeric matrix. Reference spectra; fluorophores in rows, detectors in columns.
- figures
Logical, default
TRUE. Whether to save variant-spectrum plots.- output.dir
Character or
NULL. Directory for figures and the .rds output file. Defaults toasp$variant.dir.- parallel
Logical, default
FALSE. Enable parallel processing across fluorophores.- verbose
Logical, default
TRUE. Set toFALSEto suppress messages.- threads
Numeric or
NULL. Number of parallel workers. Defaults toasp$worker.process.n.- n.cells
Integer, default
10000. Maximum positive events per fluorophore used for SOM clustering. Files with more events above threshold are randomly downsampled. Passed toget.fluor.variants.- som.dim
Integer, default
10. Side length of the square SOM grid; up tosom.dim^2candidate variants per fluorophore before cosine QC. Passed toget.fluor.variants.- k.neighbors
Integer, default
3. Number of scatter-space nearest neighbours from the unstained pool used to estimate per-event background. Passed toget.fluor.variants.- sim.threshold
Numeric, default
0.99. Minimum cosine similarity to the reference spectrum for a SOM centroid to be retained as a variant. Passed toget.fluor.variants.- variant.fill.color
Color for the shaded ribbon in variant plots. Default
"red".- variant.fill.alpha
Alpha for
variant.fill.color. Default0.7.- median.line.color
Color for the reference-spectrum line. Default
"black".- median.linewidth
Width of the reference-spectrum line. Default
1.- stained.sample
Optional file path to a representative stained FCS file. When supplied, it is read and unmixed to obtain per-fluorophore median positive signal (MFI), which weights the optimization necessity scores by fluorophore brightness. Pass
NULL(default) to use purely geometric scores.- optimize.necessity.threshold
Numeric in
[0, 1], default0.01. Passed tocalculate.optimize.necessity(). Fluorophores whose normalised leakage score falls below this value are flagged as not requiring per-cell spectral optimisation. The result is stored in$optimize.recommendedin the returned list and used automatically byunmix.autospectral.rcpp()to skip unnecessary optimisation passes.- ...
Ignored. Catches and warns on previously used deprecated arguments:
af.spectra,refine,problem.quantile,pos.quantile.
Value
A named list with elements:
thresholdsNamed numeric vector of positivity thresholds in the unmixed space, one per fluorophore.
variantsNamed list of variant-spectra matrices, one per fluorophore. Each matrix has variants in rows and detectors in columns.
delta.listNamed list of delta matrices (variant minus reference spectrum), one per fluorophore.
delta.normsNamed list of Euclidean norms of the deltas, one numeric vector per fluorophore.
The list is also saved as an .rds file in output.dir.