lilab-bcb / harmony-pytorch

BSD 3-Clause "New" or "Revised" License
45 stars 9 forks source link

Converting to adata.X #8

Open dmiyagi opened 1 year ago

dmiyagi commented 1 year ago

If I'm wanting to pass the 'X_harmony" array downstream to other scanpy external packages like scanpy.external.pp.magic (https://scanpy.readthedocs.io/en/stable/generated/scanpy.external.pp.magic.html) or scanpy.external.tl.phate (https://scanpy.readthedocs.io/en/stable/generated/scanpy.external.tl.phate.html) how would I convert it to take the place of adata.X? sort of like how correct_scanpy() works in Scanorama (https://github.com/brianhie/scanorama) ? Thank you!!

yihming commented 6 months ago

@dmiyagi Sorry that I just saw your issue.

The normal use case of Harmony algorithm is to apply it to some embedding, such as PCA matrix. Therefore, The "X_harmony" array is usually of shape (n_cells, n_comps), where n_comps is the number of components. This is different from adata.X which is of shape (n_cells, n_genes).

So I don't think the direct conversion could work. Otherwise, you may think of creating another AnnData object of shape (n_cells, n_comps) with X_harmony matrix being its adata.X.