Skip to contents

# t-test to compare cell population frequencies

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

`frequency_t_test()` performs a two-sided, two sample t-test on cell type frequencies.

## Usage

    frequency_t_test(
      fcd,
      cluster_slot,
      cluster_var,
      sample_var,
      group_var,
      pair_var = NULL,
      paired_test = F,
      var.equal = F,
      detailed = F,
      p.adjust.method = "bonferroni",
      numeric = F,
      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 exactly two levels.

pair_var

  string indicating variable in cell_anno that defines pairing of samples, e.g. donor ID, that should be used if `paired_test = T`.

paired_test

  logical, indicating if a paired (TRUE) or unpaired test (FALSE, default) should be performed.

var.equal

  logical, indicating whether variance in both groups should be treated as equal (TRUE) or not (FALSE, default). TRUE uses pooled variance, FALSE the Welch approximation, see documentation of `t_test` .

detailed

  logical if detailed output from `t_test` should be reported.

p.adjust.method

  p-value adjustment method to use for multiple comparison testing, 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.

print_results

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

## Value

`frequency_t_test()` returns the fcd containing a data frame produced by `t_test` with two additional columns, "cluster" containing the information, which cell population was tested, and "applied_test", indicating which test was used. Results are stored in the fcd under extras$statistics.

## Details

frequency_t_test

`frequency_t_test()` is a wrapper function around the `t_test()` implemented in the package `rstatix`. The function first calculates cell population frequencies for each sample in sample_var. Then, a two-sided, two sample t-test is performed between two groups defined in group_var. The test can either be run unpaired (two independent groups) or paired. Afterwards, p-value adjustment will be performed across all comparisons that were made.