Skip to contents

This function calculates the log2-ratio of the sum of percentages normalized by group size between an experimental group and a control group. It adds a small constant to avoid division by zero.

Usage

calculate_enrichment(
  df,
  percentage_data = "node_percentage",
  expr_group = NULL,
  ctrl_group = NULL
)

Arguments

expr_group

The name of the experimental group as a single string which must match exactly with one of the groups in `sampledef`.

ctrl_group

The name of the control group as a single string which must match exactly with one of the groups in `sampledef`.

percentage

A numeric vector of percentages for each sample.

sampledef

A data frame containing at least a column named 'group' which denotes the group assignment of each sample in the `percentage` vector.

Value

A single numeric value representing the log2-transformed ratio of normalized sums of percentages between the experimental and control groups.

Examples

if (FALSE) { # \dontrun{
percentage <- c(0.1, 0.2, 0.15, 0.05)
sampledef <- data.frame(group = c("exp", "exp", "ctrl", "ctrl"))
calculate_enrichment(df, "exp", "ctrl")
} # }