Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Display asterisk next to P-Value when it is below a defined threshold #150

Merged
merged 2 commits into from May 10, 2023

Conversation

tompollard
Copy link
Owner

@tompollard tompollard commented Apr 24, 2023

In #138, @davidkurland asks whether we could highlight P-Values that fall below a threshold.

This pull request adds a pval_threshold argument. When set (e.g. pval_threshold = 0.01), we display an asterisk (*) after all p-values that fall below this threshold.

e.g.

from tableone import TableOne, load_dataset

data = load_dataset('pn2012')

table1 = TableOne(data, groupby="death", pval=True, pval_threshold=0.2)
print(table1.tabulate(tablefmt = "github"))

Displays:

Missing Overall 0 1 P-Value
n 1000 864 136
Age, mean (SD) 0 65.0 (17.2) 64.0 (17.4) 71.7 (14.0) <0.001*
SysABP, mean (SD) 291 114.3 (40.2) 115.4 (38.3) 107.6 (49.4) 0.134*
Height, mean (SD) 475 170.1 (22.1) 170.3 (23.2) 168.5 (11.3) 0.304
Weight, mean (SD) 302 82.9 (23.8) 83.0 (23.6) 82.3 (25.4) 0.782
ICU, n (%) CCU 0 162 (16.2) 137 (15.9) 25 (18.4) <0.001*
CSRU 202 (20.2) 194 (22.5) 8 (5.9)
MICU 380 (38.0) 318 (36.8) 62 (45.6)
SICU 256 (25.6) 215 (24.9) 41 (30.1)
MechVent, n (%) 0 0 540 (54.0) 468 (54.2) 72 (52.9) 0.862
1 460 (46.0) 396 (45.8) 64 (47.1)
LOS, mean (SD) 0 14.2 (14.2) 14.0 (13.5) 15.4 (17.7) 0.386

@tompollard tompollard requested a review from jraffa April 24, 2023 20:35
@tompollard
Copy link
Owner Author

@davidkurland @jraffa please could you take a look at this and let me know if any changes are needed?

@tompollard
Copy link
Owner Author

@jraffa is happy with the approach, but reminded me to double check that this works for adjusted values too.

@tompollard
Copy link
Owner Author

Looks okay to me:

from tableone import TableOne, load_dataset

data = load_dataset('pn2012')
table1 = TableOne(data, groupby="death", pval=True, pval_adjust="bonferroni",
                  pval_threshold=0.99)
print(table1.tabulate(tablefmt = "github"))
Missing Overall 0 1 P-Value (adjusted)
n 1000 864 136
Age, mean (SD) 0 65.0 (17.2) 64.0 (17.4) 71.7 (14.0) <0.001*
SysABP, mean (SD) 291 114.3 (40.2) 115.4 (38.3) 107.6 (49.4) 0.936*
Height, mean (SD) 475 170.1 (22.1) 170.3 (23.2) 168.5 (11.3) 1.000
Weight, mean (SD) 302 82.9 (23.8) 83.0 (23.6) 82.3 (25.4) 1.000
ICU, n (%) CCU 0 162 (16.2) 137 (15.9) 25 (18.4) 0.001*
CSRU 202 (20.2) 194 (22.5) 8 (5.9)
MICU 380 (38.0) 318 (36.8) 62 (45.6)
SICU 256 (25.6) 215 (24.9) 41 (30.1)
MechVent, n (%) 0 0 540 (54.0) 468 (54.2) 72 (52.9) 1.000
1 460 (46.0) 396 (45.8) 64 (47.1)
LOS, mean (SD) 0 14.2 (14.2) 14.0 (13.5) 15.4 (17.7) 1.000

@tompollard tompollard merged commit 0b46fa1 into main May 10, 2023
2 checks passed
@tompollard tompollard deleted the tp/pval_threshold branch May 10, 2023 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant