Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging (phenoimager2mc), max-projections #557

Merged
merged 9 commits into from
Aug 28, 2024

Conversation

kbestak
Copy link
Contributor

@kbestak kbestak commented Aug 26, 2024

Hi, this is a PR for our branch of MCMICRO where we've added a staging step before illumination specific for unmixed single-tile outputs from Akoya's InForm software as part of the push to make MCMICRO compatible with SignalStar, a method for multicycle multispectral imaging.

In addition, I've added a max-projection functionality to recyze as described below in the change points - max projection of nuclear markers is returned as channel 0 and max projection of membrane markers is returned as channel 1. This functionality would mostly benefit Cellpose segmentation in my opinion.

  • Add staging step before illumination - start-at: staging
    • inputs should be saved in staging folder, outputs will be stored in raw and continue as a typical mcmicro run.
  • phenoimager2mc added as a staging module - staging-method: phenoimager2mc
  • illumination is run by default if start-at: staging is given and can be toggled off with illumination: false
  • Add max projection option to recyze on multiple nuclear and/or membrane channels provided - output will have nuclear channel 0 and membrane channel 1
    • segmentation-max-projection: true
    • segmentation-channel: 1 3 8 9
    • segmentation-nuclear-channel: 1 8
    • segmentation-membrane-channel: 3 9

Example parameter file for running staging, registration, segmentation with cellpose using the above options and quantification:

workflow:
  start-at: staging
  stop-at: quantification
  illumination: false
  staging-method: phenoimager2mc
  segmentation-recyze: true
  segmentation-max-projection: true
  segmentation-channel: 1 5 7 8 11
  segmentation-nuclear-channel: 5 11
  segmentation-membrane-channel: 1 7 8
  segmentation: cellpose
options:
  phenoimager2mc: -m 6 --normalization max
  ashlar: --align-channel 4 --flip-y
  cellpose: --pretrained_model cyto --chan 1 --chan2 0 --no_npy

Let me know if this is of interest and if changes would have to be made,

Best,
Krešo

@ArtemSokolov
Copy link
Collaborator

Thanks for submitting this, @kbestak.

Looks like CI test are failing with No subdirectories found in staging directory.
I think you may need to wrap

stagingDirs = Channel.fromPath("${params.in}/staging/*", type: 'dir')
    .ifEmpty { error "No subdirectories found in staging directory" }

inside an if/else:

// Look for staging directories only if the user is starting from the staging step
stagingDirs = (wfp['start-at'] == 'staging') ?
    Channel.fromPath("${params.in}/staging/*", type: 'dir')
        .ifEmpty { error "No subdirectories found in staging directory" } : Channel.empty()

I had to do similar thing for all other steps, so I defined a function here: https://github.com/labsyspharm/mcmicro/blob/master/main.nf#L44-L50

@kbestak
Copy link
Contributor Author

kbestak commented Aug 27, 2024

Thank you for highlighting this, I've addressed the issue, added validation for the max projection / nuclear-membrane specifications, excluded the mentioned staging parameter (now start-at: staging is enough for staging to run), and caught a bug with providing recyze with the max-projection tag that was fixed now.

@ArtemSokolov ArtemSokolov merged commit f25fcbf into labsyspharm:master Aug 28, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants