batch_diagnostics: Batch and confounding diagnostics

View source: R/batch.R

batch_diagnosticsR Documentation

Batch and confounding diagnostics

Description

Checks whether the study design, the quality-control metrics and the main axes of variation follow technical batches such as cartridges and run dates.

Usage

batch_diagnostics(x, group = NULL, batch = c("CartridgeID", "Date"))

Arguments

x

A nacho object from load_rcc() or normalise().

group

A column of nacho_samples(x) with the biological groups, or NULL to skip the design check.

batch

Columns of nacho_samples(x) that describe technical batches.

Details

Start with design: when a batch level holds a single group, batch and biology cannot be told apart, and no normalisation can fix it.

Value

A list:

  • design: NULL without group; otherwise, for each batch variable, its number of levels, Cramér's V with group, the number of levels that hold a single group, and confounded, TRUE when at least one does. A level counts as holding a single group only when it has two or more samples with a group, so a cartridge with one sample never makes the design confounded. Cramér's V uses only the samples that have both a group and a batch, and is NA when the batch or group has fewer than two levels among them.

  • crosstabs: NULL without group; otherwise the table of group against each batch variable.

  • metrics: Kruskal-Wallis tests of each quality-control metric against each batch variable.

  • pc_batch: the share of each principal component's variance explained by each batch variable.

metrics and pc_batch are data frames with these columns, and have no rows when there is nothing to report. A batch variable with one level gives NA in statistic, p_value and r_squared, and a constant metric gives NA in statistic and p_value. A batch variable whose levels each hold one sample with a value also gives NA in r_squared. For PlexSet data, BD and FoV are tested once per lane.

Examples

data(GSE74821)
batch_diagnostics(GSE74821)$pc_batch

NACHO documentation built on Nov. 2, 2026, 5:09 p.m.