Abstract
Genomic data analyses such as Genome-Wide Association Studies (GWAS) or Hi-C studies are often faced with the problem of partitioning chromosomes into successive regions based on a similarity matrix of high-resolution, locus-level measurements. An intuitive way of doing this is to perform a modified Hierarchical Agglomerative Clustering (HAC), where only adjacent clusters are allowed to be merged. A major practical drawback of this method is its quadratic time and space complexity. By assuming that the similarity between physically distant objects is negligible, we propose an implementation of this adjacency-constrained HAC with quasi-linear complexity. Our illustrations on GWAS and Hi-C datasets demonstrate the relevance of this assumption and show that this method highlights biologically meaningful signals.
Introduction
In modern genomics, researchers frequently need to partition linear chromosomes into functional blocks. Examples include Linkage Disequilibrium (LD) blocks in GWAS or Topologically Associating Domains (TADs) in Hi-C contact maps. Hierarchical Agglomerative Clustering (HAC) with an adjacency constraint—where only neighboring clusters can merge—is a natural fit for this task. However, standard implementations suffer from $O(p^2)$ complexity, making them impractical for datasets with $10^4$ to $10^5$ loci where the number of potential similarity calculations can reach billions.
Methods: Breaking the Quadratic Bottleneck
The proposed approach achieves quasi-linear complexity through three primary innovations:
1. The Band Similarity Assumption
The authors assume that the similarity between two loci is negligible if they are separated by more than a bandwidth $h$. This transforms the dense $p \times p$ similarity matrix into a sparse band matrix, reducing space complexity to $O(ph)$.
2. The "Pencil Trick"
To compute Ward’s linkage efficiently within this band, the authors developed a recursive strategy. By pre-calculating sums of similarities in specific "pencil-shaped" regions (as seen in the figure above), the cost of any potential merge can be calculated in constant $O(1)$ time. This avoids re-scanning the matrix at every step of the hierarchy.
3. Min-Heap Optimization
Instead of a linear search for the best merge at each step, the algorithm utilizes a min-heap to store and retrieve candidate merges. This reduces the search time from $O(p)$ to $O(\log p)$, which is critical for maintaining performance as the number of loci increases.
Results and Validation
The method was tested on GWAS and Hi-C datasets, demonstrating significant performance gains without sacrificing biological accuracy.
- Computational Efficiency: For a chromosome with ~23,000 SNPs, the
adjclustpackage completed the task in 20 seconds (with $h=1000$), compared to over 5 hours for standard $O(p^2)$ implementations. The complexity scales as $O(p(h + \log p))$. - Memory Footprint: Memory usage for a large human ESC chromosome dropped by a factor of 10 (from 231 Mb to 23 Mb) due to the sparse representation.
- Biological Relevance: Clusters identified in Hi-C data showed high enrichment for CTCF binding sites (proteins that help organize DNA loops), confirming that the "banded" approximation preserves essential biological structures.
Conclusion
By leveraging the inherent locality of genomic interactions, the adjclust method provides a scalable solution for high-resolution chromosome partitioning. The implementation is available as an R package on CRAN, enabling researchers to perform complex genomic clustering on standard hardware in seconds rather than hours.
Summary updated