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

support gene panel selection/adaptation #1697

Open
mojtababahrami opened this issue Sep 26, 2024 · 1 comment
Open

support gene panel selection/adaptation #1697

mojtababahrami opened this issue Sep 26, 2024 · 1 comment
Milestone

Comments

@mojtababahrami
Copy link

mojtababahrami commented Sep 26, 2024

I come across this issue many times when I have two Anndata objects A and B and I want to change B to have the same vars as A by keeping the shared genes and inflating the new genes that are in A but not in B with a default value (e.g. zeros). I searched the API but did not find a function to do this.
Now I do something like the following to achieve this:

adata = ad.concat([adata_train, adata_test], join='outer')
adata_test = adata[len(adata_train):]
adata_test = adata_test[:, adata_train.var.index]
assert (adata_train.var_names == adata_test.var_names).all()

It would be good to support it natively as I assume this is a very common use case (for example you train a model e.g. a simple PCA on A and you want to project/transform the B using that model).

So I imagine something like this:

adata_test.adapt_vars(adata_train, fill_value=0)
@ilan-gold
Copy link
Contributor

Hmmm @mojtababahrami this is an interesting idea...I will need to think about it a bit. My initial reaction is that should be fairly straightforward but there may be some rough edges. Thanks for the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants