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

Is it possible to pass a custom embedding? #224

Open
zvittorio opened this issue Apr 4, 2024 · 0 comments
Open

Is it possible to pass a custom embedding? #224

zvittorio opened this issue Apr 4, 2024 · 0 comments
Labels

Comments

@zvittorio
Copy link

zvittorio commented Apr 4, 2024

Hi MAGIC developers/maintainers,

as the title reads, I was wondering whether there is an option to pass a custom embedding that overrides the PCA computed while running magic.MAGIC.fit_transform.
For example like the PCA computed by Harmony so that the imputation also follows the integration logic based on Harmony results.
Thank you for the clarification

Vittorio

Update: going over the code I found that the methods of the Magic class (e.g., fit, transform, fit_transform) also have a graph argument to receive a precomputed graph in the format of graphtools.
So what I did was the following:

import graphtools as gt
import magic

custom_knn = gt.Graph(embedding, n_pca=None)

magic_operator = magic.MAGIC(t=3)

magic_fit = magic_operator.fit(X=adata.X, graph=custom_knn) 

magic_counts = magic_fit.transform(X=adata.X, genes=genes, t_max=3)

Everything runs fine without any warning or errors.
At this point my updated question would be, is this the correct workflow meant for a user-defined graph in MAGIC?

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

No branches or pull requests

1 participant