scverse / anndata

Annotated data.
http://anndata.readthedocs.io
BSD 3-Clause "New" or "Revised" License
525 stars 150 forks source link

AnnCollection cannot be converted to AnnData #1383

Open jwalewski opened 4 months ago

jwalewski commented 4 months ago

Please make sure these conditions are met

Report

There should be an easy way to convert AnnCollections to normal AnnData objects - I am considering this a bug report as, in theory, one would expect the AnnData() function to do this, but it doesn't. Unfortunately, the default method does not accept AnnCollection datatypes.

How should an AnnCollection object be converted to an AnnData object?

Code:

whole_object = ad.AnnData(collected_adata)
#collected_adata is an AnnCollection

Traceback:

Traceback (most recent call last):
  File "<string>", line 363, in <module>
  File "<string>", line 355, in main
  File "/home/jw2894/.local/lib/python3.10/site-packages/anndata/_core/anndata.py", line 362, in __init__
    self._init_as_actual(
  File "/home/jw2894/.local/lib/python3.10/site-packages/anndata/_core/anndata.py", line 514, in _init_as_actual
    raise ValueError(
ValueError: `X` needs to be of one of ndarray, MaskedArray, spmatrix, ZarrArray, ZappyArray, DaskArray, CupyArray, CupySparseMatrix, BaseCompressedSparseDataset, not <class 'anndata.experimental.multi_files._anncollection.AnnCollection'>.

Versions

-----
anndata             0.11.0.dev31+g49ca3bd
session_info        1.0.0
-----
cython_runtime      NA
dateutil            2.8.2
exceptiongroup      1.0.1
h5py                3.9.0
mpl_toolkits        NA
natsort             8.4.0
numpy               1.24.4
packaging           21.3
pandas              2.1.0
pytz                2023.3.post1
scipy               1.11.2
setuptools_scm      NA
sitecustomize       NA
six                 1.16.0
sphinxcontrib       NA
-----
Python 3.10.8 (main, Jun 21 2023, 12:35:41) [GCC 12.2.0]
Linux-4.18.0-477.27.1.el8_8.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2024-02-21 14:44
github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. Please add a comment if you want to keep the issue open. Thank you for your contributions!