Skip to content

Commit

Permalink
Added num2sig() which converts p-value to significance (see #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbslee committed Feb 23, 2021
1 parent d05a449 commit 92d318b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions dokdo/api2/num2sig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
def num2sig(num):
"""Convert a p-avalue to a signifiacne annotation.
Significance lebels are defined as follows:
| P-value | Signifiacne |
| -------------------- | ----------- |
| 0.05 < P | ns |
| 0.01 < P <= 0.05 | * |
| 0.001 < P <= 0.01 | ** |
| 0.0001 < P <= 0.001 | *** |
| P <= 0.0001 | **** |
Parameters
----------
num : float
P-value to be converted.
Returns
-------
str
Signifiance annotation.
"""
if 0.05 < num:
sig = 'ns'
elif 0.01 < num <= 0.05:
sig = '*'
elif 0.001 < num <= 0.01:
sig = '**'
elif 0.0001 < num <= 0.001:
sig = '***'
else:
sig = '****'
return sig

0 comments on commit 92d318b

Please sign in to comment.