| gating | R Documentation |
Extracts cells within statistically significant combinations of fluorescent markers, successively, for a set of markers. Statistically significant combinations are identified using two-tailed p-values of a relative risk surface assuming asymptotic normality. This function is currently available for two-level comparisons of a single condition (e.g., case/control) or two conditions (e.g., case/control at time 1 and time 2). Provides functionality for basic visualization and multiple testing correction.
gating(
dat,
vars,
n_condition = c(1, 2),
numerator = TRUE,
bandw = NULL,
alpha = 0.05,
p_correct = "none",
nbc = NULL,
plot_gate = FALSE,
save_gate = FALSE,
name_gate = NULL,
path_gate = NULL,
rcols = c("#FF0000", "#CCCCCC", "#0000FF"),
lower_lrr = NULL,
upper_lrr = NULL,
c1n = NULL,
c2n = NULL,
win = NULL,
...,
doplot = lifecycle::deprecated(),
verbose = lifecycle::deprecated()
)
This function performs a sequential gating strategy for mass cytometry data comparing two levels with one or two conditions. Gates are typically two-dimensional space comprised of two fluorescent markers. The two-level comparison allows for the estimation of a spatial relative risk function and the computation of p-value based on an assumption of asymptotic normality. Cells within statistically significant areas are extracted and used in the next gate. This function relies heavily upon the risk function. Basic visualization is available if plot_gate = TRUE.
The vars argument must be a vector with an even-numbered length where the odd-numbered elements are the markers used on the x-axis of a gate, and the even-numbered elements are the markers used on the y-axis of a gate. For example, if vars = c("V1", "V2", "V3", and "V4") then the first gate is "V1" on the x-axis and "V2" on the y-axis and then the second gate is V3" on the x-axis and "V4" on the y-axis. Makers can be repeated in successive gates.
The n_condition argument specifies if the gating strategy is performed for one condition or two conditions. If n_condition = 1, then the function performs a one condition gating strategy using the internal rrs function, which computes the statistically significant areas (clusters) of a relative risk surface at each gate and selects the cells within the clusters specified by the numerator argument. If n_condition = 2, then the function performs a two conditions gating strategy using the internal lotrrs function, which computes the statistically significant areas (clusters) of a ratio of relative risk surfaces at each gate and selects the cells within the clusters specified by the numerator argument. The condition variable(s) within dat must be of class 'factor' with two levels. The first level is considered the numerator (i.e., "case") value, and the second level is considered the denominator (i.e., "control") value. The levels can also be specified using the c1n and c2n parameters. See the documentation for the internal rrs and lotrrs functions for more details.
The p-value surface of the ratio of relative risk surfaces is estimated assuming asymptotic normality of the ratio value at each gridded knot. The bandwidth is fixed across all layers.
Provides functionality for a correction for multiple testing. If p_correct = "FDR", calculates a False Discovery Rate by Benjamini and Hochberg. If p_correct = "uncorrelated Sidak", calculates an independent Sidak correction. If p_correct = "uncorrelated Bonferroni", calculates an independent Bonferroni correction. If p_correct = "correlated Sidak" or if p_correct = "correlated Bonferroni", then the corrections take into account the into account the spatial correlation of the surface. (NOTE: If p_correct = "correlated Sidak" or if p_correct = "correlated Bonferroni", it may take a considerable amount of computation resources and time to calculate). If p_correct = "Adler and Hasofer" or if p_correct = "Friston", then calculates a correction based on Random Field Theory. If p_correct = "none" (the default), then the function does not account for multiple testing and uses the uncorrected alpha level. See the internal pval_correct function documentation for more details.
An object of class list. This is a named list with the following components:
obsAn object of class 'tibble' of the same features as dat that includes the information for the cells extracted with significant clusters in the final gate.
nAn object of class 'list' of the sample size of cells at each gate. The length is equal to the number of successful gates plus the final result.
gateAn object of class 'list' of 'rrs' objects from each gate. The length is equal to the number of successful gates.
noteAn object of class 'character' of the gating diagnostic message.
The objects of class 'rrs' is similar to the output of the risk function with two additional components:
rrAn object of class 'im' with the relative risk surface.
fAn object of class 'im' with the spatial density of the numerator.
gAn object of class 'im' with the spatial density of the denominator.
PAn object of class 'im' with the asymptotic p-value surface.
lrrAn object of class 'im' with the log relative risk surface.
alphaA numeric value for the alpha level used within the gate.
if (interactive()) {
## Single condition, no multiple testing correction
test_gate <- gating(dat = randCyto,
vars = c("arcsinh_CD4", "arcsinh_CD38",
"arcsinh_CD8", "arcsinh_CD3"),
n_condition = 1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.