Harmony with two or more covariates
Sayyam-Shah opened this issue · 3 comments
Hello @slowkow,
Thank you for adding Harmony to Python!
May you please allow harmony to be run with multiple covariates in harmonypy as this will make many workflows easier? This can be done in the R package.
Thanks for opening the issue!
harmonypy version 0.0.4 (and later versions) supports multiple covariates.
Please see #4 for discussion of this issue.
Hello @slowkow
Thank you! Has this been added to the Scanpy function?
I assume the line will look like: sce.pp.harmony_integrate(adata, ['batch1', 'batch2'])
Try it! If it doesn't work, then please consider reporting the issue to scanpy developers.
Please also consider reading the source code for the packages that you use:
Here is what I see inside the harmony_integrate()
scanpy function (lines 77-84):
try:
import harmonypy
except ImportError:
raise ImportError("\nplease install harmonypy:\n\n\tpip install harmonypy")
harmony_out = harmonypy.run_harmony(adata.obsm[basis], adata.obs, key, **kwargs)
adata.obsm[adjusted_basis] = harmony_out.Z_corr.T