-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nan_policy='omit' does not work in paired tests (t-test, Wilcoxon) while using Annotator.plot_and_annotate_facets #124
Comments
Hi! edit: this was incorrect, the way it was used in the original post is correct. There may be a bug |
Thanks Trevis for quick reply! I tried your suggestion however I am running into another error - here is the code: data=df_freq
TypeError: ttest_rel() got an unexpected keyword argument 'stats_params' Could it be third party package version differences - scipy for example? |
I'm sorry, please dismiss my previous comment that wasn't helpful at all. |
No problem - here is the complete trace from the last error: TypeError Traceback (most recent call last) File ~/work/software/homebrew/lib/python3.10/site-packages/seaborn/axisgrid.py:819, in FacetGrid.map_dataframe(self, func, *args, **kwargs) File ~/work/software/homebrew/lib/python3.10/site-packages/seaborn/axisgrid.py:848, in FacetGrid._facet_plot(self, func, ax, plot_args, plot_kwargs) File ~/work/software/homebrew/lib/python3.10/site-packages/statannotations/Annotator.py:848, in Annotator.plot_and_annotate_facets(self, plot, plot_params, configuration, annotation_func, annotation_params, ax_op_before, ax_op_after, annotate_params, *args, **kwargs) File ~/work/software/homebrew/lib/python3.10/site-packages/statannotations/Annotator.py:320, in Annotator.apply_test(self, num_comparisons, **stats_params) File ~/work/software/homebrew/lib/python3.10/site-packages/statannotations/Annotator.py:477, in Annotator._get_results(self, num_comparisons, pvalues, **stats_params) File ~/work/software/homebrew/lib/python3.10/site-packages/statannotations/Annotator.py:615, in Annotator._get_stat_result_from_test(self, group_struct1, group_struct2, num_comparisons, **stats_params) File ~/work/software/homebrew/lib/python3.10/site-packages/statannotations/stats/test.py:74, in apply_test(group_data1, group_data2, test, comparisons_correction, num_comparisons, alpha, **stats_params) File ~/work/software/homebrew/lib/python3.10/site-packages/statannotations/stats/StatTest.py:77, in StatTest.call(self, group_data1, group_data2, alpha, **stat_params) File ~/work/software/homebrew/lib/python3.10/site-packages/scipy/stats/_axis_nan_policy.py:502, in _axis_nan_policy_factory..axis_nan_policy_decorator..axis_nan_policy_wrapper(failed resolving arguments) TypeError: ttest_rel() got an unexpected keyword argument 'stats_params' |
Hello Vladirmir, |
HI, I have scipy the latest stable version: 1.10.1. the statannotations package is version: 0.5.0. Interestingly the suggestion you gave me to try outside FacetGrid worked: annotator = Annotator(g, pairs, **hue_plot_params) These two lines of code didn't give any errors. Could it be that within FacetGrid I have to apply different syntax to pass nan_policy parameter? |
Stumbled over the error while dealing with Nan values in paired tests. The code:
data=df_freq
correction='BH'
tests=['t-test_paired','Wilcoxon']
pal = sns.color_palette(['black'], len(data[hue_var].unique()))
pairs = [('C1D1','C2D1'),('C1D1','C4D1'),('C1D1','Progression')]
for test in tests:
kwargs = {
'plot_params': { 'x': x_var,'y': y_var,'order':order_vars },
'annotation_func': 'apply_test',
'annotation_params' : {'nan_policy':'omit'},
'configuration': {'test': test,'comparisons_correction':correction,'verbose':False},
'plot': 'boxplot'
}
gives ValueError: unequal length arrays
df_freq is dataframe with 10200 rows, gives 34 facets, each item in pairs has 75 observations (34 x 75 x 4 = 10200). Running the same dataframe on original scipy.wilcoxon or scipy.t-test_paired with nan_policy='omit' gives correct results.
Is it a bug or I need to set parameters differently?
Thank you,
Vladimir
The text was updated successfully, but these errors were encountered: