Skip to contents

Perform Kruskal-Wallis test for glycomics or glycoproteomics data. The function supports non-parametric comparison of multiple groups. For significant results, Dunn's post-hoc test is automatically performed. P-values are adjusted for multiple testing using the method specified by p_adj_method.

Usage

gly_kruskal(
  exp,
  group_col = "group",
  p_adj_method = "BH",
  add_info = TRUE,
  ...
)

gly_kruskal_(expr_mat, groups, p_adj_method = "BH", ...)

Arguments

exp

A glyexp::experiment() object containing expression matrix and sample information.

group_col

A character string specifying the column name of the grouping variable in the sample information. Default is "group".

p_adj_method

A character string specifying the method to adjust p-values. See p.adjust.methods for available methods. Default is "BH". If NULL, no adjustment is performed.

add_info

A logical value. If TRUE (default), variable information from the experiment will be added to the result tibble. If FALSE, only the statistical results are returned. Only applicable to gly_kruskal().

...

Additional arguments passed to stats::kruskal.test().

expr_mat

A numeric matrix with variables as rows and samples as columns.

groups

A factor or character vector specifying group membership for each sample. Must have at least 2 levels. Character vectors will be automatically converted to factors.

Value

A list containing two elements:

  • tidy_result: A list containing:

    • main_test: A tibble with Kruskal-Wallis test results containing the following columns:

      • variable: Variable name

      • statistic: Kruskal-Wallis test statistic

      • p_value: Raw p-value from Kruskal-Wallis test

      • parameter: Degrees of freedom

      • method: Statistical method used

      • p_adj: Adjusted p-value (if p_adj_method is not NULL)

      • post_hoc: Significant group pairs from post-hoc test

    • post_hoc_test: A tibble with pairwise comparison results containing the following columns:

      • variable: Variable name

      • group1: First group in comparison

      • group2: Second group in comparison

      • p_value: Raw p-value from Dunn's test

      • p_adj: Adjusted p-value from Dunn's test

  • raw_result: A list containing:

    • main_test: A list of raw kruskal.test objects.

    • post_hoc_test: A list of raw dunnTest objects.

Details

The function performs log2 transformation on the expression data (log2(x + 1)) before statistical testing. At least 2 groups are required in the grouping variable.

gly_kruskal() is the top-level API that works with glyexp::experiment() objects and supports the add_info parameter for joining experiment metadata.

gly_kruskal_() is the underlying API that works with matrices and factor vectors directly, providing more flexibility for users who don't use the glyexp package.

Post-hoc Test: Dunn's test with Holm correction for multiple comparisons (FSA::dunnTest()) is performed for variables with significant main effects (p_adj < 0.05).

Required packages

This function requires the FSA package for Dunn's post-hoc test.