Classify template-matched particles as inside vs outside a segmented PML nuclear body, and render a 3D visual-proteomics overview.
Accompanies:
Pražák V, Harley I, Falckenhayn J, Boutell C, Thomason PA, Davis BG, Kaufmann R, Carter SD. In situ molecular architecture of PML bodies reveals columnar trinucleosomes in an open state selected by a porous mesh.
Given one PML body segmentation (Amira TIFF label file or pre-exported
.obj mesh) and one or more particle STAR files, the script:
- Loads the segmentation and extracts a triangulated surface via
skimage.measure.marching_cubes, transposing axes from(Z, Y, X)to(X, Y, Z)to match the RELION XYZ coordinate order of the particle STAR files. A pre-exported.objmesh can be passed directly instead. - Builds a
trimesh.Trimeshobject and applies standard repair routines (normals, hole filling, degenerate faces). - Loads particle coordinates from each STAR file, scales them from unbinned STAR pixels into the mesh's coordinate space, and then into nanometres.
- Classifies every particle as inside or outside the PML body by
ray-casting with
Trimesh.contains. - Writes per-type inside/outside counts, per-particle classifications, a JSON summary, and a 3D rendering.
Requires Python 3.10 or newer.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtDependencies: numpy, scikit-image, tifffile, trimesh, matplotlib.
python pml_body_visual_proteomics.py \
--segmentation path/to/pml_labels.tif \
--particles p28:path/to/p28.star \
TRiC_closed:path/to/tric_closed.star \
TRiC_open:path/to/tric_open.star \
--pml-label 2 \
--unbinned-to-mesh-scale 4 \
--mesh-pixel-size-nm 0.992 \
--output-dir results/| Flag | Description |
|---|---|
--segmentation |
Amira TIFF label file or pre-exported .obj mesh. |
--particles |
One or more LABEL:PATH entries. LABEL is used in figure legend and output files. |
--unbinned-to-mesh-scale |
Division factor from unbinned STAR pixels to mesh-space pixels (e.g. 4 if mesh is bin-4). |
--mesh-pixel-size-nm |
Pixel size of the mesh coordinate space in nm (e.g. 0.992 for bin-4 at 2.48 Å unbinned). |
--output-dir |
Directory for outputs (created if absent). |
| Flag | Default | Description |
|---|---|---|
--pml-label |
2 |
Integer label value marking the PML body in the TIFF. |
--isovalue |
0.5 |
Marching-cubes isovalue. |
--title |
segmentation name | Figure title override. |
Run python pml_body_visual_proteomics.py --help for the full list.
- Segmentation: either a
.tif/.tifflabel file (multi-label is supported; only the value given to--pml-labelis treated as PML), or a.objmesh file. - Particle STAR files: standard RELION/PyTOM format with
_rlnCoordinateX,_rlnCoordinateY,_rlnCoordinateZcolumns in unbinned pixel coordinates.
Written to --output-dir:
| File | Contents |
|---|---|
inside_outside_counts.csv |
One row per particle type with total / inside / outside counts and percent inside. |
classifications.csv |
One row per particle with (x, y, z) in nm and the boolean inside classification. |
summary.json |
All parameters used plus the per-type counts. |
rendering.png |
3D figure with the PML body as a semi-transparent mesh and particles as spheres. Large markers denote inside, small markers outside. |
The underlying functions can be called from another Python program:
from pml_body_visual_proteomics import (
load_mesh,
load_star_coords,
classify_particles,
render,
)MIT (see LICENSE).