A batch is rarely identified by a single column. Once an assay
spans several plates, acquisition runs or experiment days, the
analytical batch is the combination of those columns, and any
analysis that standardizes against a control has to respect that
combination. cr_batch_key() collapses any number of design or
cell columns into one character key that can be grouped on, joined
on and reported.
Arguments
- x
A
cr_experimentor a data frame. For acr_experimentthe design columns are joined onto the cells first; a column present in both tables is taken fromcells.- batch_vars
Character vector of column names that jointly define a batch, for example
c("compound", "run", "plate", "experiment", "interval").- sep
Separator placed between the parts of the key.
- na_label
Label substituted for missing values.
Details
Missing values are replaced by na_label rather than propagated,
so that two rows with an unrecorded plate are grouped together
visibly instead of silently producing NA keys.
See also
cr_batch_reference(), cr_standardize_batch()
Other batch standardization functions:
cr_batch_reference(),
cr_correct_batch(),
cr_standardize_batch()
Examples
exp <- cr_example_experiment(seed = 1, n_cells_per_well = 10)
exp$design$plate <- rep(c("P1", "P2"), length.out = nrow(exp$design))
key <- cr_batch_key(exp, c("plate", "timepoint"))
head(unique(key))
#> [1] "P1 | 24" "P2 | 24"
# Works on a plain data frame too
cr_batch_key(data.frame(a = c("x", "y"), b = 1:2), c("a", "b"))
#> [1] "x | 1" "y | 2"