1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/// Calculate the expected false discovery rate (E\[FDR\])
///
/// # Arguments
///
/// * `ranked_list_1_len` - The length of the first ranked list (genes bound by the TF in the assay)
/// * `ranked_list_2_len` - The length of the second ranked list (genes responsive when the TF is perturbed)
/// * `overlap_len` - The size of the overlap between the two ranked lists (R ∩ B)
/// * `population_size` - The total population size (all genes assayed in both binding and response experiments)
/// * `sensitivity` - Sensitivity of the intersection algorithm (default is 0.8)
///
/// # Returns
///
/// The expected false discovery rate (E\[FDR\]) as a `f64`.
///
/// # Examples
///
/// ```
/// use dual_threshold_optimization::stat_operations::fdr;
///
/// let ranked_list_1_len = 200; // Size of set B
/// let ranked_list_2_len = 150; // Size of set R
/// let overlap_len = 50; // Size of R ∩ B
/// let population_size = 1000; // Size of G
/// let sensitivity = 0.8; // Default sensitivity
///
/// let est_fdr = fdr(ranked_list_1_len, ranked_list_2_len, overlap_len, population_size, sensitivity);
/// assert!((est_fdr - 0.240625).abs() < 1e-4); // Expected value is approximately 0.240625
/// ```