Skip to content

Commit

Permalink
Some more bug fixes in statistical tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn committed Aug 15, 2023
1 parent eed5ae3 commit bc8a1e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions WORC/featureprocessing/StatisticalTestFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def StatisticalTestFeatures(features, patientinfo, config, output_csv=None,
if type(output_tex) is list:
output_tex = ''.join(output_tex)

print(output_png, output_tex)
# Create output folder if required
if not os.path.exists(os.path.dirname(output_csv)):
os.makedirs(os.path.dirname(output_csv))
Expand Down Expand Up @@ -153,7 +152,12 @@ def StatisticalTestFeatures(features, patientinfo, config, output_csv=None,
pvalueswelch.append(ttest_ind(class1, class2, equal_var=False)[1])
pvalueswil.append(ranksums(class1, class2)[1])
try:
pvaluesmw.append(mannwhitneyu(class1, class2)[1])
pmwu = mannwhitneyu(class1, class2)[1]
if pmwu == 0.0:
print("[WORC Warning] Mann-Whtiney U test resulted in a p-value of exactly 0.0, which is not valid. Replacing metric value by NaN.")
pvaluesmw.append(np.nan)
else:
pvaluesmw.append(pmwu)
except ValueError as e:
print("[WORC Warning] " + str(e) + '. Replacing metric value by NaN.')
pvaluesmw.append(np.nan)
Expand Down
8 changes: 7 additions & 1 deletion WORC/plotting/plot_pvalues_features.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright 2016-2020 Biomedical Imaging Group Rotterdam, Departments of
# Copyright 2016-2023 Biomedical Imaging Group Rotterdam, Departments of
# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -115,6 +115,12 @@ def manhattan_importance(values, labels, feature_labels,
(1, y_value_annotated),
xytext=(1, y_value_annotated*0.95), size=8, color='magenta')

if 0.05 > 10**-yminlim:
plt.hlines(0.05, 0, max(positions), linestyles='dashed', linewidth=1, color='magenta')
plt.annotate('p=0.05',
(1, 0.05),
xytext=(1, 0.05*0.95), size=8, color='magenta')

plt.xlabel("Feature groups", size=12)
plt.ylabel("P-value Mann-Whitney U", size=12)

Expand Down

0 comments on commit bc8a1e9

Please sign in to comment.