You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a problem in the spatial binning function in that creates the wrong matrix type that then triggers an error downstream.
from popari._dataset_utils import _spatial_binning
binned_datasets = []
for dataset in transformed_datasets:
binned_dataset = _spatial_binning(dataset, chunks=8, downsample_rate=0.2)
print(f"Dataset downsampled from {len(dataset)} spots to {len(binned_dataset)} spots.")
binned_datasets.append(binned_dataset)
/bgfs/alee/LO_LAB/Personal/Alexander_Chang/alc376/envs/popari_env/lib/python3.12/site-packages/scipy/sparse/_index.py:151: SparseEfficiencyWarning: Changing the sparsity structure of a csr_array is expensive. lil and dok are more efficient.
self._set_arrayXarray(i, j, x)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[23], line 8
5 if isinstance(dataset.X, csr_array):
6 # Convert dataset.X to csr_matrix
7 dataset.X = dataset.X.tocsr()
----> 8 binned_dataset = _spatial_binning(dataset, chunks=8, downsample_rate=0.2)
9 print(f"Dataset downsampled from {len(dataset)} spots to {len(binned_dataset)} spots.")
10 binned_datasets.append(binned_dataset)
File /bgfs/alee/LO_LAB/Personal/Alexander_Chang/alc376/envs/popari_env/lib/python3.12/site-packages/popari/_dataset_utils.py:797, in _spatial_binning(dataset, level, chunks, downsample_rate, chunk_size, chunk_1d_density, num_jobs)
795 binned_dataset.obsm["spatial"] = filtered_bin_coordinates
796 binned_dataset.obs["total_transformed_counts"] = binned_dataset.X.sum(axis=1)
--> 797 binned_dataset.obsm[f"bin_assignments_{binned_dataset_name}"] = bin_assignments
799 binned_dataset.uns["chunk_size"] = chunk_size
800 binned_dataset.uns["chunk_1d_density"] = chunk_1d_density
File /bgfs/alee/LO_LAB/Personal/Alexander_Chang/alc376/envs/popari_env/lib/python3.12/site-packages/anndata/_core/aligned_mapping.py:216, in AlignedActual.__setitem__(self, key, value)
215 def __setitem__(self, key: str, value: Value):
--> 216 value = self._validate_value(value, key)
217 self._data[key] = value
File /bgfs/alee/LO_LAB/Personal/Alexander_Chang/alc376/envs/popari_env/lib/python3.12/site-packages/anndata/_core/aligned_mapping.py:279, in AxisArraysBase._validate_value(self, val, key)
277 msg = "Index.equals and pd.testing.assert_index_equal disagree"
278 raise AssertionError(msg)
--> 279 return super()._validate_value(val, key)
File /bgfs/alee/LO_LAB/Personal/Alexander_Chang/alc376/envs/popari_env/lib/python3.12/site-packages/anndata/_core/aligned_mapping.py:100, in AlignedMappingBase._validate_value(self, val, key)
97 raise ValueError(msg)
99 name = f"{self.attrname.title().rstrip('s')} {key!r}"
--> 100 return coerce_array(val, name=name, allow_df=self._allow_df)
File /bgfs/alee/LO_LAB/Personal/Alexander_Chang/alc376/envs/popari_env/lib/python3.12/site-packages/anndata/_core/storage.py:104, in coerce_array(value, name, allow_df, allow_array_like)
102 if e is not None:
103 msg += " (Failed to convert it to an array, see above for details.)"
--> 104 raise ValueError(msg) from e
ValueError: Obsm 'bin_assignments_MWS22-14789_level_0' needs to be of one of np.ndarray, numpy.ma.core.MaskedArray, scipy.sparse.spmatrix, awkward.Array, h5py.Dataset, zarr.Array, zappy.base.ZappyArray, anndata.experimental.[CSC,CSR]Dataset, dask.array.Array, cupy.ndarray, or cupyx.scipy.sparse.spmatrix, not <class 'scipy.sparse._csr.csr_array'>.
The text was updated successfully, but these errors were encountered:
There's a problem in the spatial binning function in that creates the wrong matrix type that then triggers an error downstream.
The text was updated successfully, but these errors were encountered: