Skip to contents

The function sets up a root-finding problem in which the appropriate per-test cutoff alpha is found that satisfies the supplied FDR (in expectation), then reports overall power for tests carried out at that alpha level. Vectorized over n, but nothing else.

Usage

power_hd(n, p, d, m, FDR = 0.1)

Arguments

n

Sample size (per group)

p

Number of features (genes)

d

Number of differential features (differentially expressed genes)

m

Minimum difference among differential features, in terms of mean difference divided by SD (effect size)

FDR

Target FDR

Value

A list containing three items:

  • expected_hits: Expected number of discoveries (marginal power multiplied by number of differential features)

  • marginal_power: Power to detect a given feature (function assumes this is the same for all features)

  • disjunctive_power: Power to detect at least one feature

Details

Further reading:

  • Pawitan2005: Original idea

  • wiki: Derivation and explanation

Examples

power_hd(10, 1000, 100, 1)
#> $expected_hits
#> [1] 7.625742
#> 
#> $marginal_power
#> [1] 0.07625742
#> 
#> $disjunctive_power
#> [1] 0.999641
#> 
power_hd(seq(10, 100, by=10), 1000, 100, 1)
#> $expected_hits
#>  [1]  7.625742 61.921585 87.955227 96.580856 99.111374 99.786569 99.952146
#>  [8] 99.989884 99.997966 99.999608
#> 
#> $marginal_power
#>  [1] 0.07625742 0.61921585 0.87955227 0.96580856 0.99111374 0.99786569
#>  [7] 0.99952146 0.99989884 0.99997966 0.99999608
#> 
#> $disjunctive_power
#>  [1] 0.999641 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
#>  [9] 1.000000 1.000000
#> 
power_hd(300, 100000, 50, 0.2)
#> $expected_hits
#> [1] 0.09362905
#> 
#> $marginal_power
#> [1] 0.001872581
#> 
#> $disjunctive_power
#> [1] 0.08945943
#>