Skip to content

Commit ff193a6

Browse files
Merge pull request #33 from juliangehring/simple-scalar-float-signatures
Simplify signature definition for scalar floats
2 parents a578a89 + aaefdc1 commit ff193a6

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/model.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cdf(bum, 0:0.05:1)
3131
"""
3232
function BetaUniformMixtureModel end
3333

34-
function BetaUniformMixtureModel{T<:AbstractFloat}(π0::T, α::T = 0.5, β::T = 1.0)
34+
function BetaUniformMixtureModel(π0::AbstractFloat, α::AbstractFloat = 0.5, β::AbstractFloat = 1.0)
3535
if !isin(π0, 0., 1.)
3636
throw(DomainError())
3737
end

src/pi0-estimators.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function estimate_pi0{T<:AbstractFloat}(pValues::PValues{T}, pi0estimator::Store
3737
storey_pi0(pValues, pi0estimator.λ)
3838
end
3939

40-
function storey_pi0{T<:AbstractFloat}(pValues::AbstractVector{T}, lambda::T)
40+
function storey_pi0{T<:AbstractFloat}(pValues::AbstractVector{T}, lambda::AbstractFloat)
4141
pi0 = (sum(pValues .>= lambda) / length(pValues)) / (1.-lambda)
4242
pi0 = min(pi0, 1.)
4343
return pi0
@@ -170,7 +170,7 @@ function estimate_pi0{T<:AbstractFloat}(pValues::PValues{T}, pi0estimator::TwoSt
170170
twostep_pi0(pValues, pi0estimator.α, pi0estimator.method)
171171
end
172172

173-
function twostep_pi0{T<:AbstractFloat}(pValues::AbstractVector{T}, alpha::T, method::PValueAdjustmentMethod)
173+
function twostep_pi0{T<:AbstractFloat}(pValues::AbstractVector{T}, alpha::AbstractFloat, method::PValueAdjustmentMethod)
174174
padj = adjust(pValues, method)
175175
pi0 = sum(padj .>= (alpha/(1+alpha))) / length(padj)
176176
return(pi0)
@@ -261,8 +261,9 @@ function estimate_pi0(pi0fit::CensoredBUMFit)
261261
return π0
262262
end
263263

264-
function cbum_pi0{T<:AbstractFloat}(pValues::AbstractVector{T}, γ0::T = 0.5, λ::T = 0.05,
265-
xtol::T = 1e-6, maxiter::Int = 10000)
264+
function cbum_pi0{T<:AbstractFloat}(pValues::AbstractVector{T},
265+
γ0::AbstractFloat = 0.5, λ::AbstractFloat = 0.05,
266+
xtol::AbstractFloat = 1e-6, maxiter::Int = 10000)
266267
n = length(pValues)
267268
idx_right = pValues .>= λ
268269
n2 = sum(idx_right)
@@ -297,8 +298,9 @@ function cbum_pi0{T<:AbstractFloat}(pValues::AbstractVector{T}, γ0::T = 0.5, λ
297298
return NaN, [γ, α], false
298299
end
299300

300-
function cbum_pi0_naive{T<:AbstractFloat}(pValues::AbstractVector{T}, γ0::T = 0.5, λ::T = 0.05,
301-
xtol::T = 1e-6, maxiter::Int = 10000)
301+
function cbum_pi0_naive{T<:AbstractFloat}(pValues::AbstractVector{T},
302+
γ0::AbstractFloat = 0.5, λ::AbstractFloat = 0.05,
303+
xtol::AbstractFloat = 1e-6, maxiter::Int = 10000)
302304
n = length(pValues)
303305
z = fill(1-γ0, n)
304306
idx_left = pValues .< λ

src/pval-adjustment.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ immutable BenjaminiHochbergAdaptive <: PValueAdjustmentMethod
5454
end
5555

5656
## default to BenjaminiHochberg
57-
BenjaminiHochbergAdaptive{T<:AbstractFloat}(π0::T) = BenjaminiHochbergAdaptive(Oracle(π0))
57+
BenjaminiHochbergAdaptive(π0::AbstractFloat) = BenjaminiHochbergAdaptive(Oracle(π0))
5858

5959
BenjaminiHochbergAdaptive() = BenjaminiHochbergAdaptive(1.0)
6060

@@ -111,7 +111,7 @@ function benjamini_liu(pValues::PValues, n::Integer)
111111
return min(sortedPValues[originalOrder], 1)
112112
end
113113

114-
function benjamini_liu_step{T<:AbstractFloat}(p::T, i::Int, n::Int)
114+
function benjamini_liu_step(p::AbstractFloat, i::Int, n::Int)
115115
# a bit more involved because cutoffs at significance α have the form:
116116
# P_(i) <= 1- [1 - min(1, m/(m-i+1)α)]^{1/(m-i+1)}
117117
s = n-i+1
@@ -248,7 +248,7 @@ end
248248

249249

250250
function stepdown!{T<:AbstractFloat}(sortedPValues::AbstractVector{T}, multiplier::Function, k::Integer, n::Integer)
251-
stepfun(p::T, i::Int, n::Int) = p * multiplier(i, n)
251+
stepfun(p::AbstractFloat, i::Int, n::Int) = p * multiplier(i, n)
252252
general_stepdown!(sortedPValues, stepfun, k, n)
253253
return sortedPValues
254254
end

src/qvalue.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## qValues ##
22

3-
function qValues{T<:AbstractFloat}(pValues::AbstractVector{T}, pi0::T, pfdr::Bool = false)
3+
function qValues{T<:AbstractFloat}(pValues::AbstractVector{T}, pi0::AbstractFloat, pfdr::Bool = false)
44
valid_pvalues(pValues)
55
valid_pvalues([pi0])
66
n = length(pValues)

0 commit comments

Comments
 (0)