Skip to contents

WHAT: for every population, compares each non-reference group against the reference group, and (with 3+ groups) also reports an omnibus test.

Usage

stats_group_comparison(
  freq,
  group_of,
  reference = NULL,
  min_n = 3L,
  measure = "auto",
  value_col = NULL
)

Arguments

freq

population_frequencies table

group_of

named character vector sample_id -> group label

reference

the group all others are compared against (e.g. controls)

min_n

minimum samples per group for a test to be attempted

measure

Which abundance measure to use. Default "auto".

value_col

override the abundance measure: test this column instead of pct_of_cd45_pos/cells_per_ul. Used for tables shaped like freq (sample_id, population, ...) but carrying a different quantity, e.g. functional-marker pct_positive or a derived population ratio.

Value

data.frame, one row per population x comparison

Details

WHY THESE TESTS: group sizes in this design are single-digit to low-double-digit and cell-abundance distributions are right-skewed with outliers, so normality is not a safe assumption and a t-test's nominal p-value would be unreliable. Wilcoxon rank-sum (Mann-Whitney) assumes only independence and ordinal comparability. Its p-value is computed exactly, ties included (see rank_sum_p()), so it behaves sensibly at n = 6. Kruskal-Wallis is its multi-group extension; its p-value is R's chi-squared approximation, which is rough at a handful of donors per group, and it is read as an omnibus screen before the pairwise columns.

WHY BOTH RAW AND ADJUSTED p: testing 12 populations x 2 groups is 24 tests, at which, under the null and taking the tests as independent, about one p < 0.05 (1.2) is expected and the chance of at least one is 1 - 0.95^24 = 71%. Reporting only raw p invites reading noise as signal; reporting only adjusted p hides a real trend in an underpowered study. Both are written, with Benjamini-Hochberg FDR (not Bonferroni) because these tests are correlated and the goal is a ranked shortlist, not a single confirmatory decision.