scverse / anndata

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

transpose fails for backed='r' #225

Open bkmartinjr opened 5 years ago

bkmartinjr commented 5 years ago

Found while trying to support backed mode in cellxgene: if I load an h5ad in backed mode, .T and .transpose fail:

Example:

>>> import anndata 
>>> ad = anndata.read_h5ad('example-dataset/pbmc3k.h5ad', backed='r')
>>> ad.T
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/c/Users/bruce/projects/cellxgene/venv/lib/python3.6/site-packages/anndata/core/anndata.py", line 1405, in transpose
    return AnnData(X.T, self._var, self._obs, self._uns,
AttributeError: 'Dataset' object has no attribute 'T'
>>> ad.transpose()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/c/Users/bruce/projects/cellxgene/venv/lib/python3.6/site-packages/anndata/core/anndata.py", line 1405, in transpose
    return AnnData(X.T, self._var, self._obs, self._uns,
AttributeError: 'Dataset' object has no attribute 'T'
>>> ad.X.T
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Dataset' object has no attribute 'T'

Version info:

anndata==0.6.22.post1
h5py==2.9.0
ivirshup commented 5 years ago

What were you expecting adata.T to do? I'm asking because I'm not completely sure what I'd expect it to do.

My first thought was it would require making a transposed copy of the entire object, and we currently require a path for that in backed mode. A transposed view of the backed object could work, but I'm not sure how much work that would take on our end.

bkmartinjr commented 5 years ago

Possibly naively, I was expecting a view. Perhaps this is just a documentation bug, as the docs seem to indicate that these exist and work for all AnnData modes. It would be very helpful if the docs made it clear which subset of the AnnData API work with all modes, and which are mode-specific.

github-actions[bot] commented 1 year 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!