Skip to contents

# Friedman Rank Sum test to compare cell population frequencies of paired samples

Source: `R/differential_testing.R`
`frequency_friedman_test.Rd`

`frequency_friedman_test()` performs a Friedman Rank Sum test to compare cell population frequencies of three of more groups. Optionally, post-hoc testing is performed using Wilcoxon Rank Sum test.

## Usage

    frequency_friedman_test(
      fcd,
      cluster_slot,
      cluster_var,
      sample_var,
      group_var,
      pair_var,
      friedman_p.adjust.method = "bonferroni",
      numeric = F,
      post_hoc_test = F,
      post_hoc_p.adjust.method = "bonferroni",
      friedman_sig_threshold = 0.05,
      print_results = T
    )

## Arguments

fcd

  flow cytometry data set, that has been subjected to clustering or cell type label prediction with cyCONDOR

cluster_slot

  string specifying which clustering slot to use to find variable specified in cluster_var

cluster_var

  string specifying variable in cluster_slot that identifies cell population labels to be used (e.g. clusters, metaclusters or predicted labels).

sample_var

  string indicating variable in cell_anno that defines sample IDs to be used.

group_var

  string indicating variable in cell_anno that should be used to group samples in sample_var. group_var must have three or more levels.

pair_var

  string indicating variable in cell_anno that should be used to pair the samples.

friedman_p.adjust.method

  p-value adjustment method to use for multiple comparisons of Friedman Rank Sum test, e.g "bonferroni" (default) or "BH" (Benjamini-Hochberg). All available options can be checked in the documentation of the `adjust_pvalue` function from the package `rstatix`.

numeric

  logical, if TRUE numeric levels in cluster_var are ordered in ascending order and "Cluster_" is pasted before number, if FALSE alphabetical ordering is applied.

post_hoc_test

  logical, whether to perform post-hoc testing (TRUE, default) or not (FALSE).

post_hoc_p.adjust.method

  p-value adjustment method to use for post-hoc testing, e.g "bonferroni" (default). All available options can be checked in the documentation of the `adjust_pvalue` function from the package `rstatix`.

friedman_sig_threshold

  significance threshold Friedman Rank Sum test. For all Friedman Rank Sum comparisons with an adjusted p-value equal or smaller than the threshold, post-hoc tests are performed (default 0.05)

print_results

  Logical, indicating if the test results are printed to the console (TRUE) or not (FALSE).

## Value

`frequency_friedman_test` returns the fcd containing two data frames, "friedman" and "friedman_pht". "friedman" comprises results produced by `friedman_test` and `friedman_effsize` and "friedman_pht" contains results obtained by `wilcox_test`. Both data frames have one additional columns, "cluster", containing the information, which cell population was tested. Results are stored in the fcd under extras$statistics.

## Details

frequency_friedman_test

`frequency_friedman_test()` is a wrapper function around `friedman_test`, `friedman_effsize` and `wilcox_test` implemented in the package `rstatix`. The function first calculates cell population frequencies for each sample in sample_var. Then a Friedman Rank Sum test is performed for each cell population followed by p-value adjustment. If `post_hoc = T`, post-hoc testing with pairwise Wilcoxon Rank Sum Tests and p-value correction is performed for each significant Friedman Rank Sum test comparison.