Difference between revisions of "Getting a Structure from Multiple Tomograms of HIV Capsids (I2PC – Instruct Course on Electron Tomography and Subtomogram Averaging 2025)"

From Dynamo
Jump to navigation Jump to search
(Created page with "Category:WalkthroughsSpecific This tutorial shows how to manually pick particles in a tomogram, extract them, align and classify them. This tutorial is a shortened versio...")
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:WalkthroughsSpecific]]
 
[[Category:WalkthroughsSpecific]]
  
This tutorial shows how to manually pick particles in a tomogram, extract them, align and classify them. This tutorial is a shortened version of the original [[Starters_guide | starters guide]] that was adapted for the use in ''Dynamo'' workshops.
+
In this walkthrough you will get familiar with managing multiple tomograms through the ''Dynamo'' catalogue and developing strategies for alignment projects to reach a reasonable structure from a set of tomograms. You will make use of the knowledge that you acquired during the workshop and apply it to a more realistic case. It is recommended to get familiar with the [[ Complete walkthrough on FHV virus (I2PC – Instruct Course on Electron Tomography and Subtomogram Averaging 2025) | advanced starters guide]] and the [[Walkthrough for lattices on vesicles (I2PC – Instruct Course on Electron Tomography and Subtomogram Averaging 2025)| walkthrough for lattices on vesicles]] before starting this walkthrough.  
  
=Manual particle picking and ''Dynamo'' catalogues=
+
== Data ==
The ''Dynamo'' catalogues are databases that manage tomograms and link the tomographic data to the extracted particles. Start the catalogue manager by typing the command:
+
We prepared a set of 6 tomograms, each containing one Immature HIV-1 virus like particle (VLP) with a layer formed by a lattice of capsid proteins. The capsid proteins have a C6 symmetry, a diameter of roughly 15nm and a molecular weight of about 150kDa. The pixelsize of the tomograms is 2.7 angstrom. In this workshop, the data has already been downloaded from {{Template:DownloadLinkVLPs}} and can be found in
  
<tt>dcm</tt>
+
<tt> /home/student/data/VirusLikeParticles </tt>  
After the catalogue manager opens, we create 3 synthetic tomograms that include our particles (thermosomes) in the following way:
 
  
[[File:StartersGuideFigure1.png|thumb|center|600px| Figure 1: creating a set of synthetic tomograms with ''Dynamo'' Catalogue Manager]]
+
The tomograms are part of the data that was used in the publication ''An atomic model of HIV-1 capsid-SP1 reveals structures regulating assembly and maturation'' by  Schur FK, Obr M, Hagen WJ, Wan W, Jakobi AJ, Kirkpatrick JM, Sachse C, Kräusslich HG and Briggs JA. (2016). The full dataset can be found on the Electron Microscopy Public Image Archive (EMPIAR) under [https://www.ebi.ac.uk/pdbe/emdb/empiar/entry/10164/ EMPIAR-10164]. The 6 tomograms were extracted from the tilt series TS_03 and TS_43.
  
You can see the list of your tomograms and their metadata in a table in the bottom of your catalogue manager. When workin on your own projects, you can add tomograms to the catalogue by ''Catalogue -> Browse for new volume''. The tomograms are situated in the directory <tt>testCatalogue</tt>. They contain a small amount of noise and a missing wedge associated to rotation around Y-axis. We added the information about location of the particles in the tomograms in an additional catalogue called <tt>testCatalogue_withmodels</tt>. If needed, it can be opened from the current folder with ''Catalogue -> look for local catalogues'' in the catalogue manager window.
+
== Goal==
 +
From the data given you should be able to get a final average in which you start seeing hints of alpha helices, i.e., it should be possible to reach a resolution close to roughly 10 angstroms.  
  
==Viewing tomograms==
+
== Walkthrough  ==
Select the first tomogram in the list and go to ''View volume>Full tomogram file in tomoslice''.  
+
=== Set up a catalogue ===
 +
Create a new [[catalogue|catalogue]]
 +
<tt>dcm -create catVLP</tt>
 +
and open it in the catalogue manager
 +
<tt>dcm catVLP</tt>
 +
You can add each volume manually to the catalogue under ''Catalogue -> Browse for new volume'' or you can make use of a [[volume list file|volume file]] and add all tomograms at once under ''Catalogue -> Input list of tomograms -> Browse for text file (.vll file)''. The volume file should be created beforehand by opening a blank text file named for example <code>VLPtomograms.vll</code> and copy the paths of all tomograms into it:
 +
<nowiki>vlp_1.mrc
 +
vlp_2.mrc
 +
vlp_3.mrc
 +
vlp_4.mrc
 +
vlp_5.mrc
 +
vlp_6.mrc</nowiki>
  
[[ File:StartersSelectTomoSliceInCatalogue.png |thumb| center |600px| Figure 2: Selecting a volume in the catalogue manager to be inspected in <tt>dpreview</tt>]]
+
In case you imported the tomograms using a volume file you have to click the button ''list volumes'' to refresh the tomogram list in the catalogue manager. Now you should see the 6 tomograms in the catalogue manager. [[Prebinned_tomograms|Prebin]] the tomograms once (1x) under ''Catalogue -> Create binned versions -> with factor 1''. You can now look at single tomograms in [[dtmslice|tomoslice]] by selecting a tomogram of choice in the catalogue manager and then go under ''View volume -> Load full prebinned Volume [if available] -> open in tomoslice''. If needed, adjust the lowpass level and contrast in tomoslice to improve the depiction.
  
The volume browser tomoslicer loads the entire tomograms into memory and allows making annotations to the regions of interest. The tomograms in this tutorial are small, and you can load them directly into memory. For real life tomograms, bear in mind that you will need to [[Prebinned tomograms| prebin]] the files before loading them into memory. Tomoslice has a simple set of controls and is suitable for visualization tasks that require oblique sections through the tomogram. It uses the same tool as other ''Dynamo'' browsers to keep track of your annotations: a pool of models. You might need to adjust the contrast (blue arrow). To move through the tomogram slices, you can either use the mouse wheel, click and drag the tomogram slice up and down (orange arrows), or move the position control left and right (orange box).
+
=== Annotate tomograms ===
 +
To know where we want to later extract the subvolumes we have to first annotate the surfaces of the VLPs inside the tomograms. We do this by opening a tomogram inside tomoslice where a so called dipole Set model is defined. How to do that is described in detail in the section ''DipoleSet models'', ''Corrections during picking'' and ''Corrections after picking'' of the [[Walkthrough_for_lattices_on_vesicles | walkthrough for lattices on vesicles]]. A new dipole set model has to be made for each tomogram. Save each model before closing tomoslice and when opening a new tomogram in tomoslice select ''Delete from memory'' if asked. In case you see markers of the previously defined dipole set inside the newly opened tomogram make sure the model pool is empty and click on ''reset scene'' before defining the new dipole set. Once you went through all tomograms click on the button ''list volumes'' inside the catalogue manager to refresh the list of tomograms. In the column ''model files'' of the tomogram list of the catalogue manager you should now see that you have one defined model per tomogram.
  
 +
=== Define crop points ===
 +
To extract subvolumes (crop particles) we need to first define the crop points on the surface of the VLPs using the previously defined models. The crop points are then stored in a table. This is all done with the following script which is an extended version of the one found in the [[Walkthrough_for_lattices_on_vesicles | walkthrough for lattices on vesicles]]. Note that we [[Seed_oversampling|oversample]] the VLPs, i.e., we define enough crop points such that every protein has the chance to end up in at least one subvolume. We will take care of proteins that end up in more than subvolume in a later step. Note that this script assumes that there are exactly 6 tomograms with only one model for each tomogram. In cases where a different number of tomograms or models is used, the script has to be adapted accordingly.
  
[[ File:StartersTomoSlice.png |thumb| center |600px|]]
+
<nowiki>% read dipole from catalogue into workspace
 +
dcmodels catVLP -tc dipoleSet -ws o -gm 1
  
==Picking and extracting particles in tomograms==
+
c=1; % counter for table
Coordinates of picked particles are represented by data types called models. In the tomoslicer window go to ''Model Pool -> Create new model in pool (choose type) -> General''. This is the simplest type of [[model]] where each clicked/model point corresponds to a single isolated particle. Now you can navigate up and down the tomogram, place the mouse on the center of a particle and press the [c] key on your keyboard to add a new model point. (Note the ''Help -> all hot keys'' options that lists the different the actions of the different keystrokes). Backspace button deletes the last clicked point (you can also use the right-click to delete single points).
+
for tomo = 1:6 % loop over tomograms
 +
    ds = o.models{tomo};                  % read models
 +
    NDipoles = length(ds.dipoles);
 +
    for i=1:NDipoles                      % loop over models (in our case just one per tomogram)
 +
        v = dmodels.vesicle();            % create empty vesicle model
 +
        v.center = ds.dipoles{i}.center;  % add center from dipole to vesicle model
 +
        v.radius = norm( ds.dipoles{i}.north - ds.dipoles{i}.center); % add radius
 +
        v.separation = 60;                % separation of crop points (in px)
 +
        v.crop_distance_from_surface =0;
 +
        v.updateCrop();                  % update vesicle model
  
[[File:StartersGuideFigure4.png|thumb|center|600px| Generating a new model]]
+
        tv{c} = v.grepTable(); % create crop table from using vesicle model
 +
        tv{c}(:,22) = i;      % add model number to table
 +
        tv{c}(:,20) = tomo;    % add tomogram number to table
 +
        c=c+1;
 +
    end
 +
end</nowiki>
  
After you are done clicking about 10 particles click on ''Active model > Update Crop points'' in the tomoslice window.
 

 
  
[[File:StartersGuideUpdate.png|thumb|center|600px|]]
+
In the '''standalone version''' you need to proceed as follows:
  
Save the model into the catalogue by ''Active model -> Save active model into catalogue (disk)'' and close the slicer window.
+
1.) Open a text file named <code>commands.m</code> and copy the following into the file (avoid commenting with % or #):
  
[[File:StartersGuideFigure6.png|thumb|center|600px| ]]
+
<nowiki>o=dcmodels('catVLP','tc','dipoleSet','gm',1);
 +
c=1;
 +
for tomo = 1:6
 +
    ds = dread(o{tomo});
 +
    NDipoles = length(ds.dipoles);
 +
    for i=1:NDipoles
 +
        v = dmodels.vesicle();
 +
        v.center = ds.dipoles{i}.center;
 +
        v.radius = norm( ds.dipoles{i}.north - ds.dipoles{i}.center);
 +
        v.separation = 60;
 +
        v.crop_distance_from_surface =0;
 +
        v.updateCrop();
 +
        tv{c} = v.grepTable();
 +
        tv{c}(:,22) = i;
 +
        tv{c}(:,20) = tomo;
 +
        c=c+1;
 +
        disp(sprintf('Dipole %d will provide %d crop points',i,size(v.crop_points,2)));
 +
    end
 +
end
 +
dwrite(tv,'cellOfTables.mat');</nowiki>
  
Pick particles for tomograms 2 and 3. In total, there are around 30-40 particles in the generated dataset. When you open a new tomogram, make sure that you delete the pool of models from memory when asked. This will have no effect onto the models stored in disk, and it is necessary in order to ensure that you are not mixing models from different tomograms.
+
2.) Execute the text file in a system shell or in the ''Dynamo'' console:
 +
 +
