-
Notifications
You must be signed in to change notification settings - Fork 57
Description
I get the following error running the scanpy spatial transcriptomics tutorial with the following command:
counts = pd.DataFrame(adata.X.todense(), columns=adata.var_names, index=adata.obs_names)
coord = pd.DataFrame(adata.obsm['spatial'], columns=['x_coord', 'y_coord'], index=adata.obs_names)
results = SpatialDE.run(coord, counts)
Traceback:
ValueError Traceback (most recent call last)
File :3
File /opt/homebrew/lib/python3.11/site-packages/SpatialDE/base.py:420, in run(X, exp_tab, kernel_space)
411 ''' Perform SpatialDE test
412
413 X : matrix of spatial coordinates times observations
(...)
417 model can be specifiec using the kernel_space paramter.
418 '''
419 if kernel_space == None:
--> 420 l_min, l_max = get_l_limits(X)
421 kernel_space = {
422 'SE': np.logspace(np.log10(l_min), np.log10(l_max), 10),
423 'const': 0
424 }
426 logging.info('Performing DE test')
File /opt/homebrew/lib/python3.11/site-packages/SpatialDE/base.py:26, in get_l_limits(X)
24 def get_l_limits(X):
25 Xsq = np.sum(np.square(X), 1)
---> 26 R2 = -2. * np.dot(X, X.T) + (Xsq[:, None] + Xsq[None, :])
27 R2 = np.clip(R2, 0, np.inf)
28 R_vals = np.unique(R2.flatten())
File /opt/homebrew/lib/python3.11/site-packages/pandas/core/series.py:1072, in Series.getitem(self, key)
1069 key = np.asarray(key, dtype=bool)
1070 return self._get_rows_with_mask(key)
-> 1072 return self._get_with(key)
File /opt/homebrew/lib/python3.11/site-packages/pandas/core/series.py:1082, in Series._get_with(self, key)
1077 raise TypeError(
1078 "Indexing a Series with DataFrame is not "
1079 "supported, use the appropriate DataFrame column"
1080 )
1081 elif isinstance(key, tuple):
-> 1082 return self._get_values_tuple(key)
1084 elif not is_list_like(key):
1085 # e.g. scalars that aren't recognized by lib.is_scalar, GH#32684
1086 return self.loc[key]
File /opt/homebrew/lib/python3.11/site-packages/pandas/core/series.py:1122, in Series._get_values_tuple(self, key)
1117 if com.any_none(*key):
1118 # mpl compat if we look up e.g. ser[:, np.newaxis];
1119 # see tests.series.timeseries.test_mpl_compat_hack
1120 # the asarray is needed to avoid returning a 2D DatetimeArray
1121 result = np.asarray(self._values[key])
-> 1122 disallow_ndim_indexing(result)
1123 return result
1125 if not isinstance(self.index, MultiIndex):
File /opt/homebrew/lib/python3.11/site-packages/pandas/core/indexers/utils.py:341, in disallow_ndim_indexing(result)
333 """
334 Helper function to disallow multi-dimensional indexing on 1D Series/Index.
335
(...)
338 in GH#30588.
339 """
340 if np.ndim(result) > 1:
--> 341 raise ValueError(
342 "Multi-dimensional indexing (e.g. obj[:, None]
) is no longer "
343 "supported. Convert to a numpy array before indexing instead."
344 )
ValueError: Multi-dimensional indexing (e.g. obj[:, None]
) is no longer supported. Convert to a numpy array before indexing instead.