tableone icon indicating copy to clipboard operation
tableone copied to clipboard

Highlighting when pval below threshold

Open davidkurland opened this issue 1 year ago • 3 comments

Is there are way to call out or highlight a cell when p<0.05?

davidkurland avatar Jan 17 '23 20:01 davidkurland

@davidkurland Not currently, as far as I'm aware, I'm sorry. We could potentially add it, so I'll keep this issue open.

tompollard avatar Jan 19 '23 20:01 tompollard

@jraffa @davidkurland how about adding a new pval_threshold argument. If the p-value is less than or equal to the threshold, we display a * after the value?

tompollard avatar Apr 24 '23 19:04 tompollard

I have added a draft implementation on the https://github.com/tompollard/tableone/tree/tp/pval_threshold branch, if you'd like to give it a try.

Clone the repo, switch to the pval_threshold branch (git switch pval_threshold), then pip install . within the folder to install.

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"))
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

@jraffa @davidkurland Please let me know your thoughts!

tompollard avatar Apr 24 '23 20:04 tompollard