cellrank icon indicating copy to clipboard operation
cellrank copied to clipboard

Invalid lineage name XYZ. Valid names are `[np.str_('4'), np.str_('0_1'), np.str_('0_2')]`.

Open Zethson opened this issue 8 months ago • 0 comments

I had disabled the ehrapy cellrank CI job for a while as it was broken and I wanted to wait for a proper release and not with development versions. Today, I tried enabling the job again and I see that my test notebook fails with:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[21], line 1
----> 1 drivers_1_1 = g.compute_lineage_drivers(lineages="1_1")
      2 adata.obs["fate_probs_1_1"] = g.fate_probabilities["1_1"].X.flatten()
      4 ep.pl.umap(
      5     adata,
      6     color=["fate_probs_1_1"] + list(drivers_1_1.index[:8]),
   (...)
     10     vmax="p96",
     11 )

File ~/miniconda3/envs/ehrapy/lib/python3.11/site-packages/cellrank/estimators/mixins/_lineage_drivers.py:134, in LinDriversMixin.compute_lineage_drivers(self, lineages, method, cluster_key, clusters, layer, use_raw, confidence_level, n_perms, seed, **kwargs)
    132     lineages = [lineages]
    133 if lineages is not None:
--> 134     _ = fate_probs[lineages]
    135 else:
    136     lineages = fate_probs.names

File ~/miniconda3/envs/ehrapy/lib/python3.11/site-packages/cellrank/_utils/_lineage.py:300, in Lineage.__getitem__(self, item)
    297     if isinstance(item, tuple):
    298         item = item[::-1]
--> 300 obj = self.__getitem(item)
    302 return obj.T if was_transposed else obj

File ~/miniconda3/envs/ehrapy/lib/python3.11/site-packages/cellrank/_utils/_lineage.py:383, in Lineage.__getitem(self, item)
    381             return self._mix_lineages(slice(None, None, None), item)
    382         if any(isinstance(i, str) for i in item):
--> 383             item = (slice(None, None, None), self._maybe_convert_names(item))
    384             col = item[1]
    386 shape, row_order, col_order = None, None, None

File ~/miniconda3/envs/ehrapy/lib/python3.11/site-packages/cellrank/_utils/_lineage.py:1028, in Lineage._maybe_convert_names(self, names, is_singleton, default, make_unique)
   1026                 name = default
   1027         else:
-> 1028             raise KeyError(f"Invalid lineage name `{name!r}`. Valid names are: `{list(self.names)}`.")
   1029     res.append(name)
   1031 if make_unique:

KeyError: "Invalid lineage name `'1_1'`. Valid names are: `[np.str_('4'), np.str_('0_1'), np.str_('0_2')]`."

Ignoring that the name doesn't match anymore (probably because of reproducibility issues that I keep hitting with cellrank), the valid names probably shouldn't include the np.str() or is that intended now?

Note that it still works when omitting the ´np.str` so it's probably just a malformed exception.

Versions:

Installed 156 packages in 283ms + anndata==0.11.4 + array-api-compat==1.11.2 + asttokens==3.0.0 + attrs==25.3.0 + autograd==1.7.0 + autograd-gamma==0.5.0 + beautifulsoup4==4.13.4 + bleach==6.2.0 + cachetools==5.5.2 + causal-learn==0.1.4.1 + cellrank==2.0.7 + certifi==2025.4.26 + charset-normalizer==3.4.1 + clarabel==0.10.0 + click==8.1.8 + comm==0.2.2 + contourpy==1.3.2 + cvxpy==1.6.5 + cycler==0.12.1 + cython==0.29.37 + db-dtypes==1.4.2 + debugpy==1.8.14 + decorator==5.2.1 + defusedxml==0.7.1 + docrep==0.3.2 + scanpy==1.11.1 + scikit-learn==1.5.2 + scikit-misc==0.5.1 + scipy==1.15.2 + scs==3.2.7.post2 + scvelo==0.3.3 + seaborn==0.13.2 + session-info2==0.1.2 + setuptools==79.0.1 + six==1.17.0 + sklearn-compat==0.1.3 + soupsieve==2.7 + stack-data==0.6.3 + statsmodels==0.14.4 + sympy==1.13.3 + tableone==0.8.0 + tabulate==0.9.0 + texttable==1.7.0 + thefuzz==0.22.1 + threadpoolctl==3.6.0 + tinycss2==1.4.0 + tornado==6.4.2 + tqdm==4.67.1 + traitlets==5.14.3 + typing-extensions==4.13.2 + tzdata==2025.2 + umap-learn==0.5.7 + urllib3==2.4.0 + wcwidth==0.2.13 + webencodings==0.5.1 + wrapt==1.17.2

Zethson avatar Apr 27 '25 01:04 Zethson