Post-clustering difference testing: valid inference and practical considerations

Benjamin Hivert, Denis Agniel, Rodolphe Thiébaut, Boris P. Hejblum · DOI

Abstract

Clustering is part of unsupervised analysis methods that consist in grouping samples into homogeneous and separate subgroups of observations also called clusters. To interpret the clusters, statistical hypothesis testing is often used to infer the variables that significantly separate the estimated clusters from each other. However, data-driven hypotheses are considered for the inference process, since the hypotheses are derived from the clustering results. This double use of the data leads traditional hypothesis test to fail to control the Type I error rate particularly because of uncertainty in the clustering process and the potential artificial differences it could create. We propose three novel statistical hypothesis tests which account for the clustering process. Our tests efficiently control the Type I error rate by identifying only variables that contain a true signal separating groups of observations.

Introduction: The "Double-Dipping" Problem

In fields ranging from genomics to ecology, researchers frequently employ clustering algorithms to identify patterns in complex datasets. A common follow-up step is to perform statistical tests, such as a t-test, to determine which variables drive the differences between the identified clusters. However, this approach constitutes "circular analysis" or "double-dipping."

Clustering algorithms are designed to find or even force separations between groups, even when the underlying data is purely random noise. When the same data is used both to define the groups and to test for differences between them, the resulting p-values are artificially small. This leads to a massive inflation of Type I errors (false positives), as traditional tests assume that hypotheses are formulated independently of the data.

Proposed Methods for Valid Inference

To address this bias, three novel statistical tests are proposed that account for the clustering process:

  1. Selective Test (Direct): Utilizing selective inference, this method calculates p-values by conditioning on the clustering event. It employs a "perturbation" approach, determining how much data points could be moved toward each other before the clustering algorithm would no longer separate them. By accounting for this "clustering boundary," it yields valid p-values.
  2. Merging Selective Test: This extension addresses scenarios with "intervening clusters" (e.g., comparing Cluster A and C when Cluster B lies between them). It tests adjacent pairs along a path and merges the p-values using a harmonic mean function to restore statistical power.
  3. Multimodality Test (Dip Test): A non-parametric approach based on the Hartigan Dip Test. Instead of mean differences, it evaluates whether a variable's distribution is multimodal. If a continuum exists between clusters rather than a clear dip, the test concludes the clusters are not truly separated by that variable.

Experimental Evaluation

The methods were evaluated using both simulated Gaussian data and the Palmer Penguins dataset.

  • Simulated Data: Used to model "null" scenarios (pure noise) and "power" scenarios (true clusters with mean difference $\delta$).
  • Palmer Penguins: Served as a real-world benchmark. A negative control using only female Gentoo penguins (one species) tested if the methods correctly reported no significant differences when forced into clusters. A positive control using the full dataset evaluated the ability to identify variables distinguishing the three actual species.

Key Results and Error Control

The primary advantage of the proposed methods is their ability to control the Type I error rate. In noise-only simulations, standard t-tests produced p-values near zero, suggesting high significance where none existed. In contrast, the proposed methods produced a uniform distribution of p-values, indicating valid null hypothesis testing.

Figure 2: (A-B) Clustering a single distribution into two groups. (C-D) Comparison of p-value distributions showing that standard t-tests (yellow) fail to control Type I error, while the proposed selective test (red) matches the expected uniform distribution (blue).

In the penguin negative control, the t-test "discovered" significant differences in flipper length and body mass that were non-existent. The proposed tests correctly identified these as non-significant. Furthermore, the Multimodality Test proved to be significantly faster than the Selective Test, making it suitable for initial data screening.

Practical Considerations and Limitations

While these tests provide a robust solution to the double-dipping problem, certain limitations remain:

  • High Dimensionality: The Selective Test's performance degrades when the number of variables greatly exceeds the number of observations, as the signal becomes too sparse.
  • Computational Cost: The Selective Test requires Monte-Carlo simulations, which can be computationally intensive for large datasets.
  • Univariate Focus: Currently, these tests evaluate variables individually. Future work aims to extend these methods to multivariate feature sets.

Summary updated

BibTeX
@inproceedings{hivert2024post,
  author = {Benjamin Hivert and Denis Agniel and Rodolphe Thiébaut and Boris P. Hejblum},
  title = {{Post-clustering difference testing: valid inference and practical considerations}},
  booktitle = {Computational},
  year = {2024},
  doi = {10.1016/j.csda.2023.107916},
}
Figure