I am a biochemist and my results are too fine for my economist friends they would prefer p-value significance to be set at 10% or alpha= 0.1 instead of the standard 5% (0.05). I used Statannotations the latest v0.5. Here I have an example of what happens as a default:
import matplotlib.pyplot as plt
import seaborn as sns
from statannotations.Annotator import Annotator
from statannotations import format_annotations
df = sns.load_dataset('diamonds')
df = df[df['color'].map(lambda c: c in 'EIJ')]
x = "clarity"
y = "carat"
hue = "color"
hue_order=["E", "I", "J"]
pairs = [(("SI2", "E"), ("SI1", "E"))]
pairs = pairs + [((clar, 'I'), (clar, 'J')) for clar in df['clarity'].unique()]
width = 0.4
grph = sns.catplot(kind='bar',data=df, x=x, y=y, hue=hue, hue_order=hue_order)
for ax in grph.axes.ravel():
annot= Annotator(ax, pairs, data=df, x=x, y=y, hue=hue, hue_order=hue_order)
annot.configure(test='Kruskal',
comparisons_correction= None,
correction_format='replace',
text_format='star',
line_offset=15, line_height=0.05, text_offset=1)
annot.apply_test().annotate()
plt.legend(loc='upper left', bbox_to_anchor=(1.03, 1), title=hue)
plt.savefig('example_barplot_hue.png', dpi=300, bbox_inches='tight')
I want to change the alpha, which you can specify in annot.configure
to alpha=0.1, this however throws an error telling you to change the pvalue_thresholds
which makes sense.
I want the thresholds to be the following, which would correspond to my new alpha:
econ_pvalues= [[1e-3, "****"],
[1e-2, "***"],
[0.05, "**"],
[0.1, "*"],
[1, "ns"]]
Such that the tests are run and alternative pvalue significance levels are annotated on the graph ie: * becomes **, ** becomes *** depending on the pvalues.
I figured out how to access and change them using format_annotations.pval_annotation_text
... but it makes no sense because I can only access the statstest results after I have annotated the graph and cant for the life of me find where or what more to do.
annot.configure(alpha= 0.1
test='Kruskal',
comparisons_correction= None,
correction_format='replace',
text_format='star',
line_offset=15, line_height=0.05, text_offset=1)
annot.apply_test()
ax, test_result= annot.annotate() #where you can access the StatResult
print(test_result,'\n')
statresults = []
for t in test_result:
statresults.append(t.data)
econp=format_annotations.pval_annotation_text(statresults, pvalue_thresholds=econ_pvalues)
print(econp)
Any help would be amazing I hope this is a comprehensive example (first time poster, python newbie)