Skip to content

Commit

Permalink
bugfix for failing wald tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kose-y committed Feb 27, 2023
1 parent e76b3c6 commit 241bed0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TrajGWAS"
uuid = "9514c204-b736-47c9-8157-11c3e9e5ab30"
authors = ["Seyoon Ko <[email protected]>, Chris German <[email protected]>, and contributors"]
version = "0.4.1"
version = "0.4.3"

[deps]
BGEN = "6db4b851-9beb-4b83-9d64-eb1cfb37721d"
Expand Down
59 changes: 39 additions & 20 deletions src/gwas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -592,25 +592,32 @@ function trajgwas(
ctable = coeftable(altmodel)
copyto!(pvalsβ, 1, ctable.cols[4], fittednullmodel.p + 1, q)
copyto!(stderrβ, 1, ctable.cols[2], fittednullmodel.p + 1, q)
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4],
altmodel.p + fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[2],
altmodel.p + fittednullmodel.l + 1, q)
end
catch e
try
WiSER.fit!(altmodel, solver, parallel = parallel, runs = runs, init=init(altmodel); throw_on_failure=true)
copyto!(γ̂β, 1, altmodel.β, fittednullmodel.p + 1, q)
ctable = coeftable(altmodel)
copyto!(pvalsβ, 1, ctable.cols[4], fittednullmodel.p + 1, q)
copyto!(stderrβ, 1, ctable.cols[2], fittednullmodel.p + 1, q)
copyto!(stderrβ, 1, ctable.cols[2], fittednullmodel.p + 1, q)
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4],
altmodel.p + fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[2],
altmodel.p + fittednullmodel.l + 1, q)
end
catch e
@warn "Test failed for $(snpj[1]). The SNP may be too rare. Effect size NaN and p-value -1 will be printed."
success = false
end
end
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4],
altmodel.p + fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[2],
altmodel.p + fittednullmodel.l + 1, q)
end
end
if snponly
println(io, "$(snpj[1])\t$(snpj[4])\t$(snpj[2])\t",
Expand Down Expand Up @@ -1220,6 +1227,13 @@ function trajgwas(
copyto!(stderrβ, 1, ctable.cols[2], fittednullmodel.p + 1, q)
copyto!(pvalsβ, 1, ctable.cols[4],
fittednullmodel.p + 1, q)
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[1],
altmodel.p + fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4],
altmodel.p + fittednullmodel.l + 1, q)
end
catch e
try
WiSER.fit!(altmodel, init=init(altmodel), solver, parallel = parallel, runs = runs; throw_on_failure=true)
Expand All @@ -1228,18 +1242,18 @@ function trajgwas(
copyto!(stderrβ, 1, ctable.cols[2], fittednullmodel.p + 1, q)
copyto!(pvalsβ, 1, ctable.cols[4],
fittednullmodel.p + 1, q)
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[1],
altmodel.p + fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4],
altmodel.p + fittednullmodel.l + 1, q)
end
catch e
@warn "Test failed for $(rec_ids[1][1]). The SNP may be too rare. Effect size NaN and p-value -1 will be printed."
success = false
end
end
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[1],
altmodel.p + fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4],
altmodel.p + fittednullmodel.l + 1, q)
end
end
if snponly
println(io, "$(rec_chr[1])\t$(rec_pos[1])\t$(rec_ids[1][1])\t",
Expand Down Expand Up @@ -1948,23 +1962,28 @@ function trajgwas(
copyto!(γ̂β, 1, altmodel.β, fittednullmodel.p + 1, q)
copyto!(stderrβ, 1, ctable.cols[2], fittednullmodel.p + 1, q)
copyto!(pvalsβ, 1, ctable.cols[4], fittednullmodel.p + 1, q)
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[2], altmodel.p + fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4], altmodel.p + fittednullmodel.l + 1, q)
end
catch e
try
WiSER.fit!(altmodel, init=init(altmodel), solver, parallel = parallel, runs = runs; throw_on_failure=true)
ctable = coeftable(altmodel)
copyto!(γ̂β, 1, altmodel.β, fittednullmodel.p + 1, q)
copyto!(stderrβ, 1, ctable.cols[2], fittednullmodel.p + 1, q)
copyto!(pvalsβ, 1, ctable.cols[4], fittednullmodel.p + 1, q)
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[2], altmodel.p + fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4], altmodel.p + fittednullmodel.l + 1, q)
end
catch e
@warn "Test failed for $(variant.rsid). The SNP may be too rare. Effect size NaN and p-value -1 will be printed."
success = false
end
end
if !disable_wsvar
copyto!(γ̂τ, 1, altmodel.τ, fittednullmodel.l + 1, q)
copyto!(stderrτ, 1, ctable.cols[2], altmodel.p + fittednullmodel.l + 1, q)
copyto!(pvalsτ, 1, ctable.cols[4], altmodel.p + fittednullmodel.l + 1, q)
end
end
if snponly
println(io, "$(variant.chrom)\t$(variant.pos)\t$(variant.rsid)\t",
Expand Down

0 comments on commit 241bed0

Please sign in to comment.