Importing crYOLO particle coordinates into cryoSPARC

Currently, I’m trying to import particles picked using crYOLO into cryoSPARC. Initially, I use crYOLO to pick particles from the patch motion correction job’s output (the dose-weighted aligned micrographs). crYOLO outputs a list of star files with the particle coordinates for each micrograph. From this point on, I’m unsure of how to be using the ‘Import Particle Stack’ job to be importing those coordinates into cryoSPARC.

This is what I have tried so far with Import Particle Stack:

  1. Importing source micrographs from an earlier patch motion correction job
  2. Selecting ignore raw data and setting particle data path to all the star files outputted by crYOLO
  3. Setting the 2 suffix cuts to their correct values

This fails due to lacking, I think, the Particle meta path. But I’m not sure what the meta path for the particles should be here. crYOLO does not output any such files. What should I do in this case so that the particles can be imported successfully?

Have you tried just concatenating all the per-mic crYOLO star files together into one big particle star file (removing all except the first header of course) - that should work I would think?

Cheers
Oli

Thanks @olibclarke for the suggestion - that should work. @kmzaw please let us know if you were able to import successfully!

That did work! Thanks @olibclarke

1 Like

Hi, I am also trying to do this but still got an error that says “Could not import star file: too many fields missing” Does your star file looks like this?
Screen Shot 2021-04-30 at 2.07.34 PM|225x499

Hi Smona, the other way to do it (which I have been doing recently) is just to do an extraction in relion (using either crYOLO box or star files) purely to generate a particle star file, then import the resulting star file into cryosparc, with ignore raw data on. Maybe give that a try?

Cheers
Oli

1 Like

Has anyone attempted to make a script to import cryolo picks directly to crysoparc? I tried to concatenate as @olibclarke suggested without any luck.

Currently picked particles from denoised micrographs (using topaz output), which works just fine, but having issues converting them into a particle.star file that will import and link to the topaz denoising job which I ran in cryosparc. Any ideas @apunjani?

I know this is an older thread, but I since it was related to my question I did not want to open a new thread.

we just do an extraction in relion (using the .box files) and import ignoring raw data - does that not work for you @Omid?

Hi @olibclarke,

I have done it in the past but for some reason I had a hard t using the same denoised micrographs that I used for picking. Maybe it is because some of the micrographs have zero picked particles. I am sure I can figure it out using relion eventually… Just curious if someone had a script for it that they did not mind sharing which avoids going from cryolo, to relion and then to cryosparc. Perhaps I’ll set some time aside and make one. I am just very slow at scripting.

Best,
Omid

hmm - was it giving an error of some kind? I’ve been doing it with JANNI denoised micrographs without issues

Yeah it was not able to find one of the input micrographs. I suspect it is because no particles were picked for that image and hence no box file output for that corresponding micrograph. I’ll test it out later…

Hello everyone, @Omid and @olibclarke,

I always use cryolo for picking and directly import to csparc using the following very simple script.

