Skip to content
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

pvalue_format Parameter error in Annotator.config call #169

Open
mtvector opened this issue Feb 15, 2025 · 0 comments
Open

pvalue_format Parameter error in Annotator.config call #169

mtvector opened this issue Feb 15, 2025 · 0 comments

Comments

@mtvector
Copy link

When I'm running something like this where I'm trying to set the pvalue levels like in the docs:

annot = Annotator(ax, pairs, data=df, x='variable', y='value', 
                  hue='syntenic', order=order, hue_order=hue_order)
annot.configure(test='Mann-Whitney',text_format='star', loc='inside',pvalue_format=[[1e-20, "****"], [1e-10, "***"], [1e-5, "**"], [1e-1, "*"], [1, "ns"]],
                comparisons_correction='bonferroni', verbose=2)

I get the following error which suggests that pvalue_format is supposed to be a dictionary or perhaps that it's not registering correctly with the other params.

AttributeError                            Traceback (most recent call last)
Cell In[126], line 29
     26 # Create the Annotator using the same parameters as in your working example.
     27 annot = Annotator(ax, pairs, data=df, x='variable', y='value', 
     28                   hue='syntenic', order=order, hue_order=hue_order)
---> 29 annot.configure(test='Mann-Whitney',text_format='star', loc='inside',pvalue_format=[[1e-20, "****"], [1e-10, "***"], [1e-5, "**"], [1e-1, "*"], [1, "ns"]],
     30                 comparisons_correction='bonferroni', verbose=2)
     31 annot.apply_test()
     32 annot.annotate()

File [~/Matthew/utils/miniforge3/envs/rapids-24.12/lib/python3.12/site-packages/statannotations/Annotator.py:303](https://aidc-ood-prd.corp.alleninstitute.org/node/n258/39937/lab/workspaces/auto-n/tree/Matthew/code/triple-dev-wb/analysis/Matthew/utils/miniforge3/envs/rapids-24.12/lib/python3.12/site-packages/statannotations/Annotator.py#line=302), in Annotator.configure(self, **parameters)
    296     parameters["pvalue_format"] = {
    297         item: value
    298         for item, value in parameters.items()
    299         if item in PVALUE_CONFIGURABLE_PARAMETERS
    300     }
    302 unmatched_parameters = parameters.keys() - set(CONFIGURABLE_PARAMETERS)
--> 303 unmatched_parameters -= parameters["pvalue_format"].keys()
    305 if unmatched_parameters:
    306     raise InvalidParametersError(unmatched_parameters)

AttributeError: 'list' object has no attribute 'keys'

I tried a few different format inputs and hacking with the code a little and couldn't figure it out. Thanks for making this package, it's a lifesaver!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant