-
Notifications
You must be signed in to change notification settings - Fork 17
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
MuData.to_anndata()
& AnnData.to_mudata()
#14
Labels
enhancement
New feature or request
Milestone
Comments
The API should come in v0.3. As the |
This now works: import jax
import numpy as np
from mudata import *
x = np.array(jax.random.normal(jax.random.PRNGKey(1), (100, 300)))
adata = AnnData(x)
adata.var["split"] = np.array(jax.random.binomial(jax.random.PRNGKey(1), 1, .5, (adata.n_vars,)))
adata.var["split"] = adata.var["split"].map({0.0: 'a', 1.0: 'b'})
to_mudata(adata, axis=0, by='split')
# MuData object with n_obs × n_vars = 100 × 300
# var: 'split'
# 2 modalities
# a: 100 x 139
# var: 'split'
# b: 100 x 161
# var: 'split'
mdata.to_anndata()
# AnnData object with n_obs × n_vars = 100 × 300
# var: 'split'
# obsm: 'a', 'b'
# varm: 'a', 'b' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd like to propose some utility methods for converting back and forth between MuData and AnnData objects.
Implementations would look something like:
With
split_by
being: scverse/anndata#613Additional needs
I think it would be good to have arguments giving some control over which features are moved to/ from shared mappings in the mudata object, as opposed to being anndata specific.
Decisions on copies vs views would be good as well.
Use cases
The main use case here is easing transition for libraries that only work with one of the types. I think it would also make it much easier to play around with which representation fits a particular use case better.
It also does a good job of advertising the connectedness of the objects, but that's very secondary.
The text was updated successfully, but these errors were encountered: