Skip to content

Commit 5ab6b9f

Browse files
committed
address Olivier's comments
1 parent 44eb4b5 commit 5ab6b9f

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/outputs.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ function qqplot(output, results)
2828
for pvalue_col pvalue_cols
2929
pvalues = -log10.(filter(x -> !isnan(x), results[!, pvalue_col]))
3030
n = length(pvalues)
31-
# If only 1 non-NA p-value, exit function
32-
if n <= 1
33-
return
34-
end
31+
# If <= 1 non-NA p-value, qqplot! throws error
32+
n > 1 || continue
3533
unif_quantiles = log10_uniform_quantiles(n)
3634
qqplot!(ax, unif_quantiles, pvalues, qqline=:identity, label=replace(string(pvalue_col), "_PVALUE" => ""))
3735
end
@@ -40,7 +38,7 @@ function qqplot(output, results)
4038
unif_quantiles = log10_uniform_quantiles(n)
4139
ub = log10_beta_quantiles(n, 0.025)
4240
lb = log10_beta_quantiles(n, 0.975)
43-
band!(ax, unif_quantiles, lb, ub, color=(:grey, 0.6))
41+
band!(ax, unif_quantiles, lb, ub, color=(:grey, 0.6), label = "Uncertainty") # label required for axislegend() to run on empty plot
4442
# Legend
4543
axislegend(position=:lt)
4644
# Save figure

test/outputs.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ include(joinpath(TESTDIR, "testutils.jl"))
8484
@test tmle["PVALUE"] === NaN
8585
@test tmle["EFFECT_SIZE"] == "Failed"
8686

87-
# Check subsetted results & optional QQplot generation
87+
# When <= 1 NA p-value present in results, check that empty QQ plot can be generated and qqplot!() does not throw error
8888
sub_results = results[1:1, :]
89-
TargeneCore.qqplot(TargeneCore.make_filepath_from_prefix(tmpdir; filename = "Non_existent_QQ.png"), sub_results)
90-
@test !isfile(joinpath(tmpdir, "Non_existent_QQ.png"))
89+
TargeneCore.qqplot(TargeneCore.make_filepath_from_prefix(tmpdir; filename = "Empty_QQ.png"), sub_results)
90+
@test isfile(joinpath(tmpdir, "Empty_QQ.png"))
9191
end
9292

9393
end

0 commit comments

Comments
 (0)