it seems that this is a bug in SpatialDE
Input code:
%%time 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)
Output error:
ValueError Traceback (most recent call last)
File
File ~/my-conda-envs/HiP-CT-Visium_env/lib/python3.10/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 ~/my-conda-envs/HiP-CT-Visium_env/lib/python3.10/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 ~/my-conda-envs/HiP-CT-Visium_env/lib/python3.10/site-packages/pandas/core/series.py:1143, in Series.getitem(self, key) 1140 key = np.asarray(key, dtype=bool) 1141 return self._get_rows_with_mask(key) -> 1143 return self._get_with(key)
File ~/my-conda-envs/HiP-CT-Visium_env/lib/python3.10/site-packages/pandas/core/series.py:1153, in Series._get_with(self, key) 1148 raise TypeError( 1149 "Indexing a Series with DataFrame is not " 1150 "supported, use the appropriate DataFrame column" 1151 ) 1152 elif isinstance(key, tuple): -> 1153 return self._get_values_tuple(key) 1155 elif not is_list_like(key): 1156 # e.g. scalars that aren't recognized by lib.is_scalar, GH#32684 1157 return self.loc[key]
File ~/my-conda-envs/HiP-CT-Visium_env/lib/python3.10/site-packages/pandas/core/series.py:1193, in Series._get_values_tuple(self, key) 1188 if com.any_none(*key): 1189 # mpl compat if we look up e.g. ser[:, np.newaxis]; 1190 # see tests.series.timeseries.test_mpl_compat_hack 1191 # the asarray is needed to avoid returning a 2D DatetimeArray 1192 result = np.asarray(self._values[key]) -> 1193 disallow_ndim_indexing(result) 1194 return result 1196 if not isinstance(self.index, MultiIndex):
File ~/my-conda-envs/HiP-CT-Visium_env/lib/python3.10/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.