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

Annotator does not work if any of the groups has only NaN values #111

Open
kokyriakidis opened this issue Feb 13, 2023 · 2 comments
Open

Comments

@kokyriakidis
Copy link

kokyriakidis commented Feb 13, 2023

Hey @trevismd

Right now Annotator does not work if any of the groups have only NaN values. Is there a way to perform a test between the other groups and ignore the group that has only NaN values?

In order to make it work I added zero values to the group that has only NaN values. I made it look like this:
image

Otherwise I get the following error when I try yo run the Annotator:

>>> Annotator(ax, pairs, data=df[['CONTROL_Edited', 'CONTROL_Not_Edited', 'AD_Edited', 'AD_Not_Edited']], order=order)
/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/seaborn/categorical.py:82: FutureWarning: iteritems is deprecated and will be removed in a future version. Use .items instead.
  plot_data = [np.asarray(s, float) for k, s in iter_data]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/statannotations/Annotator.py", line 106, in __init__
    self._plotter = self._get_plotter(engine, ax, pairs, plot, data,
  File "/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/statannotations/Annotator.py", line 778, in _get_plotter
    return engine_plotter(*args, **kwargs)
  File "/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/statannotations/_Plotter.py", line 94, in __init__
    self.value_maxes = self._generate_value_maxes()
  File "/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/statannotations/_Plotter.py", line 215, in _generate_value_maxes
    group_name, value_pos = self._get_value_pos(child, data_to_ax)
  File "/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/statannotations/_Plotter.py", line 316, in _get_value_pos
    return self._get_value_pos_for_path_collection(
  File "/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/statannotations/_Plotter.py", line 332, in _get_value_pos_for_path_collection
    group_pos = float(np.round(np.nanmean(
  File "<__array_function__ internals>", line 180, in nanmean
  File "/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/numpy/lib/nanfunctions.py", line 1048, in nanmean
    avg = _divide_by_count(tot, cnt, out=out)
  File "/media/kokyriakidis/RED/BCBIO/anaconda/envs/postprocessSPRINT/lib/python3.8/site-packages/numpy/lib/nanfunctions.py", line 215, in _divide_by_count
    return np.divide(a, b, out=a, casting='unsafe')
ValueError: output array is read-only

Can I somehow have the CONTROL_Edited category be empty (have only NaN values) and make Annotator work?

@trevismd
Copy link
Owner

Hello,
Can't you remove "CONTROL_Edited" from your pairs?

@kokyriakidis
Copy link
Author

I prefer to leave it on the graph and be empty. (I want someone to see that it is empty)

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

2 participants