Skip to content

anndataToGiotto fails to load from H5AD #319

@xw363

Description

@xw363

Hi, I encountered a warning and an error when loading an AnnData object using anndataToGiotto():

> giotto.obj <- anndataToGiotto(data_path)
...
Warning: Key 'connectivities' not found in adata.uns.
Error in py_call_impl(callable, call_args$unnamed, call_args$named) : 
  TypeError: 'NoneType' object is not subscriptable
Run `reticulate::py_last_error()` for details.

> reticulate::py_last_error()

── Python Exception Message ────────────────────────────────────────────────────────────────────────────────────────────────────
Traceback (most recent call last):
  File "/Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/GiottoClass/python/ad2g.py", line 322, in align_network_data
    w_nz = weights[idx_dist_not_sparse].astype(float)
TypeError: 'NoneType' object is not subscriptable

── R Traceback ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    ▆
 1. └─GiottoClass::anndataToGiotto(data_path)
 2.   └─reticulate (local) align_network_data(distances = weights_ad, weights = distances_ad)
 3.     └─reticulate:::py_call_impl(callable, call_args$unnamed, call_args$named)
See `reticulate::py_last_error()$r_trace$full_call` for more details.

The AnnData object was first converted from a Xenium dataset using the spatialdata Python package and then processed using Scanpy (but not Giotto). Since the error seems to be related to nearest neighbor networks, I am also listing relevant info below:

> adata.uns['neighbors']
'connectivities_key': 'connectivities',
 'distances_key': 'distances',
 'params': {'method': 'umap',
  'metric': 'euclidean',
  'n_neighbors': 15,
  'n_pcs': 20,
  'random_state': 0}}

> adata.obsp
PairwiseArrays with keys: connectivities, distances

> adata.obsp['connectivities']
<Compressed Sparse Row sparse matrix of dtype 'float32'
	with 20864442 stored elements and shape (960632, 960632)>

> adata.obsp['distances']
<Compressed Sparse Row sparse matrix of dtype 'float32'
	with 15370112 stored elements and shape (960632, 960632)>

Software versions:

  • R: 4.4.3
  • Giotto: 4.2.2
  • GiottoClass: 0.4.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions