Thank you very much for your interest in our work! The Matlab script that was used to determine the optimal number of clusters can be found here: https://github.com/elifesciences-publications/immuneTopography/blob/master/step_03b_findOptimClust.m The core function in this script is the Matlab function "evalclusters" which is extensively documented here: https://de.mathworks.com/help/stats/evalclusters.html. These links should allow you to reproduce the procedure for your project. Hope that helps!