Skip to content

Commit e9b5bca

Browse files
Merge pull request #18 from juliangehring/two-step-adjust-method
Add adjustment method selection for TwoStep π0 procedure
2 parents a5efd5d + 110ae0d commit e9b5bca

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ adjust(pvals, ForwardStop())
5454
* Censored BUM
5555
* BUM
5656
* FlatGrenander
57+
* Oracle for known π0
5758

5859
```julia
5960
estimate_pi0(pvals, Storey())
6061
estimate_pi0(pvals, StoreyBootstrap())
6162
estimate_pi0(pvals, LeastSlope())
6263
estimate_pi0(pvals, TwoStep())
6364
estimate_pi0(pvals, TwoStep(0.05))
65+
estimate_pi0(pvals, TwoStep(0.05, BenjaminiHochbergAdaptive(0.9))
6466
estimate_pi0(pvals, RightBoundary())
6567
estimate_pi0(pvals, CensoredBUM())
6668
estimate_pi0(pvals, BUM())
6769
estimate_pi0(pvals, FlatGrenander())
70+
estimate_pi0(pvals, Oracle(0.9))
6871
```

src/pi0-estimators.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,20 @@ Reference: Benjamini, Krieger and Yekutieli, 2006
160160
"""
161161
immutable TwoStep <: Pi0Estimator
162162
α::AbstractFloat
163-
## method::PValueAdjustmentMethod
163+
method::PValueAdjustmentMethod
164164

165-
TwoStep(α) = isin(α, 0., 1.) ? new(α) : throw(DomainError())
165+
TwoStep, method) = isin(α, 0., 1.) ? new, method) : throw(DomainError())
166166
end
167167

168168
TwoStep() = TwoStep(0.05)
169169

170+
TwoStep(α) = TwoStep(α, BenjaminiHochberg())
171+
170172
function estimate_pi0{T<:AbstractFloat}(pValues::Vector{T}, pi0estimator::TwoStep)
171-
twostep_pi0(pValues, pi0estimator.α)
173+
twostep_pi0(pValues, pi0estimator.α, pi0estimator.method)
172174
end
173175

174-
function twostep_pi0{T<:AbstractFloat}(pValues::Vector{T}, alpha::T, method::PValueAdjustmentMethod = BenjaminiHochberg())
176+
function twostep_pi0{T<:AbstractFloat}(pValues::Vector{T}, alpha::T, method::PValueAdjustmentMethod)
175177
padj = adjust(pValues, method)
176178
pi0 = sum(padj .>= (alpha/(1+alpha))) / length(padj)
177179
return(pi0)

test/test-pi0-estimators.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,27 @@ using StatsBase
127127
alpha = 0.05
128128

129129
## checked against mutoss::TSBKY_pi0_est
130-
@test twostep_pi0(p, alpha) 0.665
131-
@test twostep_pi0(p0, alpha) 1.0
132-
@test twostep_pi0(p1, alpha) 0.29
130+
@test twostep_pi0(p, alpha, BenjaminiHochberg()) 0.665
131+
@test twostep_pi0(p0, alpha, BenjaminiHochberg()) 1.0
132+
@test twostep_pi0(p1, alpha, BenjaminiHochberg()) 0.29
133133

134134
@test issubtype(typeof(TwoStep(alpha)), Pi0Estimator)
135135
@test estimate_pi0(p, TwoStep()) 0.665
136+
@test estimate_pi0(p, TwoStep()) 0.665
136137
@test estimate_pi0(p, TwoStep(alpha)) 0.665
137138
@test estimate_pi0(p0, TwoStep(alpha)) 1.0
138139
@test estimate_pi0(p1, TwoStep(alpha)) 0.29
140+
@test estimate_pi0(p, TwoStep(alpha, BenjaminiHochberg())) 0.665
139141

140142
@test estimate_pi0(p, TwoStep(0.1)) 0.63
141143
@test estimate_pi0(p, TwoStep(0.0)) 1.0
142144
@test estimate_pi0(p, TwoStep(1.0)) 0.415
145+
@test estimate_pi0(p, TwoStep(0.1, BenjaminiHochberg())) 0.63
143146

144147
## unsorted p-values
145148
p_unsort = unsort(p)
146149
@test !issorted(p_unsort)
147-
@test twostep_pi0(p_unsort, alpha) 0.665
150+
@test estimate_pi0(p_unsort, TwoStep(alpha)) 0.665
148151
@test !issorted(p_unsort)
149152

150153
end

0 commit comments

Comments
 (0)