This function performs spectral unmixing on FCS data using various methods.
Usage
unmix.fcs(
fcs.file,
spectra,
asp,
flow.control,
method = c("AutoSpectral", "OLS", "WLS", "Poisson", "FastPoisson"),
weighted = FALSE,
weights = NULL,
af.spectra = NULL,
spectra.variants = NULL,
output.dir = NULL,
file.suffix = NULL,
include.raw = FALSE,
include.imaging = TRUE,
use.dist0 = TRUE,
divergence.threshold = 10000,
divergence.handling = "Balance",
balance.weight = 0.5,
speed = c("fast", "medium", "slow"),
parallel = TRUE,
threads = if (parallel) 0 else 1,
verbose = TRUE,
n.variants = NULL,
chunk.size = 2e+06,
pipeline = c("legacy", "joint"),
n.passes = 1L,
n.af.passes = 1L,
cell.weight = if (asp$cytometer == "ID7000") TRUE else FALSE,
noise.floor = 125,
alpha = 0.5,
collinear.threshold = 0.5,
joint.pair.resolution = TRUE,
refine.af.quantile = 0.5,
...
)Arguments
- fcs.file
A character string specifying the path to the FCS file.
- spectra
A matrix containing the spectral data. Fluorophores in rows, detectors in columns.
- asp
The AutoSpectral parameter list. Prepare using
get.autospectral.param.- flow.control
A list containing flow cytometry control parameters.
- method
A character string specifying the unmixing method to use. The default as of version 1.0.0 is now
AutoSpectralto avoid confusion. To use AutoSpectral unmixing, you must provide at leastaf.spectrato perform autofluorescence extraction (on a per-cell basis). To also optimize fluorophore spectra, providespectra.variants. To perform other types of unmixing, select from the options:OLS,WLS,PoissonorFastPoisson.FastPoissonrequires installation ofAutoSpectralRcpp.- weighted
Logical, whether to use ordinary or weighted least squares unmixing as the base algorithm in AutoSpectral legacy pipeline unmixing. Default is
FALSEand will use OLS.- weights
Optional numeric vector of weights (one per fluorescent detector). Default is
NULL, in which case weighting will be done by channel means (Poisson variance). Only used forWLS.- af.spectra
Spectral signatures of autofluorescences, normalized between 0 and 1, with fluorophores in rows and detectors in columns. Prepare using
get.af.spectra. Required forAutoSpectralunmixing. Default isNULLand will thus provoke failure if no spectra are provided andAutoSpectralis selected.- spectra.variants
Named list (names are fluorophores) carrying matrices of spectral signature variations for each fluorophore. Prepare using
get.spectral.variants. Default isNULL. Used for AutoSpectral unmixing. Required for per-cell fluorophore optimization.- output.dir
A character string specifying the directory to save the unmixed FCS file. Default is
NULL, which will use./AutoSpectral_unmixed.- file.suffix
A character string to append to the output file name. Default is
NULL.- include.raw
A logical value indicating whether to include raw expression data in the written FCS file. Default is
FALSEto provide smaller output files.- include.imaging
A logical value indicating whether to include imaging parameters in the written FCS file. Default is
TRUE.- use.dist0
Legacy pipeline argument. Logical, controls whether the selection of the optimal AF signature for each cell is determined by the minimization of potential AF spillover into the fluorophore channels (
use.dist0=TRUE) or by which unmixing minimizes the per-cell residual (use.dist0=FALSE). Default isTRUE. Used for legacy AutoSpectral unmixing.- divergence.threshold
Numeric. Used for
FastPoissononly. Threshold to trigger reversion towards WLS unmixing when Poisson result diverges for a given point. To be deprecated.- divergence.handling
String. How to handle divergent cells from Poisson IRLS. Options are
NonNeg(non-negativity will be enforced),WLS(revert to WLS initial unmix) orBalance(WLS and NonNeg will be averaged). Default isBalance. To be deprecated.- balance.weight
Numeric. Weighting to average non-convergent cells. Used for
Balanceoption underdivergence.handling. Default is0.5. To be deprecated.- speed
Selector for the precision-speed trade-off in AutoSpectral per-cell fluorophore optimization. Options are
fast,mediumandslow, with the default beingfast. As of version 1.0.0, the backend for how this works has changed. Spectral variants and AF signatures are now pre-screened per cell to identify likely candidates, so brute force testing of all variants is no longer required. So,speedcontrols the number of variants to be tested per cell, withfasttesting a single variant,mediumtesting 3 variants, andslowtesting 10 variants. While this is now implemented in pure R inAutoSpectral, installation ofAutoSpectralRcppis strongly encouraged for faster processing.- parallel
Logical, default is
TRUE, which enables parallel processing for per-cell unmixing methods.- threads
Numeric, defaults to a single thread for sequential processing (
parallel=FALSE) or all available cores ifparallel=TRUE.- verbose
Logical, controls messaging. Default is
TRUE. Set toFALSEto have it shut up.- n.variants
Numeric, used for legacy AutoSpectral pipeline unmixing. Number of variants to test per cell. Allows explicit control over the number used, as opposed to
speed, which selects from pre-defined choices. Providing a numeric value ton.variantswill overridespeed, allowing up ton.variants(or the max available) variants to be tested. The default isNULL, in which casen.variantswill be ignored.- chunk.size
Numeric, number of events to use per chunk of unmixing. Used to manage memory when processing large FCS files. As a rough guide, you will need approximately 10x the size of the raw FCS file on disk as available memory. Default is set at
2e6events, assuming ~20GB memory available.- pipeline
Character, one of
"legacy"(default) or"joint". Passed tounmix.autospectral.rcpp()."joint"uses the new covariance-weighted joint per-cell pipeline;"legacy"reproduces the behaviour of AutoSpectral prior to version 1.6.0.- n.passes
Integer, default
1L. Number of joint optimisation passes per cell. Only used whenpipeline = "joint". Set higher for some improvement in unmixing with high spillover datasets.- n.af.passes
Integer, default
1L. Number of autofluorescence extraction passes per cell. Only used whenpipeline = "joint". Passed tounmix.autospectral.rcpp().- cell.weight
Logical, default
FALSE. Applies per-cell detector weighting to the joint unmixing solve. Only used whenpipeline = "joint". Passed tounmix.autospectral.rcpp().- noise.floor
Numeric, default
125. Lower clamp on the denominator of the per-cell detector weights whencell.weight = TRUE. Only used whenpipeline = "joint". Passed tounmix.autospectral.rcpp().- alpha
Numeric, default
0.5. Weighting for balancing residual and covariance spillover minimization. Only used whenpipeline = "joint". Passed tounmix.autospectral.rcpp().- collinear.threshold
Numeric, default
0.5. Cosine similarity value to trigger conflict assessment for collinear fluorophore variants. Only used whenpipeline = "joint". Passed tounmix.autospectral.rcpp().- joint.pair.resolution
Logical, default
TRUE. Whether to perform conflict-resolution for collinear fluorophore pairs. Only used whenpipeline = "joint". Passed tounmix.autospectral.rcpp().- refine.af.quantile
Numeric, default
0.5. Fraction of cells taken forward for additional AF passes (seen.af.passes). Only used whenpipeline = "joint". Passed tounmix.autospectral.rcpp().- ...
Ignored. Used to catch deprecated arguments.