This function performs hypothesis testing by controlling the False Discovery Rate (FDR) based on the
local false discovery rate (lfdr) stored in the fash object.
fdr_control(fash_obj, alpha = 0.05, plot = FALSE, sort = FALSE)A fash object containing the results of the FASH pipeline,
including the vector lfdr.
A numeric value specifying the FDR threshold (significance level)
used to declare discoveries. Default is 0.05.
A logical value. If TRUE, plots the cumulative FDR values
against the rank of units sorted by lfdr, with a horizontal line at the
alpha level. Default is FALSE.
A logical value. If TRUE, returns the FDR results sorted by increasing lfdr.
A list with the following components:
A data frame with one row per unit, containing:
rank: Rank of the unit after sorting by lfdr (1 = smallest lfdr).
index: Original index of the unit in lfdr.
lfdr: The sorted local false discovery rate values.
FDR: The cumulative FDR at each rank, computed as
the running mean of the sorted lfdr values.
A character string summarizing how many units are significant
at the chosen alpha level and the total number of units tested.
A vector of indices (or names, if lfdr is named)
corresponding to units with cumulative FDR less than or equal to alpha.
# Example usage
set.seed(1)
data_list <- list(
data.frame(y = rnorm(n = 5, sd = 0.5), x = 1:5, offset = 0),
data.frame(y = rnorm(n = 5, sd = 0.8), x = 1:5, offset = 0),
data.frame(y = rnorm(n = 5, sd = 0.6), x = 1:5, offset = 0),
data.frame(y = rnorm(n = 5, sd = 0.7), x = 1:5, offset = 0)
)
S <- list(rep(0.5, 5), rep(0.8, 5), rep(0.6, 5), rep(0.7, 5))
grid <- seq(0, 2, length.out = 10)
fash_obj <- fash(data_list = data_list, Y = "y", smooth_var = "x", offset = "offset", S = S, grid = grid, likelihood = "gaussian", verbose = TRUE)
#> Starting data setup...
#> Completed data setup in 0.00 seconds.
#> Starting likelihood computation...
#>
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
#> Completed likelihood computation in 0.10 seconds.
#> Starting empirical Bayes estimation...
#> Completed empirical Bayes estimation in 0.00 seconds.
#> fash object created successfully.
fdr_control(fash_obj, alpha = 0.05, plot = TRUE)
#> 0 datasets are significant at alpha level 0.05. Total datasets tested: 4.
#> $fdr_results
#> rank index lfdr FDR
#> Dataset_1 1 1 1 1
#> Dataset_2 2 2 1 1
#> Dataset_3 3 3 1 1
#> Dataset_4 4 4 1 1
#>
#> $message
#> [1] "0 datasets are significant at alpha level 0.05. Total datasets tested: 4."
#>
#> $significant_units
#> character(0)
#>