Harmony is an algorithm that integrates single-cell RNA-seq data by iteratively soft-clustering cells and applying a mixture model-based correction to harmonize diverse datasets in a shared embedding. It operates on a low-dimensional principal component analysis (PCA) space, grouping cells into multi-dataset clusters and computing dataset-specific linear correction factors to align populations while preserving genuine biological variation.
Glossary
Harmony

What is Harmony?
Harmony is an iterative algorithm for integrating single-cell RNA-seq data that uses soft clustering and a mixture model-based correction to project diverse datasets into a shared, batch-corrected embedding.
Unlike methods requiring a reference dataset, Harmony performs unsupervised data integration by maximizing cluster diversity—penalizing clusters dominated by a single batch. This makes it robust for merging heterogeneous studies, technologies, and donors. The algorithm scales efficiently to millions of cells and is widely used for query-to-reference mapping and constructing large-scale single-cell atlases.
Key Features of Harmony
Harmony integrates single-cell RNA-seq data through an iterative process of soft clustering and mixture model-based correction, projecting diverse datasets into a shared, batch-corrected embedding without requiring predefined cell-type labels.
Soft Clustering with Fuzzy Assignment
Harmony uses soft k-means clustering to assign each cell to multiple clusters probabilistically rather than forcing hard boundaries. This fuzzy assignment captures transitional cell states and continuous differentiation trajectories more accurately than discrete clustering. Each cell receives a membership vector across k clusters, enabling nuanced correction that respects biological gradients.
Mixture Model-Based Batch Correction
The algorithm applies a linear mixture model to estimate and remove batch effects within each soft cluster independently. For each cluster, Harmony computes a dataset-specific correction factor that shifts cells toward a shared centroid. This local correction preserves biologically meaningful variation while eliminating technical noise introduced by different sequencing platforms, protocols, or laboratories.
Maximum Diversity Clustering
Harmony enforces a maximum diversity penalty during clustering to prevent any single batch from dominating a cluster. This constraint ensures that each cluster contains cells from multiple datasets, forcing the algorithm to find shared biological structures rather than isolating batch-specific artifacts. The penalty is controlled by a tunable theta parameter that balances integration strength against biological preservation.
Iterative Expectation-Maximization
The algorithm alternates between two steps until convergence:
- E-step: Update soft cluster assignments based on current corrected embeddings
- M-step: Re-estimate cluster centroids and batch correction parameters This expectation-maximization framework guarantees monotonic improvement of the objective function, typically converging within 5-10 iterations for most single-cell datasets.
Scalable to Million-Cell Datasets
Harmony achieves O(N) linear time complexity relative to cell count, making it suitable for atlas-scale integration. The algorithm processes 1 million cells in under 30 minutes on standard hardware by using efficient sparse matrix operations and avoiding pairwise distance calculations between all cells. This scalability has enabled integration of the Human Cell Atlas and other large-scale reference mapping projects.
Integration Without Reference Dataset
Unlike supervised methods such as label transfer or query-to-reference mapping, Harmony performs unsupervised integration without requiring a pre-annotated reference atlas. All datasets are treated symmetrically during correction, making it ideal for exploratory analyses where ground-truth cell types are unknown or when integrating novel populations not present in existing references.
Frequently Asked Questions
Explore the mechanics, applications, and theoretical underpinnings of the Harmony algorithm for robust single-cell data integration.
Harmony is an iterative algorithm that integrates single-cell RNA-seq data by soft-clustering cells and applying a mixture model-based correction to harmonize diverse datasets in a shared embedding. It begins with a low-dimensional embedding, such as one generated by Principal Component Analysis (PCA). In each iteration, Harmony performs a fuzzy clustering of cells into potentially overlapping groups using a variant of the Expectation-Maximization (EM) algorithm. It then calculates a dataset-specific linear correction factor for each cluster. Crucially, it applies a soft-mixing penalty that encourages cells from different datasets to intermingle within each cluster, progressively removing technical batch effects while preserving genuine biological variation. The output is an adjusted embedding where cells group by cell type rather than by experimental origin.
Harmony vs. Other Integration Methods
A feature-level comparison of Harmony with alternative single-cell data integration algorithms for batch correction and dataset harmonization.
| Feature | Harmony | Seurat CCA | scVI |
|---|---|---|---|
Core Algorithm | Iterative soft-clustering with mixture model correction | Canonical correlation analysis with mutual nearest neighbors | Variational autoencoder with latent variable modeling |
Handles Multiple Batches Simultaneously | |||
Preserves Rare Cell Populations | |||
Requires GPU for Training | |||
Scalability (Cells) |
| ~100,000 |
|
Output Type | Corrected PCA embeddings | Aligned canonical components | Probabilistic latent space |
Integration Runtime (100k cells) | < 5 min | 10-30 min | 30-60 min |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core concepts and methods that complement the Harmony algorithm for integrating and interpreting diverse single-cell datasets.
Batch Effect Correction
A computational process that removes technical variation introduced by different experimental batches, allowing genuine biological signals to be compared across separately processed single-cell datasets. Harmony is a leading method for this task, using soft clustering and a mixture model to align datasets in a shared embedding without requiring merged data correction.
Data Integration
The computational alignment of multiple single-cell datasets from different conditions, technologies, or donors into a shared latent space. Unlike simple batch correction, integration must preserve biological variation while removing technical noise. Harmony achieves this by iteratively clustering cells and correcting for dataset-specific effects within each cluster.
Principal Component Analysis (PCA)
A linear dimensionality reduction algorithm that transforms high-dimensional gene expression data into a set of orthogonal principal components capturing the maximum variance. Harmony typically operates on a PCA embedding as input, using these reduced dimensions to efficiently cluster cells and apply mixture model-based corrections.
Label Transfer
A supervised machine learning approach that projects cell-type annotations from a well-characterized reference atlas onto a new query dataset by identifying transcriptional similarities. Harmony's integrated embedding provides a robust foundation for label transfer, as cells from different batches are aligned in a common space where nearest-neighbor relationships reflect biology rather than technical artifacts.
Leiden Clustering
A graph-based community detection algorithm that partitions single-cell neighborhoods into biologically meaningful clusters. While Harmony performs its own soft clustering during integration, the harmonized embedding is often subsequently analyzed with Leiden clustering to identify discrete cell populations across the integrated dataset.
Query-to-Reference Mapping
The computational projection of new single-cell profiles onto an established reference atlas to rapidly annotate cell types and identify novel states. Harmony enables efficient query mapping by providing a reference embedding where new cells can be projected without requiring a full reintegration of the entire dataset, accelerating iterative analysis workflows.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us