Processing heterogeneous data sets in SIMPLE¶
This guide describes a practical SIMPLE workflow for removing junk, finding discrete compositional or conformational states, and optionally examining continuous motion. It is written for a user who has not used the SIMPLE command line before.
The recommended path is:
picked particles
|
+-- not processed by SIMPLE stream --> particle_sieving
|
+-- already processed by SIMPLE stream --> skip offline sieving
|
v
one or more solve2D runs
|
+-- optional: solve2D_chunks + learned class-rejection model
|
v
initial solve3D cleanup, normally with three/four states
|
v
choose the state(s) to retain
|
+-- one state --> continue that state with solve3D state=N
|
+-- merged states --> select/merge, then single-state solve3D
|
+-- optional: cls_expansion --> refine3D_states_cavgs
|
v
refine3D_states
|
v
select each useful state --> refine3D_auto
(or one refine3D_auto for every state: a state sweep)
|
+-- optional: flex_pca for remaining continuous heterogeneity
The first half of this workflow is junk removal. Do not interpret every class or volume from those runs as a biological state. The second half starts only after a clean particle set has been established.
1. Before running anything¶
Check that SIMPLE is available¶
which simple_exec
simple_exec prg=list
If which prints nothing, load the SIMPLE environment used at your site before
continuing.
Understand a SIMPLE command¶
SIMPLE commands consist of a program name followed by key=value arguments:
simple_exec prg=solve2D projfile=my_project.simple ncls=100 \
mskdiam=180 nparts=4 nthr=16
There must be no spaces around =. In this example:
projfileis the input SIMPLE project.nclsis the requested number of 2D classes.mskdiamis the particle mask diameter in Angstroms.npartsis the number of distributed partitions or worker processes.nthris the number of shared-memory threads used by each process.
The values of nparts and nthr depend on the computer or scheduler. Ask the
local SIMPLE administrator for suitable values. Do not copy the example CPU
values without checking the available resources.
Most workflows create a new numbered execution directory and write a new
.simple project there. At every step:
- read the final lines of the log;
- record the execution directory and output project;
- inspect the result; and
- use that output project as
projfilefor the next step.
Never assume that the original project was modified. Keeping a small text file with every command and its accepted output project prevents most lineage mistakes.
The commands below are templates. Replace every value in angle brackets, including the angle brackets themselves.
2. Remove picking junk¶
2.1 Decide whether offline sieving is needed¶
- If the particles have already been processed by SIMPLE stream, do not run offline sieving again. Start at section 2.2.
- If the particles were picked or imported without SIMPLE stream processing,
run
particle_sievingfirst.
The input project must contain its micrographs, particle stacks, and particle metadata:
simple_exec prg=particle_sieving \
projfile=<EXTRACTED_PROJECT.simple> \
nparts=<CONCURRENT_CHUNKS> nthr=<THREADS_PER_CHUNK>
Here nparts means the number of sieving chunks run at the same time, not MPI
partitions within one chunk. Each concurrent chunk uses nthr threads. Start
conservatively if memory is limited. The standard coarse and fine sieving
settings are used when their advanced parameters are omitted.
Checkpoint: inspect the retained particle count and the class averages. The output should be substantially cleaner without losing convincing, well-resolved particle views.
2.2 Run solve2D (de novo 2D classification)¶
Run solve2D on the sieved or stream-cleaned project:
simple_exec prg=solve2D \
projfile=<SIEVED_OR_STREAM_PROJECT.simple> \
ncls=<NUMBER_OF_CLASSES> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
Inspect the final ranked class-average stack and reject classes that are
obviously ice, carbon, aggregates, empty boxes, or unrecognizable noise. Run
solve2D a second time on the retained particles. More than one run is
useful because genuine views should recur, whereas unstable junk classes tend
not to.
The easiest manual-selection route is to use e2display.py from EMAN2:
- Open the final
cavgs_iterNNN_ranked.mrcsstack from thesolve2Dexecution directory. - In the image-stack window, use the middle-mouse menu and
Delto mark the bad classes. - Use
Savefrom the same menu to write the remaining good classes to a new stack, for exampleselected_cavgs.mrcs. - Map that subset back to its particles:
simple_exec prg=map_cavgs_selection \
projfile=<SOLVE2D_PROJECT.simple> \
stk2=<SELECTED_CAVGS.mrcs> prune=yes
map_cavgs_selection identifies the selected classes by correlation, so the
saved subset does not have to preserve the original class order. Use the
project from the generated numbered _selection/ directory for the next 2D
run.
If EMAN2 is unavailable, a text selection remains possible. Create a file
containing one 1 (keep) or 0 (reject) per 2D class, in project class order,
and apply it with:
simple_exec prg=selection \
projfile=<SOLVE2D_PROJECT.simple> oritype=cls2D \
infile=<CLASS_KEEP_FLAGS.txt> prune=yes
Use the resulting project from the generated numbered _selection/ directory
for the next 2D run.
Checkpoint: continue only when the retained classes have recognizable particle features, cover the expected range of views, and no longer contain a large obvious junk population. Prefer reproducibility over choosing classes merely because they look sharp.
2.3 Optional: classify independent chunks¶
For a large data set, independent chunk classifications can expose rare junk or minority populations that disappear in a single global classification:
simple_exec prg=solve2D_chunks \
projfile=<CLEANING_PROJECT.simple> \
mskdiam=<MASK_DIAMETER_A> nptcls_per_cls=500 nchunks=0 \
nchunks_in_parallel=<PARALLEL_CHUNKS> \
nparts=<PARTITIONS_PER_CHUNK> nthr=<THREADS>
nchunks=0 lets SIMPLE choose enough balanced chunks to target roughly 100
classes per chunk. Peak process use is approximately
nchunks_in_parallel * nparts, so set both values deliberately.
A data-set-specific learned rejection model can make repeated chunk cleanup consistent. Training is an advanced, supervised step: it requires projects in which the final 2D classes have first been reviewed and labelled by a person. The complete procedure is in the appendix. Never train a model on its own unreviewed predictions.
3. Perform the initial 3D cleanup¶
For most heterogeneous data sets, start with three states:
simple_exec prg=solve3D \
projfile=<SELECTED_CLEAN_2D_PROJECT.simple> \
nstates=3 pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
Use pgrp=c1 when no point-group symmetry is justified. Do not impose symmetry
only to make a map appear cleaner.
Inspect all three volumes, their particle populations, their directional coverage and generated re-projections. At this stage the three-state run is primarily a cleanup tool. A state can represent junk, damaged particles, a preferred-view failure, or an unstable reconstruction rather than a biological conformation.
For a large, high-contrast complex with an already clean particle set, it can be reasonable to use one state and postpone heterogeneity analysis:
simple_exec prg=solve3D \
projfile=<SELECTED_CLEAN_2D_PROJECT.simple> \
nstates=1 pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
Use this shortcut only when the single-state result is stable and there is no substantial junk population left to isolate.
Choose the acceptable initial states¶
Record which state or states contain the particles to retain. If one state is sufficient, no separate selection command is needed: section 4 uses SIMPLE's direct state-continuation mode.
To merge two or more acceptable states into one retained particle group:
simple_exec prg=selection \
projfile=<THREE_STATE_SOLVE3D_PROJECT.simple> \
oritype=ptcl3D states=<COMMA_SEPARATED_STATES> prune=yes
For example, use states=1,3 to merge states 1 and 3. Run every independent
selection from the original multi-state project, not from a project that has
already been pruned. Keep the original project so that the decision can be
revisited.
4. Establish a clean consensus model¶
If one state was retained from the multi-state cleanup, a complete new
reference-free solve3D run is unnecessary. Continue directly from that
state:
simple_exec prg=solve3D \
projfile=<MULTISTATE_SOLVE3D_PROJECT.simple> \
state=<STATE_NUMBER> pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
This mode internally selects and prunes the requested state, preserves its
particle poses, reconstructs a same-lineage starting map, and resumes the
single-state search at stage 5 with nonuniform filtering. It is therefore a
gentle continuation of the selected solution rather than another full
de novo search. Do not supply vol1 or nstates: the state-continuation
path owns preparation of the starting reference.
If two or more states were merged in section 3, there is no single state map that represents the merged particle group. In that case, establish a new single-state consensus with:
simple_exec prg=solve3D \
projfile=<MERGED_STATE_SELECTION_PROJECT.simple> \
nstates=1 pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
If the initial cleanup itself used nstates=1, that project already provides
the clean consensus and this section can be skipped. In all three cases, the
resulting single-state project supplies the common map and pose scaffold for
the actual heterogeneity analysis. Inspect its map, half-map agreement,
angular coverage, and particle count before continuing.
5. Separate conformational or binding states¶
Run refine3D_states from the clean single-state project:
simple_exec prg=refine3D_states \
projfile=<SINGLE_STATE_SOLVE3D_PROJECT.simple> \
nstates=<NUMBER_OF_STATES> pose_policy=global \
pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
Do not pass vol1 through volN to this program. It derives same-lineage
states from the consensus project. For a state-0/1 input, flex_pca
initializes the states before their joint refinement; it needs
nstates >= 3, and the run continues with the number of states flex
delivers.
The pose policy controls how much orientation can change while states compete:
globalis the default and performs a full orientation search.localpermits a limited change around each consensus direction.
Start with global unless the consensus orientations are already trusted and
the scientific question specifically calls for more constrained
classification. Fixed-pose classification is flex_pca itself.
Checkpoint: useful states should contain enough particles, retain broad view coverage, show interpretable structural differences, and remain similar when the analysis is repeated or the requested state count is changed. Treat very small, poorly oriented, or irreproducible states as suspect.
Optional: find the states on class averages first¶
This route is experimental; its program is visible at the Developer level.
Instead of letting flex_pca initialize the states from the particles, the
states can be found on class averages and handed to the particles. First,
split the 2D classes of the consensus project into sub-classes:
simple_exec prg=cls_expansion \
projfile=<SINGLE_STATE_SOLVE3D_PROJECT.simple> \
ncls=<TOTAL_SUBCLASSES> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
cls_expansion needs the 2D classification of the particles in the project.
ncls is the total number of sub-classes, at least the number of classes. The
classes are grouped by class-average correlation (nclust, 20 groups by
default), so classes of one view share that view's budget; a group's share grows
with the square root of its population, and inside a group the classes share in
proportion to their populations. A class holds at most pop/minpop sub-classes
(minpop=25 by default) and is kept whole below 2*minpop particles (or below
the covariance model's floor of 3*(neigs+1), 51 by default).
The sub-class averages are made from the particles, not from the model: each
particle's latent and its uncertainty
weigh the other particles, so every particle has a pre-image (a weighted
average of the particles that look like it), and the latent rank and the
bandwidth are chosen by predicting held-out Fourier coefficients. The
sub-classes are the pre-images of as many particles as the class's budget,
chosen to cover the latent distribution, preferring pre-images of at least
minpop effective particles. Their even/odd halves are weighted averages of
disjoint particles, so their FRCs and the resolution estimates read from them
are their own. A class with no reproducible variation still delivers its
budget, as near copies of its mean: in the project, neff is the effective
population and sep the cross-validation z-score of the parent (below about 3:
no variation the held-out data confirm), and the log gives the largest noise
overlap between two sub-classes of a class.
Like every program here it writes its result as a new project in its own run
directory. Then sort the sub-class averages of that project into states:
simple_exec prg=refine3D_states_cavgs \
projfile=<CLS_EXPANSION_PROJECT.simple> \
nstates=<NUMBER_OF_STATES> pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
It needs at least 100 selected sub-class averages, nstates >= 3 and the
consensus map of the project. It writes a state per sub-class average and
hands the states to the particles; particles of sub-classes that end without a
state are set to state 0. Its state maps, rec_final_stateNN.mrc, are
class-average maps, registered as vol_cavg. If it delivered two or more
states, run refine3D_states as shown above on its output project,
<REFINE3D_STATES_CAVGS_PROJECT.simple>, but without nstates: it finds the
handed-back labels and refines them without flex_pca.
6. Extract and refine each useful state¶
For every state worth retaining, run a separate selection from the original
refine3D_states project:
simple_exec prg=selection \
projfile=<REFINE3D_STATES_PROJECT.simple> \
oritype=ptcl3D state=<STATE_NUMBER> prune=yes
Then refine that particle group as a single structure:
simple_exec prg=refine3D_auto \
projfile=<SELECTED_STATE_PROJECT.simple> \
vol1=<REFINE3D_STATES_DIRECTORY/recvol_stateNN.mrc> \
pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
Replace NN with the zero-padded original state number: state 1 is 01,
state 2 is 02, and so on. Use the map produced by the same
refine3D_states run as the selected particles. Passing vol1 explicitly
is important and guarantees that refine3D_auto starts from the matching
state map. Because this reference volume and these poses have the same SIMPLE
lineage, leave the advanced ref_pose_init parameter at its default none.
This refinement includes a methodology similar to what is usually referred to
as auto- or envelope masking. SIMPLE derives a density envelope internally and
suppresses low-density solvent outside that envelope when preparing matching
references and filtering the reconstruction; no input mask is required. This
procedure can be switched off by setting the optional parameter automsk=no.
Do not refine several states in one joint refinement. Each selected state gets
its own selection project, refine3D_auto run, and validation record.
Alternative: refine every state with one command (state sweep)¶
When every state with particles is worth refining, one command refines them all, one after another:
simple_exec prg=refine3D_auto \
projfile=<REFINE3D_STATES_PROJECT.simple> \
pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
Without state=, refine3D_auto refines each state of the project as the
ordinary single-state refinement above would. Each state runs in its own
numbered directory inside the run's directory and starts from that state's map
in the project, so vol1 is neither needed nor accepted. The command then
merges every state's refined poses and its map and FSC into a copy of the
project in the run's directory. It never writes the project you gave it, and it
changes no state labels.
The file refine3D_state_sweep.txt in the run's directory lists each state with
its directory and work project. The merged project can be continued as a whole:
refine3D_local without state= on it refines every state locally in the same
way. Every particle must already have a half (it has after refine3D_states). A
project without halves is refused before anything is written.
To refine only some states, use the selection route above, or give state= to
refine one state.
7. Optional continuous-heterogeneity analysis¶
Discrete states do not always describe a flexible complex well. After a good
consensus or state-specific refinement, flex_pca can reveal reproducible
low-dimensional variability and reconstruct representative volumes:
simple_exec prg=flex_pca \
projfile=<REFINED_PROJECT.simple> \
neigs=10 npreimages=16 mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
The default neigs=10 requests ten covariance components and
npreimages=16 sets an upper limit of sixteen representative state volumes;
the recovered number can be smaller. The project consensus map is used when
vol1 is omitted. Begin with the defaults rather than requesting many
components: excess components tend to describe fitting noise and make the
state analysis less stable.
The output project holds the result in two forms. Each particle gets a hard
state label in ptcl3D; particles assigned to no state get label 0. Each
particle also gets a weight for every state. These weights form the project's
state weight set, registered in the project's out segment (imgkind
state_weights). Unless rec_states=no is given, each state's map,
recvol_stateNN.mrc, and its Fourier shell correlation (FSC) are registered
as ordinary vol and fsc entries, like the maps of any multi-state run. The
state 1 map then takes the place of the consensus map in the output project.
To run flex_pca again, start from its input project or pass vol1.
Interpret a motion only when it is supported by reproducible components, adequate particles and views across the trajectory, and coherent changes in the reconstructed volumes. A smooth-looking sequence by itself is not proof of continuous biology.
Optional: refine one state with its flex_pca weights¶
A state found by flex_pca can be refined on its own, with every particle
weighted by its state weight:
simple_exec prg=refine3D_auto \
projfile=<FLEX_PCA_PROJECT.simple> \
state=<STATE_NUMBER> m_estimator=flex \
pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
With state=, refine3D_auto copies the project into its new execution
directory as a work project, refine3D_auto_stateNN.simple, that holds the
chosen state alone. It refines that copy and does not write the flex_pca
project. The copy keeps the state's members: a particle is a member of the states that
carry 95% of its squared weights, so a weight that adds little is dropped and
that particle is not aligned for the state.
Every reconstruction weighs each particle by its weight. The weights stay as
flex_pca computed them, and alignment and particle sampling do not use them.
The state's map from the flex_pca project is the starting reference, so
vol1 is not needed. The run needs its own directory: keep the default
mkdir=yes. Run one command per state, each from the flex_pca project, or
leave out state= to refine every state of the weight set in turn: the state
sweep of section 6 with m_estimator=flex. It merges the refined states into a
copy of the flex_pca project and keeps its weight set.
The flex_pca step can also run inside the sweep. On a single-state project
(for example the output of solve3D or refine3D_auto), give the number of
states instead of state=:
simple_exec prg=refine3D_auto \
projfile=<CONSENSUS_PROJECT.simple> \
nstates=<3_OR_MORE> m_estimator=flex \
pgrp=<POINT_GROUP> mskdiam=<MASK_DIAMETER_A> \
nparts=<PARTITIONS> nthr=<THREADS>
flex_pca divides the copy of the project in the sweep's directory into at most
that many states (a state with too few particles is dropped) and publishes their
soft weights; then every state is refined with its weights as above.
min_state_frac is refused here: its population floor assigns every particle to
one state, which would turn the weighted refinement into a hard-label one. Each
state's kernel covers at least min_neff effective particles (default 2000): on a
data set of a few thousand particles lower it (to a few percent of the particles),
or the kernels span the whole set and every particle weighs about the same in
every state. flex_pca
starts from the project's consensus map. refine3D_local takes the same keys
for a local refinement of the states: use it when the large variations are
already resolved and the states differ in details. A project that already holds a
state weight set is refused with nstates: leave it out to refine the states of
the earlier flex_pca run.
For comparison, run the same command without m_estimator=flex. The default
m_estimator=no with state= refines only the particles labelled with the
state. reconstruct3D reads the weights in the same way: with
m_estimator=flex it reconstructs every state from the weight set, and adding
state=<STATE_NUMBER> reconstructs that state alone.
This weighted route is new. It has been validated on simulated data. Whether the weights give better maps than the hard labels on real data has not been tested yet, so compare the two refinements of a state before relying on the weighted one.
8. A minimal command worksheet¶
Fill this in before starting and update it after every accepted run:
Input picked/stream project:
Mask diameter (A):
Point group (use c1 if none):
nparts:
nthr:
Accepted sieving project (or STREAM):
Accepted solve2D project, run 1:
Accepted solve2D project, run 2:
Initial solve3D cleanup project:
State retained from cleanup, or states merged:
Merged-state selection project, if applicable:
State-continuation or single-state consensus project:
refine3D_states project:
State | selected project | matching recvol_stateNN.mrc | refine3D_auto project
------|------------------|----------------------------|----------------------
| | |
9. Common mistakes¶
- Using the wrong project: always copy the exact output project path from the accepted previous run.
- Running offline sieving after SIMPLE stream: this repeats a cleanup stage unnecessarily and can remove useful particles.
- Treating cleanup states as final biology: the initial three-state
solve3Dis primarily for separating useful particles from junk. - Repeating solve3D unnecessarily: when retaining one cleanup state, use
solve3D state=N; do not start over or also supplyvol1. - Skipping the clean consensus: whether continued from one state or rebuilt
after merging states,
refine3D_statesneeds a common map and pose scaffold. - Selecting from an already selected project: make every independent state extraction from the original multi-state project.
- Using the wrong map for a selected state: pass the matching
recvol_stateNN.mrcexplicitly torefine3D_auto. - Over-interpreting tiny states or PCA components: require particle support, view coverage, map quality, and repeatability.
- Oversubscribing the machine: total resource use can multiply across chunks, partitions, and threads.
Appendix: training a data-set-specific 2D rejection model¶
This optional route is useful when many comparable solve2D_chunks
outputs must be screened consistently.
A. Manually label representative projects¶
Review the final classes in several representative chunk projects. Mark good classes as state 1 and rejected classes as state 0. Both good and bad examples must be present, and the labels—not model predictions—are the training truth.
B. Export training features¶
For each reviewed project, run:
simple_exec prg=model_cavgs_rejection \
quality_mode=analyze quality_context=chunk \
projfile=<MANUALLY_LABELLED_PROJECT.simple> \
mskdiam=<MASK_DIAMETER_A>
This writes cavgs_quality_training.txt without changing the selection. Build
a plain-text SIMPLE file table containing one absolute training-file path per
line, for example:
/data/run_01/cavgs_quality_training.txt
/data/run_02/cavgs_quality_training.txt
/data/run_03/cavgs_quality_training.txt
All files in one training set must use the same quality context.
C. Learn the model¶
simple_exec prg=model_cavgs_rejection \
quality_mode=learn \
filetab=<TRAINING_FILETAB.txt> \
fname=<DATASET_QUALITY_MODEL.txt>
Keep the model together with a note identifying the data set, training projects, manual reviewer, and date. A model trained for one specimen or imaging regime should not silently become a universal model.
D. Apply the learned model¶
simple_exec prg=model_cavgs_rejection \
quality_mode=apply infile=<DATASET_QUALITY_MODEL.txt> \
projfile=<SOLVE2D_CHUNK_PROJECT.simple> \
mskdiam=<MASK_DIAMETER_A> prune=yes
Inspect the accepted and rejected class-average reports before using the pruned output. If the model makes systematic mistakes, correct the manual labels, expand the representative training set, retrain, and record the new model separately.