Skip to content

Commit 94b1d37

Browse files
committed
add prc and auroc to metrics plots
1 parent 56b18f9 commit 94b1d37

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

analysis/workflow/scripts/midway_manhattan_summary.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def main(
303303

304304
# if this is a pval, take the -log10 of it
305305
if not bic:
306-
tsfm_pval = lambda pval: -np.log10(pval)
306+
tsfm_pval = lambda pval: -np.log10(pval) if pval != 0 else np.inf
307307
else:
308308
tsfm_pval = lambda val: val
309309

@@ -422,7 +422,7 @@ def main(
422422
log.debug(f"Found {vals.shape[0]} points")
423423

424424
# remove any vals that were NA (but got converted to 0)
425-
# and also any vals that were greater than max-val
425+
# and also any vals that were greater than max-val (which defaults to inf)
426426
na_rows = (vals == 0).any(axis=1) | (vals >= max_val).any(axis=1)
427427
not_na_rows_idxs = {k: v[~na_rows] for k,v in axes_idxs.items()}
428428
if color is not None:
@@ -551,10 +551,11 @@ def main(
551551
ax.set_xlabel(case_type + ": " + ax_labs[1])
552552
ax.set_ylabel(case_type + ": " + ax_labs[0])
553553
ax.axline((0,0), (max_val, max_val), linestyle="--", color="orange")
554-
ax.axline((0,thresh), (thresh, thresh), color="red")
555-
ax_histx.axline((thresh,0), (thresh, thresh), color="red")
556-
ax.axline((thresh,0), (thresh, thresh), color="red")
557-
ax_histy.axline((0,thresh), (thresh, thresh), color="red")
554+
if thresh != 0:
555+
ax.axline((0,thresh), (thresh, thresh), color="red")
556+
ax_histx.axline((thresh,0), (thresh, thresh), color="red")
557+
ax.axline((thresh,0), (thresh, thresh), color="red")
558+
ax_histy.axline((0,thresh), (thresh, thresh), color="red")
558559
ax_histy.spines['top'].set_visible(False)
559560
ax_histx.spines['top'].set_visible(False)
560561
ax_histy.spines['right'].set_visible(False)

analysis/workflow/scripts/midway_summary_metrics.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def main(
111111

112112
log.info("Creating plots")
113113
fig, axs = plt.subplots(
114-
nrows=1, ncols=3,
115-
sharex=True, figsize=(7, 3),
114+
nrows=1, ncols=5,
115+
sharex=True, figsize=((7/3)*5, 3),
116116
constrained_layout=True, tight_layout=False,
117117
)
118118

@@ -123,14 +123,31 @@ def main(
123123
metrics_beta = metrics[params["beta"] == beta]
124124

125125
axs[0].plot(params_beta["sampsize"], metrics_beta["FPR"], "o", label=beta)
126+
axs[0].set_ylim((-0.001, 0.051))
126127
axs[0].set_ylabel("False positive rate")
127128

128129
axs[1].plot(params_beta["sampsize"], metrics_beta["Recall"], "o")
130+
axs[1].set_ylim((-0.001, 1.001))
129131
axs[1].set_ylabel("Recall")
130132

131133
axs[2].plot(params_beta["sampsize"], metrics_beta["Significance Threshold"], "o")
134+
max_alpha = max(metrics_beta["Significance Threshold"])
135+
if max_alpha > 1:
136+
axs[2].set_ylim((-2.001, 10.001))
137+
elif max_alpha < 0.25:
138+
axs[2].set_ylim((-0.001, 0.251))
139+
else:
140+
axs[2].set_ylim((-0.001, 1.001))
132141
axs[2].set_ylabel("Significance threshold")
133142

143+
axs[3].plot(params_beta["sampsize"], metrics_beta["AUROC"], "o")
144+
axs[3].set_ylim((0.495, 1.001))
145+
axs[3].set_ylabel("AUROC")
146+
147+
axs[4].plot(params_beta["sampsize"], metrics_beta["Average Precision"], "o")
148+
axs[4].set_ylim((0.495, 1.001))
149+
axs[4].set_ylabel("Average Precision")
150+
134151
log.info("Writing figure")
135152
fig.supxlabel("Sample size")
136153
fig.legend(loc="lower right", ncol=len(betas), fontsize="small")

0 commit comments

Comments
 (0)