Skip to contents

This function calculates the false discovery rate (FDR) by comparing observed values to permuted values.The function sorts observed values, compares them against permuted data, and computes FDR using the median of permutation results.

Usage

calculateFalseDiscoveryRate(
  observedValues,
  permutedValues,
  showProgress = FALSE
)

Arguments

observedValues

Numeric vector. The observed test statistics or values to be evaluated for significance.

permutedValues

Numeric matrix. The permuted test statistics or values, with rows corresponding to the same values as in observedValues and columns representing different permutations.

showProgress

Logical. If TRUE, a progress bar will be shown during the computation.

Value

A numeric vector of the same length as observedValues, containing the estimated FDR for each observed value.

Examples

observedValues <- c(2.5, 1.8, 3.1, 0.7, 2.9)
set.seed(123)
permutedValues <- matrix(rnorm(5 * 5, mean = 2, sd = 1), nrow = 5)
fdr <- calculateFalseDiscoveryRate(observedValues, permutedValues,
    showProgress = FALSE
)
print(fdr)
#> [1] 0.3333333 0.7500000 0.3333333 1.0000000 0.3333333