Skip to contents

Consumes summarize_factor_activity() (no competing calculator) and subtracts a declared per-factor baseline from each group mean: centered = mean - baseline[factor]. The baseline is either the equal-group mean of group means (each group counts once) or the observation-weighted mean (group means weighted by group size n); the choice is declared in the output metadata. Raw means, baselines, centered values and group counts are all returned. Display-only transformation: no inferential labeling, and centering never changes ordering within a factor.

Usage

center_factor_activity(
  fit,
  metadata,
  by,
  baseline = c("equal_group", "observation_weighted"),
  id_col = "sample",
  unit_col = NULL,
  weights = NULL,
  na_action = "fail"
)

Arguments

fit

Native fit or representation.

metadata

Sample metadata.

by

Grouping column(s).

baseline

equal_group or observation_weighted. With weights, the group means are weighted means but the baseline still weights them by group size n, so it is then not a weighted grand mean.

id_col

Sample ID column.

unit_col

Optional independent-unit column (carried through).

weights

Optional named observation weights (passed to summarize_factor_activity(); the baseline itself uses group sizes n).

na_action

fail or explicit omit.

Value

The summarize_factor_activity() table plus baseline and centered columns, with centering declared in analysis_metadata.

Author

Mikhael Manurung. Group-summary workflow credits David Zemmour / Zemmour Lab.