Skip to contents

Runs a parametric or non-parametric two-sample test comparing cells (or replicate summaries) from a treatment group to the control group on a single channel.

Usage

cr_test(
  experiment,
  channel,
  treatment,
  control,
  test = c("mann_whitney", "t_test", "welch", "wilcoxon_signed"),
  level = c("cell", "replicate", "both")
)

Arguments

experiment

A cr_experiment.

channel

Channel to test.

treatment

Name of the treatment group (matches design$treatment).

control

Name of the control group.

test

One of "mann_whitney", "t_test" (pooled variance), "welch" (unequal variance). The legacy "wilcoxon_signed" choice is refused: this interface has no explicit matched-pair key. Align complete pairs by a verified identifier and use stats::wilcox.test() with paired = TRUE for paired inference.

level

"cell" (default), "replicate" or "both".

Value

A cr_result object with the elements comparison, cell_level, rep_level, effect_sizes and fold_change. Effect sizes use cells for level = "cell" and replicate medians for "replicate" or "both". With "both", the additional cell_effect_sizes element retains the cell-level comparison. Replicate effect estimates differ from versions through 0.2.0.9000, which computed cell effects regardless of the requested level.

Examples

exp <- cr_example_experiment(seed = 1, n_cells_per_well = 30)
res <- cr_test(exp,
               channel = "marker_1",
               treatment = "CompoundA_high",
               control = "Untreated",
               test = "mann_whitney",
               level = "replicate")
print(res)
#> ── cr_result ───────────────────────────────────────────────────────────────────
#> • Channel: "marker_1"
#> • Treatment: "CompoundA_high"
#> • Control: "Untreated"
#> • Test: "mann_whitney"
#> ℹ Replicate-level p = 1.54e-06
#> ℹ Effect sizes: cohens_d, hedges_g, cliffs_delta, and rank_biserial