factorem
Conformational and compositional heterogeneity of cryo-EM single particles, from independent analyses of each projection direction that are then synchronized.
factorem takes the particles of a consensus refinement and gives each one a few coordinates that describe its state. It never reconstructs a volume. Particles that view the molecule from about the same direction differ in their state and in little else, so each direction is analysed on its own, as a set of 2D images. Every direction ends up with coordinates in a frame of its own, and a synchronization finds the orthogonal transform of each that brings them all to a common one: by default, the transforms that make the eigenimages of the directions agree along their common lines.
Analysing each projection direction by itself and relating the directions afterwards is the idea of ManifoldEM (Dashti et al., 2014, 2020 and Ojha et al. 2025), which factorem follows. It differs in how: each direction is embedded linearly, by a probabilistic PCA with the CTF in its model, and the directions are related all at once and in all their coordinates, by an orthogonal synchronization.
Installation
pip install factorem
For an NVIDIA GPU, ask for the cuda13 or the cuda12 extra, which bring
the matching build of JAX:
pip install 'factorem[cuda13]'
It needs Python 3.10 or later. Images are read with vitrio and everything is computed with JAX.
Usage
factorem analyze particles.star embedded.star --diameter 180
particles.star is a RELION STAR file of the particles, with their
alignment and CTF. The output is the same file with two columns more:
factoremEmbedding, the coordinates of the particle as a list such as
[1.2e-01, -3.4e-01, ...], and factoremGroupCount, how many projection
directions it was analysed with.
| Option | Default | |
|---|---|---|
--diameter |
required | Diameter of the particle [Å]. |
--resolution |
16 | Resolution of the analysis [Å]. |
--components |
6 | Coordinates to give each particle. |
--embedding |
ppca |
How the particles of each direction are embedded: ppca, by a probabilistic PCA with the CTF in its model, or mahalanobis-mds, by the multidimensional scaling of the Mahalanobis distances between the images. |
--synchronization |
common-lines |
How the directions are brought to a common frame: common-lines, by the common lines of their eigenimages, or burer-monteiro, by the particles they share. |
--root |
working directory | Directory that the images named in the STAR file are relative to. |
--device |
first GPU, else CPU | Such as cpu or gpu:1. |
--scratch |
none | Directory to keep the working images in, instead of in memory. |
-v |
Report the progress. |
The same from Python:
import factorem
dataset = factorem.StarDataset.read('particles.star')
embedding = factorem.analyze(
dataset.particles,
diameter=180.0,
embedder=factorem.ProbabilisticPCA(), # The default.
synchronizer=factorem.CommonLineSynchronizer(), # The default.
)
dataset.write('embedded.star', embedding.coordinates, embedding.group_count)
factorem.MahalanobisMDS() is the other embedder, with the distances of
Bhamre, Zhao and Singer (2017), and
factorem.BurerMonteiroSynchronizer() the other synchronization. The
stages that analyze chains are public as well, and
examples/stages.py calls them one by one.
Annotation
pip install 'factorem[annotate]'
factorem annotate embedded.star annotated.star
factorem annotate opens a window with the density of the embedded
particles on a plane, to sort them into classes there. The output is the
same file with one column more, factoremClass: the class of each
particle, from one on, and zero for the particles that the analysis left
out. With --label rlnClassNumber the classes go where RELION looks for
them.
The classes are the Gaussians of a mixture, and each particle is of the one that most likely gave it.
| Control | |
|---|---|
x, y |
The coordinate along each axis of the plane. |
| Lay out by UMAP | Show the plane that UMAP lays all the coordinates out on instead. It needs the umap extra. |
full, tied, diag, spherical |
What the covariances of the fitted Gaussians may be: any, one for all of them, aligned with the axes, or round. |
| Fit K classes | Fit a mixture of K Gaussians. |
| Fit as many as the BIC asks | Fit the mixture of least Bayesian information criterion, among those of up to 20 Gaussians. |
| Fit from the seeds | Fit a mixture of a Gaussian for each seed, starting from them. The classes keep the order of the seeds. |
| Take the seeds as they are | Make a round Gaussian of each seed, without fitting anything. |
| Save and close | Write the output. Nothing is written if the window is closed in any other way. |
A click on the plane places a seed, dragging a seed moves it, the wheel over it changes its size and a right click removes it. The zoom and the pan of the toolbar take the clicks while they are on, and the density is counted again for what they leave in sight. The classes and the seeds belong to the plane they were made on, so changing it drops them.
Development
pip install -e '.[dev]'
pytest
ruff check . && ruff format --check .
mypy
License
GPL-3.0. See LICENSE.
Metadata
Release files for factorem 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| factorem-0.1.0.tar.gz | 87.7 kB | With provenance | Details for factorem-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| factorem-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for factorem-0.1.0-py3-none-any.whl |
Total release size: 168.9 kB
Release files / factorem-0.1.0.tar.gz
| Download URL | factorem-0.1.0.tar.gz |
|---|---|
| Size | 87.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9da2d17c0bacd4c898b91513986463017c25b7176c6de111c7179639439e4d83
|
|
BLAKE2b-256 checksum How to use checksums |
b411a39b4fe83442ca97429bd03b2ad2a3ebfc198c7f9c3c77f359c2c2f7d935
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logRelease files / factorem-0.1.0-py3-none-any.whl
| Download URL | factorem-0.1.0-py3-none-any.whl |
|---|---|
| Size | 81.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eac05491c966f0aa5274460b894e6d0d60cbab4aa8fac0fc676ef275ff421e47
|
|
BLAKE2b-256 checksum How to use checksums |
d3269dbeab4b4eb96ed8b7b02fdf840684e6b5b016b7ffb0969c25e5fdcbed73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logSecurity for factorem 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for factorem-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.