dynamo.pp.harmony_debatch(adata, key, basis='X_pca', adjusted_basis='X_pca_harmony', max_iter_harmony=10, copy=False)[source]

Use harmonypy [Korunsky19] to remove batch effects.

This function should be run after performing PCA but before computing the neighbor graph. Original Code Repository is https://github.com/slowkow/harmonypy. Interesting example: https://slowkow.com/notes/harmony-animation/

  • adata (AnnData) – An Anndata object.

  • key (str) – The name of the column in adata.obs that differentiates among experiments/batches.

  • basis (str) – The name of the field in adata.obsm where the PCA table is stored.

  • adjusted_basis (str) – The name of the field in adata.obsm where the adjusted PCA table will be stored after running this function.

  • max_iter_harmony (int) – Maximum number of rounds to run Harmony. One round of Harmony involves one clustering and one correction step.

  • copy (bool) – Whether to copy adata or modify it inplace.

Return type:



Updates adata with the field adata.obsm[adjusted_basis], containing principal components adjusted by Harmony.