<tt>dynamo commands.m</tt>
 +
 
 +
3.) When you are back in the ''Dynamo'' console, you can load the results from the script into the workspace with
 +
<tt>tv = dread('cellOfTables.mat'); </tt>
 +
 
 +
Type ''whos'' to display the actual matlab workspace and to check if the variable ''tv'' was loaded correctly.
  
==An alternate visualization: orthogonal projections==
+
=== Write table with crop points ===
  
Clicking in the menu on ''Projection -> project full shown fragment along z'' (still in dtmslice) and you will get a screen where the x-y projection of the tomogram is shown. Use the secondary click on it to launch the orthogonal views of x-z and y-z planes that traverse that point. These views can also be used to click particles, in case the standard view is not sufficient.
+
The tables beloning to each dipole model are stored in the cell array ''tv''. To create one single table containing all crop points we merge all tables into one with the command
  
{|style="margin: 0 auto;"
+
<tt>tAll = dynamo_table_merge(tv,'linear_tags',1); </tt>
| [[File:orthoPickMain.png|thumb|upright|250px| click on the main projection determines two orthogonal slices]]
 
| [[File:orthoPickX.png|thumb|upright|250px| Slice xz ]]
 
| [[File:orthoPickY.png|thumb|upright|250px| Slice xy]]
 
|}
 
  
=Extracting particles from tomograms=
+
and visualize the table to see the crop points and their orientations (when visualizing actual results of an alignment project use option '' 'corrected_oriented_positions'' ' instead of the one shown here).
In the catalogue manager window select the rows for tomograms from which you want to extract particles from. You can either select them one by one with a mouse click and holding the [ctrl] key or by clicking the ''Select all'' button. Then, go to ''Crop Particles -> Open Volume List Manager''.
+
<tt>dtplot(tAll,'pf','oriented_positions'); axis equal</tt>
  
[[File:StartersGuideopenVolumeList.png|thumb|center|600px|]]
+
You should get something like:
  
A new window opens with all the models in the catalogue listed in the bottom. Pick (by checking boxes) the models of type ''general'' that you have just clicked. Click ''Create list'' and then ''Crop particle''.
+
[[File:Result_table_vlp.png|thumb|center|400px| Crop points in table.]]
  
[[File:StartersGuideSelectModels.png|thumb|center|600px|]]
 
  
In the new window, change the data name to something meaningful, such as ''thermosomeParticles'', change the sidelength from 32 to 48 and click start cropping.
+
=== Extract subvolumes ===
  
[[File:StartersGuideCrop.png|thumb|center|600px|]]
+
Before extracting the subvolumes (cropping particles) using the previously generated table we have to define a so called [[Tomogram-table map file|tomogram table map file]] which links the tomogram identification number in column 20 of the previously created table to an actual tomogram on the disk. Create a file named <code>VLPtomograms.doc</code> and copy the tomogram numbers and full paths of the tomograms into it:
 +
<nowiki>1 vlp_1.mrc
 +
2 vlp_2.mrc
 +
3 vlp_3.mrc
 +
4 vlp_4.mrc
 +
5 vlp_5.mrc
 +
6 vlp_6.mrc</nowiki>
  
After cropping is done, explore your cropped particles by clicking ''ddbrowse'' (in the window above). A new window opens where you can simply click on ''show''.
+
Define a destination for the cropped particles:
 +
<tt>targetFolder = './particlesSize128';</tt>
  
[[File:StartersGuideShow.png|thumb|center|500px|]]
+
Now we can crop the particles with sidelength 128 pixels from the tomograms using the table previously defined.
 +
<tt>dtcrop('VLPtomograms.doc',tAll,targetFolder,128);</tt>
  
You see a 2D representation (projections) of all cropped 3D subtomograms. Make sure your particles are well centered and fit the box.
+
The cropping on one core should not take longer than 5 minutes.  
  
[[File:StartersGuideParticles.png|thumb|center|500px|]]
+
We create a plain average of all cropped particles to asses the quality of the cropped particles. First we read the table of the cropped particles:
  
We also introduce the concept of the ''dynamo'' table: The information about each particle is stored in tables. Each particle has an entry in the table that contains shifts and rotations to describe its orientation (by default these values are initialized as zeroes). It also contains the particle ID (tag), the orientation of the missing wedge and others. For full info type the command <tt>dthelp</tt>. The ''Dynamo'' catalogue generates an initial table during particle extraction. Its location is in <tt>particles/crop.tbl </tt>.
+
<tt>finalTable = dread([targetFolder '/crop.tbl']);</tt>
  
=Subtomogram alignment and averaging=
+
We can also visualise the particles:
  
==Initial reference generation==
+
<tt>dslices(targetFolder,'projy','*','t',finalTable,'align',1,'tag',1:10:500,'labels','on');</tt>
We want to align the extracted tomograms to a common reference. For that, we need an initial reference (which will later be refined during the iterative alignment). Here, we create such an initial reference by manually align a few particles and average them. We use the command <tt>dgallery</tt> to generate initial orientations for some of our particles that will be used to generate the initial reference. Close all open ''Dynamo'' windows and type into the ''Dynamo'' command line:
 
  
<tt>dgallery('data','thermosomeParticles.Data');</tt>
+
Then we form the average
  
The gallery opens. Click on ''load'' to load all aprticles in memory, move the ''shown'' bar to display the particles and use the x-, y- and z-buttons to see different views:
+
<tt>oa = daverage(targetFolder,'t',finalTable,'fc',1);</tt>
  
[[File:StartersGuideGallery.png|thumb|center|600px|]]
+
and inspect the average with
 +
<tt>dview(oa.average)</tt>
  
To manually align the particles, do the following for about 10 particles:
+
You should see a faint and noisy curvature of a thick membrane-like structure in the X and Y view.
# Place the mouse over the particle center and press the key [c] (this centers the particle).
 
# Place the mouse over its top (or bottom) part and press the key [n] (this aligns the particle).
 
# Click on the particle to make sure its number turns from red to blue (blue means it is selected for further processing). To de-select a particle use the right-click.
 
Change between the x-, y- and z-views to correct the orientations if necessary. This is just done to create an initial reference, so orientations don't need to be very exact.
 
  
[[File:StartersGuideGallery2.png|thumb|center|500px|]]
+
[[File:VLP_raw128_x.png|thumb|center|170px| Average of cropped particles (X view).]]
  
Save the selected tags and corresponding table by clicking ''quick save'' button in the top right. It saves a quickbuffer.tbl and quickbuffer.tags to the hard drive that will be used later. To generate the average you need to apply the table on the particles. For this click the ''average'' button in the Particle selection field.
+
We will use this average as a first reference (template) in the next alignment project. We therefore save the average with
 +
<tt>dwrite(oa.average,[targetFolder '/template.em']);</tt>
  
[[File:StartersGuideGallery3.png|thumb|center|500px|]]
+
Hint: When dealing with preferred orientations, randomizing the azimuth of the particles bevore averaging can help (in this tutorial this is not needed):
  
It opens a new window with a lot of controls. Click ''compute average'' in the bottom of the window. Then, right-lick on the output filename and click ''ok'' in the next window to see the result. If you are not satisfied with the result, close the window and refine your manual alignment and/or add more particles to the average.
+
<tt>tRandAz = dynamo_table_randomize_azimuth(t);</tt>
  
[[File:StartersGuideGallery4.png|thumb|center|600px|]]
+
=== First alignment project ===
 +
Now we create our first [[alignment project | alignment project]] through the command line in a similar way as described in detail in the [[Walkthrough_for_lattices_on_vesicles | walkthrough for lattices on vesicles]]. First we define a project name
 +
<tt>pr = 'aliVLP';</tt>
  
[[File:StartersGuideGallery5.png|thumb|center|500px|]]
+
Then we create the alignment project with the particles, template and table that we defined before. The masks are set to default.
  
==Alignment projects==
+
<tt>dcp.new(pr,'d',targetFolder,'t',[targetFolder '/crop.tbl'],'template',[targetFolder '/template.em'],'masks','default','show',0);</tt>
Iterative alignment of subtomograms to their average is performed by ''dynamo'' projects that you can run in various high-performance computational environments. To run an alignment project you need the particles, an initial reference and a table. All of these files we generated before. Start the alignment project GUI by typing
 
  
  <tt> dcp</tt>
+
Next we set up the numerical parameters for the project and the computing environment (type ''dvhelp'' in the console for an overview of all parameters). We use 2x binned particles and a rather coarse angular search. The shift limits are very generous in order to make sure all particles have the chance to 'see' each other.
  
In thw new window, do the following:
+
<nowiki>dvput(pr,'ite_r1',4);
# Add the project name ''drun1'', press the ''enter'' key and select ''create a new project'' in the pop-up window.
+
dvput(pr,'dim_r1',32);
# Click on ''particles'' and provide the particle folder name ''thermosomeParticles.Data''. Click ok.
+
dvput(pr,'cr_r1',40);
# Click on ''table'' and provide the table name ''thermosomeParticles.Data/crop.tbl''. Click ok.
+
dvput(pr,'cs_r1',20);
# Click on ''template'' and provide the initial reference name ''my_average.em''. Click ok.
+
dvput(pr,'ir_r1',360);
# Click on ''masks'' and simply click on ''use default masks''. Click ok. You could also specify the semi-axis of the ellipsoid masks or go to “Mask editor” to make more sophisticated masks. Note that ''Dynamo'' by default uses Rossman correlation which eliminates the artefacts associated with hard (non-soft) mask.
+
dvput(pr,'is_r1',40);
 +
dvput(pr,'rf_r1',4);
 +
dvput(pr,'rff_r1',2);
 +
dvput(pr,'lim_r1',[40,40,40]);
 +
dvput(pr,'limm_r1',1);
 +
dvput(pr,'dst','standalone_gpu','cores',1,'mwa',2);</nowiki>
  
