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

.copy() doesn't work for backed files #18

Closed
gtca opened this issue Dec 14, 2020 · 3 comments
Closed

.copy() doesn't work for backed files #18

gtca opened this issue Dec 14, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@gtca
Copy link
Collaborator

gtca commented Dec 14, 2020

Modalities backed inside a .h5mu file can't be copied to a new location as expected:

>>> mdata = mu.read("rna_atac.h5mu", backed=True)
>>> mdata['rna'].copy("rna.h5ad")
KeyError: "Unable to open object (object 'mod' doesn't exist)"
@gtca gtca added the bug Something isn't working label Dec 14, 2020
@ilia-kats
Copy link
Collaborator

Either there is a serious bug in AnnData, or I'm not understanding the semantics of copy. It seems that a copy operation of a backed AnnData also overwrites the backing file of the original object:

In [3]: test = ad.read_h5ad("/home/kats/rna.h5ad", backed=True)

In [4]: test2 = test.copy("/home/kats/rna2.h5ad")

In [5]: test2.filename                                                                                                                                                                                    
Out[5]: PosixPath('/home/kats/rna2.h5ad')

In [6]: test.filename                                                                                                                                                                                     
Out[6]: PosixPath('/home/kats/rna2.h5ad')

And this issue is ultimately a consequence of that.

@gtca
Copy link
Collaborator Author

gtca commented Mar 15, 2021

I am struggling to provide any reasonable explanation to that behaviour, thanks for noticing! Let's see if that might be resolved upstream indeed then.

@ilia-kats
Copy link
Collaborator

This should work with current AnnData master, closing. Please reopen if there are any more issues with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants