trevismd / statannotations

add statistical significance annotations on seaborn plots. Further development of statannot, with bugfixes, new features, and a different API.
Other
655 stars 73 forks source link

Get results as pandas dataframe? #128

Open JohannesWiesner opened 1 year ago

JohannesWiesner commented 1 year ago

After running apply_and_annotate it would come in handy, if one could obtain the results as a pandas dataframe (like in pingouin). Right now I do this manually by doing something like (not a MRE, just to give you an intution!):

_, results = annotator.apply_and_annotate()

# extract results as data frame
results_pretty = []

for result in results:
    group_1 = result.data.group1
    group_2 = result.data.group2
    stat_value = result.data.stat_value
    pvalue = result.data.pvalue
    receptor = group_1[0]
    sig = result.text
    results_pretty.append((receptor,stat_value,pvalue,sig))

results_pretty = pd.DataFrame(results_pretty,columns=['receptor','U','p','sig'])