Extending to other statistical functions
Write your function that takes in two sets of data, and outputs a test statistic and a p-value:
import numpy as np
from scipy.stats import ttest_ind
def log_ttest(group_data1, group_data2, **stats_params):
group_data1_log = np.log(group_data1)
group_data2_log = np.log(group_data2)
return ttest_ind(group_data1_log, group_data2_log, **stats_params)
Initialize a
statannotations.stats.StatTest.StatTest
object using your function:
from statannotations.stats.StatTest import StatTest
custom_long_name = 'Log t-test'
custom_short_name = 'log-t'
custom_func = log_ttest
custom_test = StatTest(custom_func, custom_long_name, custom_short_name)
When you configure the
statannotations.Annotator.Annotator
object, you can pass yourStatTest
:
annot = Annotator(<ax>, <pairs>)
annot.configure(test=custom_test, comparisons_correction=None,
text_format='star')