LSYS/forestplot

Add option to show P-values in scientific notation

Closed this issue · 4 comments

naity2 commented

Hi @LSYS,

Thank you for this wonderful package!

I was wondering if it is possible to show P-values in scientific notation as very small P-values are displayed as 0.

Thank you!

def format_pval(pval, threshold=0.001):
if pval < threshold:
return f"{pval:.2e}"
else:
return f"{pval:.2f}"

Format the p-values in the data dataframe

data['Formattedp.value'] = [format_pval(pval, threshold=0.01) for pval in data['p.value']]

Adding this to my code before invoking forest plot script worked for me. i.e (made any value less than 0.01 to scientific notation).

LSYS commented

@naity2 Unfortunately, that function is not included within the package. But you always have the option of processing your p-values (or any other) yourself (e.g., #78 (comment) by @ksarathbabu) before including it as a column using annote.

If I get to doing an FAQ for the package, I might show how to do that.

This issue is stale because it has been open for 30 days with no activity.

This issue was closed because it has been inactive.