---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[116], line 13
8 adata_unsupervised_cleaned = adata_unsupervised_cleaned[cluster_19_mask, :]
12 # Store cluster names as str in adata object
---> 13 adata_unsupervised_cleaned.obs['Filtered clusters'] = filt_names.astype('str')
14 # Change the names based on the expression patterns
15 new_cluster_names = {
16 0: '(00) Regulatory T cells',
17 1: '(01) Fibroblasts',
(...) 28 17: '(12) Myeloid cells',
29 18: '(13) Dendritic cells'}
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/anndata/_core/views.py:85, in _SetItemMixin.__setitem__(self, idx, value)
78 else:
79 warnings.warn(
80 f"Trying to modify attribute `.{self._view_args.attrname}` of view, "
81 "initializing view as actual.",
82 ImplicitModificationWarning,
83 stacklevel=2,
84 )
---> 85 with view_update(*self._view_args) as container:
86 container[idx] = value
File ~/miniconda3/envs/squidpy/lib/python3.11/contextlib.py:137, in _GeneratorContextManager.__enter__(self)
135 del self.args, self.kwds, self.func
136 try:
--> 137 return next(self.gen)
138 except StopIteration:
139 raise RuntimeError("generator didn't yield") from None
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/anndata/_core/views.py:59, in view_update(adata_view, attr_name, keys)
39 @contextmanager
40 def view_update(adata_view: AnnData, attr_name: str, keys: tuple[str, ...]):
41 """Context manager for updating a view of an AnnData object.
42
43 Contains logic for "actualizing" a view. Yields the object to be modified in-place.
(...) 57 `adata.attr[key1][key2][keyn]...`
58 """
---> 59 new = adata_view.copy()
60 attr = getattr(new, attr_name)
61 container = reduce(lambda d, k: d[k], keys, attr)
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/anndata/_core/anndata.py:1477, in AnnData.copy(self, filename)
1471 if not self.isbacked:
1472 if self.is_view and self._has_X():
1473 # TODO: How do I unambiguously check if this is a copy?
1474 # Subsetting this way means we don’t have to have a view type
1475 # defined for the matrix, which is needed for some of the
1476 # current distributed backend. Specifically Dask.
-> 1477 return self._mutated_copy(
1478 X=_subset(self._adata_ref.X, (self._oidx, self._vidx)).copy()
1479 )
1480 else:
1481 return self._mutated_copy()
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/anndata/_core/anndata.py:1408, in AnnData._mutated_copy(self, **kwargs)
1406 new[key] = kwargs[key]
1407 else:
-> 1408 new[key] = getattr(self, key).copy()
1409 if "X" in kwargs:
1410 new["X"] = kwargs["X"]
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py:125, in AlignedMappingBase.copy(self)
123 def copy(self) -> dict[str, Value]:
124 # Shallow copy for awkward array since their buffers are immutable
--> 125 return {
126 k: copy(v) if isinstance(v, AwkArray) else v.copy() for k, v in self.items()
127 }
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py:125, in <dictcomp>(.0)
123 def copy(self) -> dict[str, Value]:
124 # Shallow copy for awkward array since their buffers are immutable
--> 125 return {
126 k: copy(v) if isinstance(v, AwkArray) else v.copy() for k, v in self.items()
127 }
File <frozen _collections_abc>:861, in __iter__(self)
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py:164, in AlignedView.__getitem__(self, key)
162 def __getitem__(self, key: str) -> Value:
163 return as_view(
--> 164 _subset(self.parent_mapping[key], self.subset_idx),
165 ElementRef(self.parent, self.attrname, (key,)),
166 )
File ~/miniconda3/envs/squidpy/lib/python3.11/functools.py:909, in singledispatch.<locals>.wrapper(*args, **kw)
905 if not args:
906 raise TypeError(f'{funcname} requires at least '
907 '1 positional argument')
--> 909 return dispatch(args[0].__class__)(*args, **kw)
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/anndata/_core/index.py:200, in _subset_sparse(a, subset_idx)
198 first_idx = np.flatnonzero(first_idx)
199 subset_idx = (first_idx.reshape(-1, 1), *subset_idx[1:])
--> 200 return a[subset_idx]
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/scipy/sparse/_index.py:104, in IndexMixin.__getitem__(self, key)
102 res = self.__class__(np.atleast_2d(row).shape, dtype=self.dtype)
103 else:
--> 104 res = self._get_arrayXarray(row, col)
106 # handle spmatrix (must be 2d, dont let 1d new_shape start reshape)
107 if not isinstance(self, sparray):
File ~/miniconda3/envs/squidpy/lib/python3.11/site-packages/scipy/sparse/_compressed.py:565, in _cs_matrix._get_arrayXarray(self, row, col)
562 minor = np.asarray(minor, dtype=idx_dtype)
564 val = np.empty(major.size, dtype=self.dtype)
--> 565 csr_sample_values(M, N, self.indptr, self.indices, self.data,
566 major.size, major.ravel(), minor.ravel(), val)
567 if major.ndim == 1:
568 return self._ascontainer(val)
ValueError: could not convert integer scalar