harmonypy
Harmony is an algorithm for integrating multiple high-dimensional datasets.
harmonypy is a port of the harmony R package by Ilya Korsunsky.
Example
This animation shows the Harmony alignment of three single-cell RNA-seq datasets from different donors.
→ How to make this animation.
Installation
This package has been tested with Python 3.7.
Use pip to install:
pip install harmonypy
Usage
Here is a brief example using the data that comes with the R package:
import pandas as pd
meta_data = pd.read_csv("data/meta.tsv.gz", sep = "\t")
vars_use = ['dataset']
data_mat = pd.read_csv("data/pcs.tsv.gz", sep = "\t")
data_mat = np.array(data_mat)
import harmonypy as hm
ho = hm.run_harmony(data_mat, meta_data, vars_use)
res = pd.DataFrame(ho.Z_corr)
res.columns = ['X{}'.format(i + 1) for i in range(res.shape[1])]
res.to_csv("data/adj.tsv.gz", sep = "\t", index = False)