[[File:StartersGuideAli1.png|thumb|center|500px|]]
+
Everything can of course also be set up through the alignment project GUI. The numerical parameters would correspond to:
  
Click on ''numerical parameters'' to set all parameters and details about the different iterations of the alignment project. You can select any parameter in the table with a mouse and click the ''?'' button on the top right of the parameter window to see a description of the parameters. The most important parameters to consider are:
+
[[File:VLP_first_parameters.png|thumb|center|400px| Alignment parameters for first alignment project.]]
  
* ''Number of iterations'': Make 3 rounds with 2 iterations each. The first round will be a global search with a coarse angular step and the following rounds will be used for refinement.
 
* ''Angular search ranges'': Cone aperture is the scan range for the first two Euler angles around the initial orientation defined in the table. 360 degrees is the full scan range. Azimuth rotation range defines the rotation range around the new vertical axis of the particle.
 
* ''High- and lowpass values'': Fourier voxels to limit the used frequency range.
 
*''Particle dimensions'': Defined as sidelength of your subvolume. If you put a lower value, the particles will be downsampled for the particular round. This will speed up the process.
 
* ''Refine'': After each angular scan, the search step is reduced by the ''refine factor''. This is repeated ''refine'' times. I.e., if your cone sampling is 10 degrees, ''refine'' is 3 and ''refine factor'' is 2, then 10, 5, 2.5 and 1.25 degrees will be sampled. This is the optimization of angular search space.
 
*''Shift limits'': Limits the translation of particles from the center of the box (if shifts limiting way is 1) or from the previously estimated center (if shifts limiting way is 2). The previous estimates for the shifts and rotations are taken from input tables and are updated at the end of each iteration.
 
*''Symmetry'': If you know the symmetry of your protein it will speed up the convergence and result in higher resolution.
 
  
Set the parameters as follows and click ''ok'':
+
Check, unfold and run the project through the alignment project GUI or through the command line:
  
[[File:StartersGuideFigure10.png|thumb|center|600px|]]
+
<nowiki>dvcheck aliVLP
 +
dvunfold aliVLP
 +
dvrun aliVLP</nowiki>
  
Click on ''Computing environment'' and select your computing environment (choose ''standalone'' if you are working on the standalone version during a workshop). Set ''CPU cores'' and ''parallelize averaging step'' to the maximum available (e.g., 4). Leave the rest as it is and click ''ok''. In the alignment GUI click ''check'' and ''unfold''. To run the project
+
On one GPU (and 2 cores for averaging) the alignment project should not take longer than half an hour. Check the status of the alignment project with
  
* in a Matlab session, you can just click on “run”.  
+
  <tt>dvstatus aliVLP</tt>
* in a standalone project it is more convenient to open a new terminal, load ''Dynamo'' (but do not run it) and run the project by typing <tt>./drun1.exe</tt>.
 
  
While the project is running, open another Matlab window (or in standalone open another terminal with ''Dynamo'' running) and you can monitor the progress of the alignment project by typing:
+
You can also see the average of the last computed iteration in ''dmapview'' with the command. If needed, adjust the lowpass and contrast to improve the depiction.
  
  <tt>dvstatus drun1</tt>
+
  <tt>dpkdev.legacy.dynamo_mapview('aliVLP:a')</tt>
  
While the project is running, you can look at projections of the intermediate results by typing:
+
=== Recenter and recrop ===
 +
After the alignment project finished successfully we can inspect the last computed average with the same command introduced before:
  
  <tt>ddb drun1:a:ite=* -j c10</tt>
+
  <tt>dpkdev.legacy.dynamo_mapview('aliVLP:a')</tt>
  
or at the latest average by typing:
+
The command can be extended to see the averages of all iterations including the starting reference. Once in ''dmapview'', press the button ''norm'' to properly compare the averages.
  
  <tt>ddb drun1:a -v </tt>
+
<tt>dpkdev.legacy.dynamo_mapview('aliVLP:a:ite=0:last')</tt>
   
+
 
The final result should look similar to:
+
In the last average, you should already start to see a hexagonal lattice. We now want to make sure that the center of one C6 subunit of the lattice coincides with the center of the subvolume and that the subunits symmetry axis is parallel to the Z axis of the subvolume. This will allow us to later recrop the subvolumes with a smaller box size and to choose finer alignment parameters in the next alignment project. The recentering and realigning can be done in two steps. First, we subbox the particles using a new, manually defined box center and recrop the particles with a smaller boxsize. Second, we align the symmetry axis using a synthetic template. Both procedures are described in detail in the [[Advanced_starters_guide | advanced starters guide]] in the section ''Aligning the axis of symmetry'' and ''Subboxing '' and are now applied here.
 +
 
 +
====Step 1: Subboxing====
 +
 
 +
Open the last computed average in ''dmapview'' as previously described. Activate the radio buttons for the ''Center/North'' tools under ''Clicks''. You can now click anywhere on the average and see the corresponding coordinates. Find the coordinates of the center of one subunit of the lattice. Switch between X,Y and Z view to make sure the center is correct. In our case we found the center of a subunit at [88,75,72]. For you these coordinates might be different.
 +
 
 +
[[File:VLP_center_xy.jpg|thumb|center|600px| Finding the coordinates of the center of a lattice subunit.]]
 +
 
 +
Copy the found coordinates of the center of the subunit into the first vector of the command below. To compute the vector from the center of the subvolume to the center of a subunit we need to subtract the coordinates of the center of the subvolume. The [[Volume_center|center of a subvolume]] with a sidelength of 128 pixels is defined as [65,65,65].
 +
 
 +
<tt>rSubunitFromCenter = [88,75,72] - [65,65,65];</tt>
 +
 
 +
This vector will now be used to shift (or recenter) all particles in the table. Read the last computed table of the alignment project
 +
 
 +
  <tt>ddb aliVLP:rt -ws t</tt>
 +
 
 +
and apply the new center to the table
 +
 
 +
<tt>ts = dynamo_subboxing_table(t,rSubunitFromCenter);</tt>
 +
 
 +
The table now contains the coordinates of the recentered particles. We use this new table to recrop the particles. We first define a new target folder:
 +
 
 +
<tt>targetFolder = './particlesSize96r';</tt>
 +
 
 +
Then we recrop the new particles. Since the particles are centered now, we can also choose a smaller boxsize of 96 pixels. This will save space and speed up the following processes.
 +
 
 +
<tt>dtcrop('VLPtomograms.doc',ts,targetFolder,96);</tt>
 +
 
 +
Again we average and visualize the cropping results:
 +
 
 +
<nowiki>finalTable = dread([targetFolder,'/crop.tbl']);
 +
oa = daverage(targetFolder,'t',finalTable,'fc',1);
 +
dwrite(oa.average,[targetFolder '/template.em']);</nowiki>
 +
 
 +
==== Step 2: Align symmetry axis ====
 +
We see that the new average is niceley centered (there is one subunit of the lattice in the center of the volume). However, the symmetry axis is not aligned with the Z axis (the whole average looks a bit 'tilted').
 +
 
 +
[[File:VLP_tilted.png|thumb|center|170px| Centered subunit but tilted symmetry axis (X view).]]
 +
 
 +
We can fix that by aligning the last computed average to a synthetic template and then apply the found transformation to the table, resulting in a new and correct orientation for all particles. First we create a synthetic template using the mask tools of ''Dynamo''. We choose a curved membrane with a hole in the center, representing the 'hollow' central subunit of the lattice.
 +
 
 +
<nowiki>mr = dpktomo.examples.motiveTypes.Membrane();  % create membrane object
 +
mr.thickness  = 22;      % choose thickness of membrane
 +
mr.sidelength = 96;      % choose sidelength of box
 +
mr.getMask();            % compute mask
 +
mem  = (mr.mask)*(-1)+1;  % invert contrast
 +
cyl = dynamo_cylinder(7,96,[48,48,48]);  % create a cylinder (this will be the 'hole')
 +
templateSum = mem+cyl;    % sum the two masks
 +
template = templateSum;
 +
template(template>0) = 1; % binarize the new mask</nowiki>
 +
 
 +
We look at the newly created template to make sure it was computed correctly.
 +
<tt>dview(template)</tt>
 +
 
 +
  [[File:VLP_template.png|thumb|center|170px| Template for axis alignment (X view).]]
 +
 
 +
Now we align the last computed average of the previous alignment project to the newly created template. We save the computed transformation parameters in the matlab object ''sal''.
 +
 
 +
<tt>sal = dalign(oa.average,template,'cr',30,'cs',5,'ir',0,'dim',48,'limm',1,'lim',[15,15,15]);</tt>
 +
 
 +
A quick look at the newly aligned average should show a nicely centered particle with the symmetry axis aligned to the Z axis.
 +
<tt>dmapview(sal.aligned_particle);</tt>
 +
 
 +
[[File:VLP_centered_xz.png|thumb|center|300px| Centered and aligned symmetry axis (X/Z view).]]
 +
 
 +
The transformation parameters that have been saved in the matlab object ''sal'' can now be applied to the table
 +
 
 +
<tt>tr =  dynamo_table_rigid(finalTable,sal.Tp);</tt>
 +
 
 +
We now have an up-to-date table with nicely centered and aligned particles. This new table can be used in a new, finer alignment project.
 +
 
 +
 
 +
=== Dealing with oversampling ===
 +
Before starting the new alignment project we apply one more operation on the table. Since we oversampled the VLP surfaces in the beginning we might have ended up with some proteins being in more than one subvolume. Using the following function we can exclude subvolumes that are closer than 20 pixels to each other. In case the distance between two (or more) subvolumes is below this threshold, only the volume with the highest cross correlation (resulting from the previous alignment project) is kept. Read more about how to deal with oversampling [[Seed oversampling| here]].
 +
 
 +
<tt>trEx = dpktbl.exclusionPerVolume(tr,20);</tt>
 +
 
 +
We save the new table and use it to create a new reference, which will be used in the next alignment project.
 +
 
 +
<nowiki>targetFolder = './particlesSize96r';
 +
dwrite(trEx,[targetFolder '/crop_trEx.tbl']);
 +
oa = daverage(targetFolder,'t',trEx,'fc',1);
 +
dwrite(oa.average,[targetFolder '/template_trEx.em']);</nowiki>
 +
 
 +
=== Second aligment project ===
 +
We now have particles which are centered and aligned. We dealt with the oversampling and recropped them to a smaller box size. These are good conditions to run one more alignment project with finer alignment parameters. We will narrow down the angular search, use a finer angular sampling, impose a C6 symmetry and use a tighter alignment mask. We begin by creating an alignment mask which is tighter than the previously used default one. Through the following commands we create a mask that looks like a thick curved membrane.
 +
 
 +
<nowiki>mr = dpktomo.examples.motiveTypes.Membrane();
 +
mr.thickness  = 55;
 +
mr.sidelength = 96;
 +
mr.getMask();
 +
mem_mask  = mr.mask;</nowiki>
 +
 
 +
We save the alignment mask
 +
<tt>dwrite(mem_mask,'mem_mask_thick.em')</tt>
 +
 
 +
and inspect it in ''dmapview''. We open first the previously created template
 +
 
 +
<tt>dmapview(oa.average)</tt>
 +
 
 +
and then in the mask section we activate ''file'', put the path of the mask in it (''mem_mask_thick.em'') and then click ''layer''. You should see the mask overlaid to the average. The mask should contain all the signal of the sample. If this is not the case create a new mask with adjusted parameters.
 +
 
 +
[[File:VLP_ali_mask_x.png|thumb|center|170px| Alignment mask overlaid to reference (X view).]]
 +
 
 +
We have now all the material to set up a new alignment project in the same way as done before. We define a new project name:
 +
 
 +
<tt>pr = 'aliVLP_fine';</tt>
 +
 
 +
We create the new alignment project with the newly cropped particles of 96 pixles sidelength, the new template and the new table. The masks are set to default for now. The new alignment mask is added in the next step.
 +
 
 +
<tt>dcp.new(pr,'d',targetFolder,'t',[targetFolder '/crop_trEx.tbl'],'template',[targetFolder '/template_trEx.em'],'masks','default','show',0);</tt>
  
[[File:StartersGuideResultsAlignment.png|thumb|center|400px| Results of alignment.]]
+
Adding the new tight alignment mask:
 
  
=Subtomogram classification=
+
<tt>dvput(pr,'file_mask','mem_mask_thick.em')</tt>
To demonstrate a classification example we provide particles with 2 slightly different sizes. We can then classify them with a simple Multi-reference Analysis (MRA). To do that, we first generate a dataset which has 2 populations of particles. For this, type:
 
  
<tt>dynamo_tutorial('data_classification','M',8,'N',8);</tt>
+
Next we set up the numerical parameters for the project. In this case we define two rounds. The first round has 2 iterations and works with 1x binned particles and a more restricted and finer angular search than the first alignment project. The second round has only 1 iteration but is using the full size particles and even finer angular search parameters. We use C6 symmetry in both rounds.
  
It generates two sets of particles, 8 particles in each including their table. The idea behind [[Multireference Analysis|MRA]] is the following: The particles are aligned to several references (here only 2). After each iteration, each particle is assigned to only one single reference where it fits the best. This procedure is repeated iteratively. Similar particles will have higher correlation to similar references and will eventually group together. For classification into N classes we will need N initial references and N initially identical tables.Follow these steps to run the MRA:
+
Parameters round 1:
 +
<nowiki>dvput(pr,'ite_r1',2);
 +
dvput(pr,'dim_r1',48);
 +
dvput(pr,'cr_r1',30);
 +
dvput(pr,'cs_r1',10);
 +
dvput(pr,'ir_r1',30);
 +
dvput(pr,'is_r1',10);
 +
dvput(pr,'rf_r1',4);
 +
dvput(pr,'rff_r1',2);
 +
dvput(pr,'lim_r1',[15,15,15]);
 +
dvput(pr,'limm_r1',1);
 +
dvput(pr,'sym_r1','c6');</nowiki>
  
# Create a new project by typing “drun2” in the project name of the alignment GUI.
+
Parameters round 2:
# Set number of references to 2.
+
<nowiki>dvput(pr,'ite_r2',1);
# Activate the ''Swap particles'' button.
+
dvput(pr,'dim_r2',96);
# Go to ''particles'' and add <tt>data_classification/data</tt> to the particle data. Click ok.
+
dvput(pr,'cr_r2',12);
# Go to ''table'' and type <tt>data_classification/real.tbl</tt> into the field ''clone this'' and press ''copy''. Click ok.
+
dvput(pr,'cs_r2',4);
# Go to ''template'' and clone <tt>data_classification/original_template.em</tt> with addition of some extra noise with amplitude 1.
+
dvput(pr,'ir_r2',12);
# Click on ''masks'' and click on ''use default masks''. Click ok.
+
dvput(pr,'is_r2',4);
# Click on ''numerical parameters'' and set the following parameters. Click ok.
+
dvput(pr,'rf_r2',4);
 +
dvput(pr,'rff_r2',2);
 +
dvput(pr,'lim_r2',[5,5,5]);
 +
dvput(pr,'limm_r2',2);
 +
dvput(pr,'sym_r2','c6');</nowiki>
  
[[File:StartersGuideResultsClassification2.png|thumb|center|400px|]]
+
We set the computing environement:
  
Choose the same computing environment as in the previous alignment project and run the project in the same way too. MRA projects usually run longer, because each particle will be aligned to two references. Here, however, we chose the parameters in a way that the process is still fast (e.g., small dimensions). Monitor the progress of the project same as before:
+
<tt>dvput(pr,'dst','standalone_gpu','cores',1,'mwa',2);</tt>
  
<tt>dvstatus drun2</tt>
+
Check, unfold and run the project:
  
And visualize the results using the command:
+
<nowiki>dvcheck aliVLP_fine
 +
dvunfold aliVLP_fine
 +
dvrun aliVLP_fine </nowiki>
  
<tt>ddb drun2:a:ref=* -j c5</tt>
+
While the project is running, we can monitor the results in the same way as we did for the first alignment project. This project should again take no longer than half an hour on one GPU (and 2 cores for averaging). If you are under time pressure you can skip the second round. You should have already nice results after the first round.
  
You should get two averages with particle in one slightly class larger than in the other.
+
=== Result ===
 +
After the second alignment and without any postprocessing or elaborate refinement your final average may look similar to the one shown below. If not, it may need one more refinement round, adjustments to the mask or one more step of recentering and recropping. This representation was lowpass filtered to ~8 angstroms (or 32px in fourier space).
  
[[File:StartersGuideResultsClassification.png|thumb|center|600px| Results of classification.]]
+
[[File:Average_hiv.jpg|thumb|center|400px| Possible outcome of the exercise.]]

Latest revision as of 17:30, 7 December 2025


In this walkthrough you will get familiar with managing multiple tomograms through the Dynamo catalogue and developing strategies for alignment projects to reach a reasonable structure from a set of tomograms. You will make use of the knowledge that you acquired during the workshop and apply it to a more realistic case. It is recommended to get familiar with the advanced starters guide and the walkthrough for lattices on vesicles before starting this walkthrough.

Data

We prepared a set of 6 tomograms, each containing one Immature HIV-1 virus like particle (VLP) with a layer formed by a lattice of capsid proteins. The capsid proteins have a C6 symmetry, a diameter of roughly 15nm and a molecular weight of about 150kDa. The pixelsize of the tomograms is 2.7 angstrom. In this workshop, the data has already been downloaded from https://saco.csic.es/s/9mcg9wAZXqYe9FB and can be found in

/home/student/data/VirusLikeParticles

The tomograms are part of the data that was used in the publication An atomic model of HIV-1 capsid-SP1 reveals structures regulating assembly and maturation by Schur FK, Obr M, Hagen WJ, Wan W, Jakobi AJ, Kirkpatrick JM, Sachse C, Kräusslich HG and Briggs JA. (2016). The full dataset can be found on the Electron Microscopy Public Image Archive (EMPIAR) under EMPIAR-10164. The 6 tomograms were extracted from the tilt series TS_03 and TS_43.

Goal

From the data given you should be able to get a final average in which you start seeing hints of alpha helices, i.e., it should be possible to reach a resolution close to roughly 10 angstroms.

Walkthrough

Set up a catalogue

Create a new catalogue

dcm -create catVLP

and open it in the catalogue manager

dcm catVLP

You can add each volume manually to the catalogue under Catalogue -> Browse for new volume or you can make use of a volume file and add all tomograms at once under Catalogue -> Input list of tomograms -> Browse for text file (.vll file). The volume file should be created beforehand by opening a blank text file named for example VLPtomograms.vll and copy the paths of all tomograms into it:

vlp_1.mrc
vlp_2.mrc
vlp_3.mrc
vlp_4.mrc
vlp_5.mrc
vlp_6.mrc

In case you imported the tomograms using a volume file you have to click the button list volumes to refresh the tomogram list in the catalogue manager. Now you should see the 6 tomograms in the catalogue manager. Prebin the tomograms once (1x) under Catalogue -> Create binned versions -> with factor 1. You can now look at single tomograms in tomoslice by selecting a tomogram of choice in the catalogue manager and then go under View volume -> Load full prebinned Volume [if available] -> open in tomoslice. If needed, adjust the lowpass level and contrast in tomoslice to improve the depiction.

Annotate tomograms

To know where we want to later extract the subvolumes we have to first annotate the surfaces of the VLPs inside the tomograms. We do this by opening a tomogram inside tomoslice where a so called dipole Set model is defined. How to do that is described in detail in the section DipoleSet models, Corrections during picking and Corrections after picking of the walkthrough for lattices on vesicles. A new dipole set model has to be made for each tomogram. Save each model before closing tomoslice and when opening a new tomogram in tomoslice select Delete from memory if asked. In case you see markers of the previously defined dipole set inside the newly opened tomogram make sure the model pool is empty and click on reset scene before defining the new dipole set. Once you went through all tomograms click on the button list volumes inside the catalogue manager to refresh the list of tomograms. In the column model files of the tomogram list of the catalogue manager you should now see that you have one defined model per tomogram.

Define crop points

To extract subvolumes (crop particles) we need to first define the crop points on the surface of the VLPs using the previously defined models. The crop points are then stored in a table. This is all done with the following script which is an extended version of the one found in the walkthrough for lattices on vesicles. Note that we oversample the VLPs, i.e., we define enough crop points such that every protein has the chance to end up in at least one subvolume. We will take care of proteins that end up in more than subvolume in a later step. Note that this script assumes that there are exactly 6 tomograms with only one model for each tomogram. In cases where a different number of tomograms or models is used, the script has to be adapted accordingly.

% read dipole from catalogue into workspace
dcmodels catVLP -tc dipoleSet -ws o -gm 1

c=1; % counter for table
for tomo = 1:6 % loop over tomograms
    ds = o.models{tomo};                  % read models
    NDipoles = length(ds.dipoles);
    for i=1:NDipoles                      % loop over models (in our case just one per tomogram)
        v = dmodels.vesicle();            % create empty vesicle model
        v.center = ds.dipoles{i}.center;  % add center from dipole to vesicle model
        v.radius = norm( ds.dipoles{i}.north - ds.dipoles{i}.center); % add radius
        v.separation = 60;                % separation of crop points (in px)
        v.crop_distance_from_surface =0;
        v.updateCrop();                   % update vesicle model

        tv{c} = v.grepTable(); % create crop table from using vesicle model
        tv{c}(:,22) = i;       % add model number to table
        tv{c}(:,20) = tomo;    % add tomogram number to table
        c=c+1;
    end
end


In the standalone version you need to proceed as follows:

1.) Open a text file named commands.m and copy the following into the file (avoid commenting with % or #):

o=dcmodels('catVLP','tc','dipoleSet','gm',1);
c=1;
for tomo = 1:6
    ds = dread(o{tomo});
    NDipoles = length(ds.dipoles);
    for i=1:NDipoles
        v = dmodels.vesicle();
        v.center = ds.dipoles{i}.center;
        v.radius = norm( ds.dipoles{i}.north - ds.dipoles{i}.center);
        v.separation = 60;
        v.crop_distance_from_surface =0;
        v.updateCrop();
        tv{c} = v.grepTable();
        tv{c}(:,22) = i;
        tv{c}(:,20) = tomo;
        c=c+1;
        disp(sprintf('Dipole %d will provide %d crop points',i,size(v.crop_points,2)));
    end
end
dwrite(tv,'cellOfTables.mat');

2.) Execute the text file in a system shell or in the Dynamo console:

dynamo commands.m

3.) When you are back in the Dynamo console, you can load the results from the script into the workspace with

tv = dread('cellOfTables.mat'); 

Type whos to display the actual matlab workspace and to check if the variable tv was loaded correctly.

Write table with crop points

The tables beloning to each dipole model are stored in the cell array tv. To create one single table containing all crop points we merge all tables into one with the command

tAll = dynamo_table_merge(tv,'linear_tags',1); 

and visualize the table to see the crop points and their orientations (when visualizing actual results of an alignment project use option 'corrected_oriented_positions ' instead of the one shown here).

dtplot(tAll,'pf','oriented_positions'); axis equal

You should get something like:

Crop points in table.


Extract subvolumes

Before extracting the subvolumes (cropping particles) using the previously generated table we have to define a so called tomogram table map file which links the tomogram identification number in column 20 of the previously created table to an actual tomogram on the disk. Create a file named VLPtomograms.doc and copy the tomogram numbers and full paths of the tomograms into it:

1 vlp_1.mrc
2 vlp_2.mrc
3 vlp_3.mrc
4 vlp_4.mrc
5 vlp_5.mrc
6 vlp_6.mrc

Define a destination for the cropped particles:

targetFolder = './particlesSize128';

Now we can crop the particles with sidelength 128 pixels from the tomograms using the table previously defined.

dtcrop('VLPtomograms.doc',tAll,targetFolder,128);

The cropping on one core should not take longer than 5 minutes.

We create a plain average of all cropped particles to asses the quality of the cropped particles. First we read the table of the cropped particles:

finalTable = dread([targetFolder '/crop.tbl']);

We can also visualise the particles:

dslices(targetFolder,'projy','*','t',finalTable,'align',1,'tag',1:10:500,'labels','on');

Then we form the average

oa = daverage(targetFolder,'t',finalTable,'fc',1);

and inspect the average with

dview(oa.average)

You should see a faint and noisy curvature of a thick membrane-like structure in the X and Y view.

Average of cropped particles (X view).

We will use this average as a first reference (template) in the next alignment project. We therefore save the average with

dwrite(oa.average,[targetFolder '/template.em']);

Hint: When dealing with preferred orientations, randomizing the azimuth of the particles bevore averaging can help (in this tutorial this is not needed):

tRandAz = dynamo_table_randomize_azimuth(t);

First alignment project

Now we create our first alignment project through the command line in a similar way as described in detail in the walkthrough for lattices on vesicles. First we define a project name

pr = 'aliVLP';

Then we create the alignment project with the particles, template and table that we defined before. The masks are set to default.

dcp.new(pr,'d',targetFolder,'t',[targetFolder '/crop.tbl'],'template',[targetFolder '/template.em'],'masks','default','show',0);

Next we set up the numerical parameters for the project and the computing environment (type dvhelp in the console for an overview of all parameters). We use 2x binned particles and a rather coarse angular search. The shift limits are very generous in order to make sure all particles have the chance to 'see' each other.

dvput(pr,'ite_r1',4);
dvput(pr,'dim_r1',32);
dvput(pr,'cr_r1',40);
dvput(pr,'cs_r1',20);
dvput(pr,'ir_r1',360);
dvput(pr,'is_r1',40);
dvput(pr,'rf_r1',4);
dvput(pr,'rff_r1',2);
dvput(pr,'lim_r1',[40,40,40]);
dvput(pr,'limm_r1',1);
dvput(pr,'dst','standalone_gpu','cores',1,'mwa',2);

Everything can of course also be set up through the alignment project GUI. The numerical parameters would correspond to:

Alignment parameters for first alignment project.


Check, unfold and run the project through the alignment project GUI or through the command line:

dvcheck aliVLP
dvunfold aliVLP
dvrun aliVLP

On one GPU (and 2 cores for averaging) the alignment project should not take longer than half an hour. Check the status of the alignment project with

dvstatus aliVLP

You can also see the average of the last computed iteration in dmapview with the command. If needed, adjust the lowpass and contrast to improve the depiction.

dpkdev.legacy.dynamo_mapview('aliVLP:a')

Recenter and recrop

After the alignment project finished successfully we can inspect the last computed average with the same command introduced before:

dpkdev.legacy.dynamo_mapview('aliVLP:a')

The command can be extended to see the averages of all iterations including the starting reference. Once in dmapview, press the button norm to properly compare the averages.

dpkdev.legacy.dynamo_mapview('aliVLP:a:ite=0:last')

In the last average, you should already start to see a hexagonal lattice. We now want to make sure that the center of one C6 subunit of the lattice coincides with the center of the subvolume and that the subunits symmetry axis is parallel to the Z axis of the subvolume. This will allow us to later recrop the subvolumes with a smaller box size and to choose finer alignment parameters in the next alignment project. The recentering and realigning can be done in two steps. First, we subbox the particles using a new, manually defined box center and recrop the particles with a smaller boxsize. Second, we align the symmetry axis using a synthetic template. Both procedures are described in detail in the advanced starters guide in the section Aligning the axis of symmetry and Subboxing and are now applied here.

Step 1: Subboxing

Open the last computed average in dmapview as previously described. Activate the radio buttons for the Center/North tools under Clicks. You can now click anywhere on the average and see the corresponding coordinates. Find the coordinates of the center of one subunit of the lattice. Switch between X,Y and Z view to make sure the center is correct. In our case we found the center of a subunit at [88,75,72]. For you these coordinates might be different.

Finding the coordinates of the center of a lattice subunit.

Copy the found coordinates of the center of the subunit into the first vector of the command below. To compute the vector from the center of the subvolume to the center of a subunit we need to subtract the coordinates of the center of the subvolume. The center of a subvolume with a sidelength of 128 pixels is defined as [65,65,65].

rSubunitFromCenter = [88,75,72] - [65,65,65];

This vector will now be used to shift (or recenter) all particles in the table. Read the last computed table of the alignment project

ddb aliVLP:rt -ws t

and apply the new center to the table

ts = dynamo_subboxing_table(t,rSubunitFromCenter);

The table now contains the coordinates of the recentered particles. We use this new table to recrop the particles. We first define a new target folder:

targetFolder = './particlesSize96r';

Then we recrop the new particles. Since the particles are centered now, we can also choose a smaller boxsize of 96 pixels. This will save space and speed up the following processes.

dtcrop('VLPtomograms.doc',ts,targetFolder,96);

Again we average and visualize the cropping results:

finalTable = dread([targetFolder,'/crop.tbl']);
oa = daverage(targetFolder,'t',finalTable,'fc',1);
dwrite(oa.average,[targetFolder '/template.em']);

Step 2: Align symmetry axis

We see that the new average is niceley centered (there is one subunit of the lattice in the center of the volume). However, the symmetry axis is not aligned with the Z axis (the whole average looks a bit 'tilted').

Centered subunit but tilted symmetry axis (X view).

We can fix that by aligning the last computed average to a synthetic template and then apply the found transformation to the table, resulting in a new and correct orientation for all particles. First we create a synthetic template using the mask tools of Dynamo. We choose a curved membrane with a hole in the center, representing the 'hollow' central subunit of the lattice.

mr = dpktomo.examples.motiveTypes.Membrane();   % create membrane object
mr.thickness  = 22;       % choose thickness of membrane
mr.sidelength = 96;       % choose sidelength of box
mr.getMask();             % compute mask 
mem  = (mr.mask)*(-1)+1;  % invert contrast
cyl = dynamo_cylinder(7,96,[48,48,48]);  % create a cylinder (this will be the 'hole')
templateSum = mem+cyl;    % sum the two masks
template = templateSum;
template(template>0) = 1; % binarize the new mask

We look at the newly created template to make sure it was computed correctly.

dview(template)
Template for axis alignment (X view).

Now we align the last computed average of the previous alignment project to the newly created template. We save the computed transformation parameters in the matlab object sal.

sal = dalign(oa.average,template,'cr',30,'cs',5,'ir',0,'dim',48,'limm',1,'lim',[15,15,15]);

A quick look at the newly aligned average should show a nicely centered particle with the symmetry axis aligned to the Z axis.

dmapview(sal.aligned_particle);
Centered and aligned symmetry axis (X/Z view).

The transformation parameters that have been saved in the matlab object sal can now be applied to the table

tr =  dynamo_table_rigid(finalTable,sal.Tp);

We now have an up-to-date table with nicely centered and aligned particles. This new table can be used in a new, finer alignment project.


Dealing with oversampling

Before starting the new alignment project we apply one more operation on the table. Since we oversampled the VLP surfaces in the beginning we might have ended up with some proteins being in more than one subvolume. Using the following function we can exclude subvolumes that are closer than 20 pixels to each other. In case the distance between two (or more) subvolumes is below this threshold, only the volume with the highest cross correlation (resulting from the previous alignment project) is kept. Read more about how to deal with oversampling here.

trEx = dpktbl.exclusionPerVolume(tr,20);

We save the new table and use it to create a new reference, which will be used in the next alignment project.

targetFolder = './particlesSize96r';
dwrite(trEx,[targetFolder '/crop_trEx.tbl']);
oa = daverage(targetFolder,'t',trEx,'fc',1);
dwrite(oa.average,[targetFolder '/template_trEx.em']);

Second aligment project

We now have particles which are centered and aligned. We dealt with the oversampling and recropped them to a smaller box size. These are good conditions to run one more alignment project with finer alignment parameters. We will narrow down the angular search, use a finer angular sampling, impose a C6 symmetry and use a tighter alignment mask. We begin by creating an alignment mask which is tighter than the previously used default one. Through the following commands we create a mask that looks like a thick curved membrane.

mr = dpktomo.examples.motiveTypes.Membrane();
mr.thickness  = 55;
mr.sidelength = 96;
mr.getMask();
mem_mask  = mr.mask;

We save the alignment mask

dwrite(mem_mask,'mem_mask_thick.em')

and inspect it in dmapview. We open first the previously created template

dmapview(oa.average)

and then in the mask section we activate file, put the path of the mask in it (mem_mask_thick.em) and then click layer. You should see the mask overlaid to the average. The mask should contain all the signal of the sample. If this is not the case create a new mask with adjusted parameters.

Alignment mask overlaid to reference (X view).

We have now all the material to set up a new alignment project in the same way as done before. We define a new project name:

pr = 'aliVLP_fine';

We create the new alignment project with the newly cropped particles of 96 pixles sidelength, the new template and the new table. The masks are set to default for now. The new alignment mask is added in the next step.

dcp.new(pr,'d',targetFolder,'t',[targetFolder '/crop_trEx.tbl'],'template',[targetFolder '/template_trEx.em'],'masks','default','show',0);

Adding the new tight alignment mask:

dvput(pr,'file_mask','mem_mask_thick.em')

Next we set up the numerical parameters for the project. In this case we define two rounds. The first round has 2 iterations and works with 1x binned particles and a more restricted and finer angular search than the first alignment project. The second round has only 1 iteration but is using the full size particles and even finer angular search parameters. We use C6 symmetry in both rounds.

Parameters round 1:

dvput(pr,'ite_r1',2);
dvput(pr,'dim_r1',48);
dvput(pr,'cr_r1',30);
dvput(pr,'cs_r1',10);
dvput(pr,'ir_r1',30);
dvput(pr,'is_r1',10);
dvput(pr,'rf_r1',4);
dvput(pr,'rff_r1',2);
dvput(pr,'lim_r1',[15,15,15]);
dvput(pr,'limm_r1',1);
dvput(pr,'sym_r1','c6');

Parameters round 2:

dvput(pr,'ite_r2',1);
dvput(pr,'dim_r2',96);
dvput(pr,'cr_r2',12);
dvput(pr,'cs_r2',4);
dvput(pr,'ir_r2',12);
dvput(pr,'is_r2',4);
dvput(pr,'rf_r2',4);
dvput(pr,'rff_r2',2);
dvput(pr,'lim_r2',[5,5,5]);
dvput(pr,'limm_r2',2);
dvput(pr,'sym_r2','c6');

We set the computing environement:

dvput(pr,'dst','standalone_gpu','cores',1,'mwa',2);

Check, unfold and run the project:

dvcheck aliVLP_fine
dvunfold aliVLP_fine
dvrun aliVLP_fine 

While the project is running, we can monitor the results in the same way as we did for the first alignment project. This project should again take no longer than half an hour on one GPU (and 2 cores for averaging). If you are under time pressure you can skip the second round. You should have already nice results after the first round.

Result

After the second alignment and without any postprocessing or elaborate refinement your final average may look similar to the one shown below. If not, it may need one more refinement round, adjustments to the mask or one more step of recentering and recropping. This representation was lowpass filtered to ~8 angstroms (or 32px in fourier space).

Possible outcome of the exercise.