@@ -38,7 +38,7 @@ Storey() = Storey(0.1)
3838function estimate_pi0 (pValues:: PValues{T} , pi0estimator:: Storey ) where T<: AbstractFloat
3939 lambda = pi0estimator. λ
4040 pi0 = (sum (pValues .>= lambda) / length (pValues)) / (1 - lambda)
41- pi0 = min . (pi0, 1 )
41+ pi0 = min (pi0, 1 )
4242 return pi0
4343end
4444
@@ -69,8 +69,8 @@ function estimate_pi0(pValues::PValues{T}, pi0estimator::StoreyBootstrap) where
6969 pi0 = w ./ n ./ (1 .- lambdas)
7070 min_pi0 = quantile (pi0, q)
7171 mse = (w ./ (n.^ 2 .* (1 .- lambdas). ^ 2 )) .* (1 .- w/ n) + (pi0 .- min_pi0). ^ 2
72- pi0 = min . (pi0[indmin (mse)], 1 )
73- pi0
72+ pi0 = min (pi0[indmin (mse)], 1 )
73+ return pi0
7474end
7575
7676
@@ -97,7 +97,7 @@ function estimate_pi0(pValues::PValues{T}, pi0estimator::LeastSlope) where T<:Ab
9797 end
9898 s0 = s1
9999 end
100- pi0 = min . ( 1 / sx + 1 , n ) / n
100+ pi0 = min ( 1 / sx + 1 , n ) / n
101101 return pi0
102102end
103103
@@ -114,7 +114,7 @@ function lsl_pi0_vec(pValues::AbstractVector{T}) where T<:AbstractFloat
114114 s = (1 .- pValues) ./ (n: - 1 : 1 )
115115 d = diff (s) .< 0
116116 idx = findfirst (d) + 1
117- pi0 = min . ( 1 / s[idx] + 1 , n ) / n
117+ pi0 = min ( 1 / s[idx] + 1 , n ) / n
118118 return pi0
119119end
120120
@@ -194,7 +194,8 @@ function estimate_pi0(pValues::PValues{T}, pi0estimator::RightBoundary) where T<
194194 pi0_decrease = diff (pi0_estimates) .>= 0
195195 pi0_decrease[end ] = true
196196 pi0 = pi0_estimates[findfirst (pi0_decrease, true ) + 1 ]
197- return min .(pi0, 1 )
197+ pi0 = min (pi0, 1 )
198+ return pi0
198199end
199200
200201
@@ -262,12 +263,8 @@ function cbum_pi0(pValues::AbstractVector{T},
262263 for i in 1 : maxiter
263264 γ = 1 - sz/ n
264265 α = - szr / ( ll * szl + sum (zr .* lpr) )
265- # explicitly handle denominator of 0 in julia 0.5: min(x, NaN) == x
266- if isnan (α)
267- break
268- end
269- γ = max .(min .(γ, 1 ), 0 )
270- α = max .(min .(α, 1 ), 0 )
266+ γ = clamp (γ, 0 , 1 )
267+ α = clamp (α, 0 , 1 )
271268 xl = (1 - γ) * (λ^ α)
272269 szl = (xl ./ (γ* λ + xl)) * n1
273270 xr = (1 - γ) * α * pr.^ (α- 1 )
@@ -296,7 +293,7 @@ function cbum_pi0_naive(pValues::AbstractVector{T},
296293 lpr = log .(pValues[idx_right])
297294 ll = log (λ)
298295 for i in 1 : maxiter
299- γ = sum (1 .- z) / n # TODO simplify
296+ γ = sum (1 .- z) / n
300297 α = - sum (z[idx_right])
301298 α = α / ( ll * sum (z[idx_left]) + sum (z[idx_right] .* lpr) )
302299 xl = (1 - γ) * (λ^ α)
0 commit comments