Skip to content

Commit 15d842e

Browse files
authored
Merge pull request #200 from TARGENE/qqplot_bug
2 parents 74a4239 + 5ab6b9f commit 15d842e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/outputs.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +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 <= 1 non-NA p-value, qqplot! throws error
32+
n > 1 || continue
3133
unif_quantiles = log10_uniform_quantiles(n)
3234
qqplot!(ax, unif_quantiles, pvalues, qqline=:identity, label=replace(string(pvalue_col), "_PVALUE" => ""))
3335
end
@@ -36,7 +38,7 @@ function qqplot(output, results)
3638
unif_quantiles = log10_uniform_quantiles(n)
3739
ub = log10_beta_quantiles(n, 0.025)
3840
lb = log10_beta_quantiles(n, 0.975)
39-
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
4042
# Legend
4143
axislegend(position=:lt)
4244
# Save figure

test/outputs.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ include(joinpath(TESTDIR, "testutils.jl"))
8383
tmle = failed_estimate["TMLE"]
8484
@test tmle["PVALUE"] === NaN
8585
@test tmle["EFFECT_SIZE"] == "Failed"
86+
87+
# When <= 1 NA p-value present in results, check that empty QQ plot can be generated and qqplot!() does not throw error
88+
sub_results = results[1:1, :]
89+
TargeneCore.qqplot(TargeneCore.make_filepath_from_prefix(tmpdir; filename = "Empty_QQ.png"), sub_results)
90+
@test isfile(joinpath(tmpdir, "Empty_QQ.png"))
8691
end
8792

8893
end

0 commit comments

Comments
 (0)