Learn R Programming

CytoProfile (version 0.2.4)

cyt_univariate_multi: Univariate Tests for Multi‑Level Categorical Predictors

Description

cyt_univariate_multiprovides univariate statistical testing for categorical predictors with more than two levels. For each categorical predictor and numeric outcome pair, a global test is performed, followed by pairwise comparisons if the global test is significant. Users may choose between two methods, classical ANOVA with Tukey’s Honest Significant Difference (HSD) or a non‑parametric Kruskal–Wallis test followed by pairwise Wilcoxon rank–sum tests. The return format can either be a list of adjusted p‑values for each outcome–predictor pair or, if format_output = TRUE, a tidy data frame summarizing all pairwise comparisons.

Usage

cyt_univariate_multi(
  data,
  method = c("anova", "kruskal"),
  cat_vars = NULL,
  cont_vars = NULL,
  p_adjust_method = "BH",
  format_output = FALSE
)

Value

Either a list (if format_output = FALSE) or a data frame (if format_output = TRUE).

Arguments

data

A data frame or matrix containing both categorical and continuous variables. Character columns will be converted to factors.

method

Character specifying the type of global test to perform. Use "anova" (default) for one‑way ANOVA with Tukey HSD or "kruskal" for Kruskal–Wallis with pairwise Wilcoxon tests.

cat_vars

Optional character vector of predictor column names. When NULL, all factor or character columns in data are used.

cont_vars

Optional character vector of numeric outcome variable names. When NULL, all numeric columns in data are used.

p_adjust_method

Character string specifying the method for p‑value adjustment across pairwise comparisons. Passed to p.adjust. Default is "BH".

format_output

Logical. If TRUE, returns a tidy data frame; otherwise (default) returns a list of numeric vectors keyed by "Outcome_Categorical". Each numeric vector contains adjusted p‑values for the pairwise comparisons.

Author

Shubh Saraswat

Examples

Run this code
data("ExampleData1")
cyt_univariate_multi(ExampleData1[, c(1:2, 5:6)], method = "kruskal",
                     format_output = TRUE)

Run the code above in your browser using DataLab