It can be adapted to a different routine, but to make sure that it will work each time, I use the csparc’s /path_to/motioncorrected/*_patch_aligned_doseweighted.mrc as input for cryolo (which is important for the x,y axis to be the same and to match the name for each micrograph) and I import only the coordinates, while connecting the exposures to the imported particles. Make sure that all exposures used as input for cryolo are dragged to be connected with the particles (it will fail if there are particles for micrographs that are not included in the exposure set, eg because some exposures have been rejected to a previous curate exposures step).

After that you can use the imported particles and any selected subset of the exposures as input for an extraction job. For example, for a csparc live session, export exposures to csparc and then use the “all_exposures” set to connect with the particles at the import particles step but only the “accepted_exposures” for the extract from mics step (to avoid manually selecting mics twice).

Hope that helps.
Best,
Left

##################################

cd cryolo_output/STAR

echo ' ' > ../picks.star
echo 'data_' >> ../picks.star
echo ' ' >> ../picks.star
echo 'loop_' >> ../picks.star
echo '_rlnMicrographName #1' >> ../picks.star
echo '_rlnCoordinateX #2' >> ../picks.star
echo '_rlnCoordinateY #3' >> ../picks.star


foreach file (*.star) 

      awk -v f="$file" '{if (NF>3) printf "%s\t%s\t%s\n", f, $1, $2}' $file >> ../picks.star

end 

sed -i 's|.star|.mrc|g' ../picks.star

gedit ../picks.star #if you want to inspect the output

cd ../../

##################################

2 Likes

Hi @lezark

So sorry for the late reply. Been a busy few months. I will definitely give this a shot. Thank you so much for sharing.

Best,
Omid

I tried your script finally, but ran into a few issues. Sorry I have no formal computer science training. Had to change the foreach command since that only works in c-shell (I think). Then I removed the CF/LF lines with dos2unix program which occur with copy and pasting from windows computers I suppose.

This is the script I used for bash shell to make it work for those interested. I figured others may run into the same issue as most basic user use bash shell.

echo ’ ’ > …/picks.star
echo ‘data_’ >> …/picks.star
echo ’ ’ >> …/picks.star
echo ‘loop_’ >> …/picks.star
echo ‘_rlnMicrographName #1’ >> …/picks.star
echo ‘_rlnCoordinateX #2’ >> …/picks.star
echo ‘_rlnCoordinateY #3’ >> …/picks.star
for file in /data/CRYOSPARC/cryolo/full_data/STAR/*.star ; do
awk -v f="$file" ‘{if (NF>3) printf “%s\t%s\t%s\n”, f, $1, $2}’ “$file” >> …/picks.star ; done

Thanks again for your suggestion!

I tried the script from @Omid and @lezark and was able to get a star file like in the attached image, top half (called picks.star).

In Cryosparc I import the micrographs (using Import Micrographs) that correspond to the star files in the picture above. The mrc micrographs are in a directory separate from the Cryolo picks star files.

Then I use Import Particles with the micrographs from the Import Micrographs job as input and the path to the picks.star file in the Particle meta path field. I click Ignore raw data and Ignore half-set split if missing. I put in the microscope parameter overrides. Then I run the job.

I keep getting the error shown in the image (bottom half).

What am I doing wrong? Do the star files in the output_boxes/STAR directory need to be in the same directory as the mrc micrograph files? Thanks!

Hi @klmcguire,

Looking at the job event log, I think you might wanna set some parameters in job builder:

  • Length of input micrograph path suffix to cut for query: 4 and Length of rlnMicrographName path suffix to cut for query: 5 to match the input and source micrograph filenames

OR

  • Edit the picks.star which you are using for import:
    Search and replace .star in the first column of the star file to .mrc
    For example, open picks.star with vim picks.star, then run :1,$ s/.star/.mrc in vim.

Best,
Kookjoo

That worked @kookjookeem, thanks!

1 Like

@kookjookeem I have one more issue in this pipeline. I imported the particles using Import Particle Stack (got some warnings, top of attachment). Then I ran an Extract From Micrographs using the particles from the import job and the micrographs that were used to pick the particles (no warnings, middle of attachment). Then I tried a 2D Classification job but it crashed and got the error at the bottom of the attachment. I am using the motion corrected doseweighted micrographs from the Cryosparc Live exported and accepted micrographs. What am I doing wrong? Thanks!

Hi @klmcguire,

picks.star only contained micrograph names and XY coordinates. It’s complaining about not having the CTF parameters in the particle metadata star file.

Neither particles nor micrographs have CTF estimates: no CTF estimates will be outputted.

This seems the input micrographs for the extraction do not have their CTF estimated. The extraction just went ahead without CTF parameters linked to your particles, and the lack of connected CTF caused your 2D classification to fail.

Are the micrographs directly exported from the live session in the same cryosparc project/workspace or were they directly imported via Import Micrographs?

If the micrographs were just imported, and they don’t have their CTF estimated yet, perhaps you can run Patch CTF on your micrographs, then use the output for particle extraction. Hope this helps!

Best,
Kookjoo