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

Bug when using keys to compute lineages #17

Closed
Marius1311 opened this issue Mar 18, 2020 · 2 comments · Fixed by #18
Closed

Bug when using keys to compute lineages #17

Marius1311 opened this issue Mar 18, 2020 · 2 comments · Fixed by #18
Assignees
Labels
bug Something isn't working

Comments

@Marius1311
Copy link
Collaborator

When I call mc_fwd.compute_lin_probs(keys=['Ductal', 'Alpha, Beta']), I get the traceback

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-33-4d1908c3199d> in <module>
----> 1 mc_fwd.compute_lin_probs(keys=['Ductal', 'Alpha, Beta'])
      2 mc_fwd.plot_lin_probs()

~/Projects/cellrank/cellrank/tools/_markov_chain.py in compute_lin_probs(self, keys, check_irred, norm_by_frequ)
    814         else:
    815             logg.debug(f"DEBUG: Combining recurrent classes according to `{keys}`")
--> 816             approx_rcs_ = self._prep_rc_classes(keys)
    817         keys = list(approx_rcs_.cat.categories)
    818 

~/Projects/cellrank/cellrank/tools/_markov_chain.py in _prep_rc_classes(self, keys)
   1259 
   1260         lin_colors = list(np.array(lin_colors)[cat_mask])
-> 1261         approx_rcs_temp.cat.reorder_categories(remaining_cat, inplace=True)
   1262         self._lin_probs = Lineage(
   1263             np.empty((1, len(lin_colors))),

~/miniconda3/envs/cellrank/lib/python3.6/site-packages/pandas/core/accessor.py in f(self, *args, **kwargs)
     91         def _create_delegator_method(name):
     92             def f(self, *args, **kwargs):
---> 93                 return self._delegate_method(name, *args, **kwargs)
     94 
     95             f.__name__ = name

~/miniconda3/envs/cellrank/lib/python3.6/site-packages/pandas/core/arrays/categorical.py in _delegate_method(self, name, *args, **kwargs)
   2623 
   2624         method = getattr(self._parent, name)
-> 2625         res = method(*args, **kwargs)
   2626         if res is not None:
   2627             return Series(res, index=self._index, name=self._name)

~/miniconda3/envs/cellrank/lib/python3.6/site-packages/pandas/core/arrays/categorical.py in reorder_categories(self, new_categories, ordered, inplace)
   1032         if set(self.dtype.categories) != set(new_categories):
   1033             raise ValueError(
-> 1034                 "items in new_categories are not the same as in " "old categories"
   1035             )
   1036         return self.set_categories(new_categories, ordered=ordered, inplace=inplace)

ValueError: items in new_categories are not the same as in old categories

> /Users/marius/miniconda3/envs/cellrank/lib/python3.6/site-packages/pandas/core/arrays/categorical.py(1034)reorder_categories()
   1032         if set(self.dtype.categories) != set(new_categories):
   1033             raise ValueError(
-> 1034                 "items in new_categories are not the same as in " "old categories"
   1035             )
   1036         return self.set_categories(new_categories, ordered=ordered, inplace=inplace)

If you fix this, please make sure that lineages still get assigned to the right color by simply running our tutorial.

@Marius1311 Marius1311 added the bug Something isn't working label Mar 18, 2020
@Marius1311
Copy link
Collaborator Author

The problem has something to do with the combination of endpoints - if I just call mc_fwd.compute_lin_probs(keys=['Ductal', 'Alpha', 'Beta']) (meaning that I excluded the epsilon endpoint), everything works.

@Marius1311
Copy link
Collaborator Author

This function is really a bit tricky - if you don't know how to fix it, we can discuss that later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants