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
Thanks for your work on cellcharter. I'm particularly interested in running the differential neighbourhood enrichment function. As such, I created a clean environment like so, skipping install of scARCHES or scVI tools.
Based on the tutorials, i'd expect the following to give me neighbourhood enrichment (albeit based on 'cell_type' rather than 'spatial_cluster' as in the tutorial, as i have skipped the spatial clustering aspect)
import squidpy as sq
import cellcharter as cc
import scanpy as sc
# Download codex test dataset
adata = cc.datasets.codex_mouse_spleen('./data/codex_mouse_spleen.h5ad')
# Find neighbours
sq.gr.spatial_neighbors(adata, library_key='sample', coord_type='generic', delaunay=True)
# Prune long links
cc.gr.remove_long_links(adata)
# Make condition categorical
adata.obs['condition'] = adata.obs['sample'].str.split('-').str[0].astype('category')
# Subset on condition
adata_balbc = adata[adata.obs['condition'] == 'BALBc']
# Run neighbourhood enrichment
cc.gr.nhood_enrichment(
adata_balbc,
cluster_key='cell_type',
)
However, i get the following error
[C:\Users\U062951\Miniconda3\envs\cellcharter\lib\site-packages\dask\dataframe\__init__.py:31](file:///C:/Users/U062951/Miniconda3/envs/cellcharter/lib/site-packages/dask/dataframe/__init__.py#line=30): FutureWarning: The legacy Dask DataFrame implementation is deprecated and will be removed in a future version. Set the configuration option `dataframe.query-planning` to `True` or None to enable the new Dask Dataframe implementation and silence this warning.
warnings.warn(
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[~\AppData\Local\Temp\ipykernel_14368\3833515324.py](http://localhost:8888/lab/tree/~/AppData/Local/Temp/ipykernel_14368/3833515324.py) in ?()
17 # Subset on condition
18 adata_balbc = adata[adata.obs['condition'] == 'BALBc']
19
20 # Run neighbourhood enrichment
---> 21 cc.gr.nhood_enrichment(
22 adata_balbc,
23 cluster_key='cell_type',
24 )
[~\AppData\Roaming\Python\Python310\site-packages\cellcharter\gr\_nhood.py](http://localhost:8888/lab/tree/~/AppData/Roaming/Python/Python310/site-packages/cellcharter/gr/_nhood.py) in ?(adata, cluster_key, connectivity_key, log_fold_change, only_inter, symmetric, pvalues, n_perms, n_jobs, batch_size, observed_expected, copy)
216 connectivity_key = Key.obsp.spatial_conn(connectivity_key)
217 _assert_connectivity_key(adata, connectivity_key)
218 _assert_categorical_obs(adata, key=cluster_key)
219
--> 220 result = _nhood_enrichment(
221 adata.obsp[connectivity_key],
222 adata.obs[cluster_key],
223 log_fold_change=log_fold_change,
[~\AppData\Roaming\Python\Python310\site-packages\cellcharter\gr\_nhood.py](http://localhost:8888/lab/tree/~/AppData/Roaming/Python/Python310/site-packages/cellcharter/gr/_nhood.py) in ?(adj, labels, log_fold_change, only_inter, symmetric, pvalues, n_perms, n_jobs, batch_size, observed_expected)
86 adj = _remove_intra_cluster_links(labels, adj)
87
88 cluster_categories = labels.cat.categories
89
---> 90 observed = _observed_n_clusters_links(
91 adj,
92 labels=labels,
93 symmetric=symmetric,
[~\AppData\Roaming\Python\Python310\site-packages\cellcharter\gr\_nhood.py](http://localhost:8888/lab/tree/~/AppData/Roaming/Python/Python310/site-packages/cellcharter/gr/_nhood.py) in ?(adj, labels, symmetric)
20 def _observed_n_clusters_links(adj, labels, symmetric=True):
21 labels_unique = labels.cat.categories
22 obs = np.zeros((len(labels_unique), len(labels_unique)))
23 for i, l1 in enumerate(labels_unique):
---> 24 total_cluster_links = adj[labels == l1]
25
26 for j, l2 in enumerate(labels_unique):
27 other_cluster_links = total_cluster_links[:, labels == l2]
[~\Miniconda3\envs\cellcharter\lib\site-packages\scipy\sparse\_index.py](http://localhost:8888/lab/tree/~/Miniconda3/envs/cellcharter/lib/site-packages/scipy/sparse/_index.py) in ?(self, key)
29 def __getitem__(self, key):
---> 30 index, new_shape = self._validate_indices(key)
31
32 # 1D array
33 if len(index) == 1:
[~\Miniconda3\envs\cellcharter\lib\site-packages\scipy\sparse\_index.py](http://localhost:8888/lab/tree/~/Miniconda3/envs/cellcharter/lib/site-packages/scipy/sparse/_index.py) in ?(self, key)
265 if ix.shape != mid_shape:
266 raise IndexError(
267 f"bool index {i} has shape {mid_shape} instead of {ix.shape}"
268 )
--> 269 index.extend(ix.nonzero())
270 array_indices.extend(range(index_ndim, tmp_ndim))
271 index_ndim = tmp_ndim
272 else: # dense array
[~\Miniconda3\envs\cellcharter\lib\site-packages\pandas\core\generic.py](http://localhost:8888/lab/tree/~/Miniconda3/envs/cellcharter/lib/site-packages/pandas/core/generic.py) in ?(self, name)
6295 and name not in self._accessors
6296 and self._info_axis._can_hold_identifiers_and_holds_name(name)
6297 ):
6298 return self[name]
-> 6299 return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'nonzero'
anyio NA
arrow 1.3.0
asttokens NA
attr 25.1.0
attrs 25.1.0
babel 2.17.0
brotli 1.1.0
certifi 2025.01.31
charset_normalizer 3.4.1
colorama 0.4.6
comm 0.2.2
cython_runtime NA
dateutil 2.9.0.post0
debugpy 1.8.12
decorator 5.1.1
exceptiongroup 1.2.2
executing 2.1.0
fastjsonschema NA
fqdn NA
idna 3.10
ipykernel 6.29.5
isoduration NA
jedi 0.19.2
jinja2 3.1.5
json5 0.10.0
jsonpointer 3.0.0
jsonschema 4.23.0
jsonschema_specifications NA
jupyter_events 0.11.0
jupyter_server 2.15.0
jupyterlab_server 2.27.3
markupsafe 3.0.2
nbformat 5.10.4
nt NA
ntsecuritycon NA
overrides NA
packaging 24.2
parso 0.8.4
pickleshare 0.7.5
platformdirs 4.3.6
prometheus_client NA
prompt_toolkit 3.0.50
psutil 6.1.1
pure_eval 0.2.3
pydev_ipython NA
pydevconsole NA
pydevd 3.2.3
pydevd_file_utils NA
pydevd_plugins NA
pydevd_tracing NA
pygments 2.19.1
pythoncom NA
pythonjsonlogger NA
pywintypes NA
referencing NA
requests 2.32.3
rfc3339_validator 0.1.4
rfc3986_validator 0.1.1
rpds NA
send2trash NA
six 1.17.0
sniffio 1.3.1
socks 1.7.1
sphinxcontrib NA
stack_data 0.6.3
tornado 6.4.2
traitlets 5.14.3
typing_extensions NA
uri_template NA
urllib3 1.26.20
wcwidth 0.2.13
webcolors NA
websocket 1.8.0
win32api NA
win32com NA
win32con NA
win32security NA
win32trace NA
winerror NA
yaml 6.0.2
zmq 26.2.1
Report
Hi,
Thanks for your work on cellcharter. I'm particularly interested in running the differential neighbourhood enrichment function. As such, I created a clean environment like so, skipping install of scARCHES or scVI tools.
Based on the tutorials, i'd expect the following to give me neighbourhood enrichment (albeit based on 'cell_type' rather than 'spatial_cluster' as in the tutorial, as i have skipped the spatial clustering aspect)
However, i get the following error
INcluding a list of my installed packages too
Version information
session_info 1.0.0
anyio NA
arrow 1.3.0
asttokens NA
attr 25.1.0
attrs 25.1.0
babel 2.17.0
brotli 1.1.0
certifi 2025.01.31
charset_normalizer 3.4.1
colorama 0.4.6
comm 0.2.2
cython_runtime NA
dateutil 2.9.0.post0
debugpy 1.8.12
decorator 5.1.1
exceptiongroup 1.2.2
executing 2.1.0
fastjsonschema NA
fqdn NA
idna 3.10
ipykernel 6.29.5
isoduration NA
jedi 0.19.2
jinja2 3.1.5
json5 0.10.0
jsonpointer 3.0.0
jsonschema 4.23.0
jsonschema_specifications NA
jupyter_events 0.11.0
jupyter_server 2.15.0
jupyterlab_server 2.27.3
markupsafe 3.0.2
nbformat 5.10.4
nt NA
ntsecuritycon NA
overrides NA
packaging 24.2
parso 0.8.4
pickleshare 0.7.5
platformdirs 4.3.6
prometheus_client NA
prompt_toolkit 3.0.50
psutil 6.1.1
pure_eval 0.2.3
pydev_ipython NA
pydevconsole NA
pydevd 3.2.3
pydevd_file_utils NA
pydevd_plugins NA
pydevd_tracing NA
pygments 2.19.1
pythoncom NA
pythonjsonlogger NA
pywintypes NA
referencing NA
requests 2.32.3
rfc3339_validator 0.1.4
rfc3986_validator 0.1.1
rpds NA
send2trash NA
six 1.17.0
sniffio 1.3.1
socks 1.7.1
sphinxcontrib NA
stack_data 0.6.3
tornado 6.4.2
traitlets 5.14.3
typing_extensions NA
uri_template NA
urllib3 1.26.20
wcwidth 0.2.13
webcolors NA
websocket 1.8.0
win32api NA
win32com NA
win32con NA
win32security NA
win32trace NA
winerror NA
yaml 6.0.2
zmq 26.2.1
IPython 8.32.0
jupyter_client 8.6.3
jupyter_core 5.7.2
jupyterlab 4.3.5
Python 3.10.16 | packaged by conda-forge | (main, Dec 5 2024, 14:07:43) [MSC v.1942 64 bit (AMD64)]
Windows-10-10.0.17763-SP0
Session information updated at 2025-02-05 13:54
The text was updated successfully, but these errors were encountered: