Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle non-csr/csc sparse matrices in anndata.write #847

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Nov 8, 2022

  1. Handle non-csr/csc sparse matrices in anndata.write

    Attempting to save an AnnData object with non-CSR/CSC sparse matrices throws an error:
    
    ```
    File "/usr/src/singlecellopenproblems/openproblems/api/utils.py", line 58, in write_h5ad
          adata.write_h5ad(filename)
        File "/usr/local/lib/python3.8/site-packages/anndata/_core/anndata.py", line 1918, in write_h5ad
          _write_h5ad(
        File "/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py", line 85, in write_h5ad
          write_elem(f, "X", adata.X, dataset_kwargs=dataset_kwargs)
        File "/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py", line 220, in func_wrapper
          raise type(e)(
      TypeError: No method has been defined for writing <class 'scipy.sparse._coo.coo_matrix'> elements to <class 'h5py._hl.group.Group'>
      
      Above error raised while writing key 'X' of <class 'h5py._hl.group.Group'> to /
    ```
    
    This PR fixes that by registering an appropriate method which converts all sparse matrices without an explicitly defined conversion to CSR.
    scottgigante-immunai authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    3e1cad3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c446a23 View commit details
    Browse the repository at this point in the history