scverse / scvi-tutorials

Notebooks used in scvi-tools tutorials
https://docs.scvi-tools.org/en/stable/tutorials/index.html
BSD 3-Clause "New" or "Revised" License
46 stars 25 forks source link

logic issue with tangram_scvi_tools tutorial #358

Closed ori-kron-wis closed 1 month ago

ori-kron-wis commented 1 month ago

spatial/tangram_scvi_tools.ipynb is not running to some logic issue with mudata:

---------------------------------------------------------------------------
InvalidIndexError                         Traceback (most recent call last)
Cell In[12], line 8
      6 mdata.mod["sp_train"] = mdata.mod["sp"][:, genes].copy()
      7 mdata.mod["sc_train"] = mdata.mod["sc"][:, genes].copy()
----> 8 mdata.update()

File /usr/local/lib/python3.12/site-packages/mudata/_core/mudata.py:1725, in MuData.update(self)
   1719 def update(self):
   1720     """
   1721     Update both .obs and .var indices of MuData with the data from all the modalities
   1722 
   1723     NOTE: From v0.4, it will not pull columns from modalities by default.
   1724     """
-> 1725     self.update_var()
   1726     self.update_obs()

File /usr/local/lib/python3.12/site-packages/mudata/_core/mudata.py:1531, in MuData.update_var(self)
   1527 """
   1528 Update global .var_names according to the .var_names of all the modalities.
   1529 """
   1530 join_common = self.axis == 0
-> 1531 self._update_attr("var",axis=0,join_common=join_common)

File /usr/local/lib/python3.12/site-packages/mudata/_core/mudata.py:579, in MuData._update_attr(self, attr, axis, **kwargs)
    577     if "join_common" in kwargs:
    578         join_common = kwargs.pop("join_common")
--> 579     self._update_attr_legacy(attr,axis,join_common,**kwargs)
    580     return
    582 prev_index = getattr(self, attr).index

File /usr/local/lib/python3.12/site-packages/mudata/_core/mudata.py:1273, in MuData._update_attr_legacy(self, attr, axis, join_common, **kwargs)
   1270     prev_index = pd.Index(prev_values)
   1271     now_index = pd.Index(now_values)
-> 1273 index_order = prev_index.get_indexer(now_index)
   1275 for mx_key, mx in attrm.items():
   12[76](https://github.com/scverse/scvi-tutorials/actions/runs/10981118176/job/30487753331#step:5:77)     if mx_key not in self.mod.keys():  # not a modality name

File /usr/local/lib/python3.12/site-packages/pandas/core/indexes/base.py:3885, in Index.get_indexer(self, target, method, limit, tolerance)
   38[82](https://github.com/scverse/scvi-tutorials/actions/runs/10981118176/job/30487753331#step:5:83) self._check_indexing_method(method, limit, tolerance)
   3884 if not self._index_as_unique:
-> 3885     raise InvalidIndexError(self._requires_unique_msg)
   3887 if len(target) == 0:
   3888     return np.array([], dtype=np.intp)

InvalidIndexError: Reindexing only valid with uniquely valued Index objects

Versions:

1.2