Learn R Programming

ggpicrust2 (version 2.5.10)

calculate_log2_fold_change: Calculate log2 fold change with consistent pseudocount handling

Description

Calculates log2 fold change between two groups with proper handling of zero values using a data-driven pseudocount approach.

Usage

calculate_log2_fold_change(
  mean1,
  mean2,
  pseudocount = NULL,
  reference_values = NULL
)

Value

log2(mean2/mean1) with pseudocount protection

Arguments

mean1

Numeric. Mean abundance of group 1 (reference/control)

mean2

Numeric. Mean abundance of group 2 (comparison/treatment)

pseudocount

Optional numeric. If NULL, calculated from reference_values

reference_values

Optional numeric vector for calculating pseudocount

Details

The fold change direction is group2/group1, so: - Positive values indicate higher abundance in group2 - Negative values indicate higher abundance in group1