Skip to contents

# Anova test to compare cell population frequencies of independent samples

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

`frequency_anova_test()` performs an independent measures Anova to compare cell population frequencies of three of more groups. Optionally, post-hoc testing is performed using Emmeans test.

## Usage

    frequency_anova_test(
      fcd,
      cluster_slot,
      cluster_var,
      sample_var,
      group_var,
      anova_p.adjust.method = "bonferroni",
      numeric = F,
      post_hoc_test = NULL,
      post_hoc_p.adjust.method = "bonferroni",
      anova_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.

anova_p.adjust.method

  p-value adjustment method to use for multiple test correction of Anova tests, 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

  string specifying which post hoc test to perform. Select `"tukey"` (balanced data is required to perform a Tukey HSD test) or `"emmeans"`. By default no post-hoc test is performed.

post_hoc_p.adjust.method

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

anova_sig_threshold

  significance threshold of the Anova test. For all Anova tests 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_anova_test()` returns the fcd containing two data frames, "anova" and "annova_pht". "anova" comprises results produced by `anova_test` and "anova_pht" contains results obtained by `emmeans_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_anova_test

`frequency_anova_test()` is a wrapper function around `anova_test`, `tukey_hsd` and `emmeans_test` implemented in the package `rstatix`. The function first calculates cell population frequencies for each sample in sample_var. Then a independent measures, one-way Anova test is performed for each cell population followed by p-value adjustment. If `post_hoc = T`, post-hoc testing with pairwise emmeans tests and p-value correction is performed for each significant Anova test.