immunogenomics/harmony
Fast, sensitive and accurate integration of single-cell data with Harmony
Harmony — Dataset Integration for Single-Cell Analysis
What it is
Harmony is an R package for integrating single-cell datasets — that is, for combining data collected from different samples, donors, or batches so they can be analyzed together as one coherent dataset.
What it does
It takes PCA cell embeddings (a compact numerical representation of each cell's gene activity, usually precomputed by other tools) and corrects them to remove systematic differences between batches or donors. The output is a corrected set of embeddings you can use in downstream steps like clustering or UMAP visualization.
How you use it — two modes
Standalone (you supply PCA embeddings and metadata yourself):
RunHarmony(my_pca_embeddings, meta_data, "dataset")
The third argument is the name of the column in your metadata that labels which dataset each cell came from.
With Seurat (a popular single-cell analysis package):
seuratObj <- RunHarmony(seuratObj, "dataset")
seuratObj <- RunUMAP(seuratObj, reduction = "harmony")
Here Harmony replaces the PCA step in your Seurat workflow, and you use the harmony embeddings for the rest of the analysis.
It also supports multiple covariates at once — for example, integrating over dataset, donor, and batch simultaneously:
RunHarmony(my_pca_embeddings, meta_data, c("dataset", "donor", "batch_id"))
Works with common pipelines
The README says Harmony supports both Seurat and SingleCellExperiment analysis pipelines, plus the standalone mode described above.
Speed
For datasets with a few samples and under 100,000 cells, integration typically finishes within seconds.
System requirements
- R version 4.2 or newer
- Tested on Linux, macOS, and Windows
- Using OpenBLAS (an optimized math library) makes a substantial performance difference
- For very large datasets (over 10 million cells), the README points to additional OpenMP performance notes
Installation
From CRAN (stable, ~15 seconds):
install.packages("harmony")
Or the development version from GitHub (~5 minutes):
devtools::install_github("immunogenomics/harmony", build_vignettes=TRUE)
Related resources
- The README links to detailed vignettes (tutorials) for a quick start, Seurat integration, and an advanced walkthrough of the internals
- A Python port called
harmonypyexists (by Kamil Slowikowski), linked from the README - The package has a preprint and a published manuscript in Nature Methods (v1)
Related
- Project
- Project
- Project
- Project