Skip to content

hr2d

Hartigan 2D classification of cryo-EM particle images with a RELION-style pose search

hr2d is a GPU (PyTorch) program for cryo-EM 2D classification. It classifies particle images through an approach inspired by Hartigan's k-means. We provide an efficient implementation by adapting the infrastructure developed in RELION, specifically we adapt the rotation operators, angle/shift search strategies and frequency marching strategy.

hr2d reads a RELION STAR file and writes RELION-format classes, particle STAR files and model files.

Details and results are available in our paper (link coming soon).

Capabilities

  • 2D classification (hr2d run): Hartigan k-means, or Lloyd (batch) k-means on the same pose search and model, with the RELION schedule (25 full passes) or a cryoSPARC-style minibatch schedule.
  • Analysis: scripts that convert RELION, cryoSPARC and Xmipp results to one convention, and compute a version of the k-means loss adapted to 2D classification.

Getting started

See the Installation page, then the Tutorial: four shapes at SNR 0.1, classified in under a minute. 2D classification lists every option.

Reproducing paper results

All the input STAR files, run scripts and config files, every method's results, the simulated datasets, the analysis scripts and the instructions are available on Zenodo. The experimental particle images are public on EMPIAR (EMPIAR-10028, 10076, 10096 and 10180). These results were obtained with the version of hr2d tagged paper-runs.

LLM disclosure

This code was written with Claude Code, Anthropic's AI coding assistant, under direction and supervision of the authors. The code has been revised and edited by the authors where necessary. It combines the Hartigan k-means model of our earlier JAX implementation, hartigan_2dclassification (now archived), with RELION's 2D classification machinery, reimplemented in PyTorch with RELION's source code as the reference. See the README for details.

Contact

Please submit bug reports, feature requests, or general feedback as a GitHub issue.