-
Couldn't load subscription status.
- Fork 61
first pass at adding gator module to mcmicro #491
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
Draft
ajitjohnson
wants to merge
2
commits into
labsyspharm:master
Choose a base branch
from
ajitjohnson:gator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| /* | ||
| A template for adding new modules to MCMICRO | ||
|
|
||
| Step 1: Add module specs to config/defaults.yml | ||
|
|
||
| a: Add a flag specifying whether the module should be run to workflow: | ||
| b: Add default module options to options: | ||
| c: Add module name and container specs to modules: | ||
|
|
||
| For example, support we wanted to add a module that produces a QC report | ||
| about the signal-to-noise ratio (snr). The three additions to defaults.yml | ||
| may then look as follows: | ||
|
|
||
| workflow: | ||
| report: false | ||
| options: | ||
| snr: --cool-parameter 42 | ||
| modules: | ||
| report: | ||
| name: snr | ||
| container: myorganization/snr | ||
| version: 1.0.0 | ||
|
|
||
| Step 2: Modify the code below as needed | ||
|
|
||
| Step 3: Run the module from the main workflow in main.nf | ||
|
|
||
| a: add an include statement to import the relevant workflow. For example: | ||
|
|
||
| ... | ||
| include {downstream} from "$projectDir/modules/downstream" | ||
| include {viz} from "$projectDir/modules/viz" | ||
| include {report} from "$projectDir/modules/report" // <- importing the new module | ||
|
|
||
| b: add a statement calling the module near the bottom of the main workflow: | ||
|
|
||
| ... | ||
| downstream(mcp, sft) | ||
|
|
||
| report(mcp, allimg, sft) // <- calling the new module | ||
|
|
||
| // Vizualization | ||
| viz(mcp, allimg) | ||
| ... | ||
|
|
||
| */ | ||
|
|
||
| // Import utility functions from lib/mcmicro/*.groovy | ||
| import mcmicro.* | ||
|
|
||
| // Process name will appear in the the nextflow execution log | ||
| // While not strictly required, it's a good idea to make the | ||
| // process name match your tool name to avoid user confusion | ||
| process gatorpy { | ||
|
|
||
| // Use the container specification from the parameter file | ||
| // No change to this line is required | ||
| container "${params.contPfx}${module.container}:${module.version}" | ||
|
|
||
| // Specify the project subdirectory for writing the outputs to | ||
| // The pattern: specification must match the output: files below | ||
| // TODO: replace report with the desired output directory | ||
| // TODO: replace the pattern to match the output: clause below | ||
| publishDir "${params.in}/gator", mode: 'copy', pattern: "GATOR/*" | ||
|
|
||
| // Stores .command.sh and .command.log from the work directory | ||
| // to the project provenance | ||
| // No change to this line is required | ||
| publishDir "${Flow.QC(params.in, 'provenance')}", mode: 'copy', | ||
| pattern: '.command.{sh,log}', | ||
| saveAs: {fn -> fn.replace('.command', "${module.name}-${task.index}")} | ||
|
|
||
| // Inputs for the process | ||
| // mcp - MCMICRO parameters (workflow, options, etc.) | ||
| // module - module specifications (name, container, options, etc.) | ||
| // img/sft - pairs of images and their matching spatial feature tables | ||
| input: | ||
| val mcp | ||
| val module | ||
| path markers | ||
| path gatorModel | ||
| tuple path(img), path(mask), path(sft) | ||
|
|
||
| // Process outputs that should be captured and | ||
| // a) returned as results | ||
| // b) published to the project directory | ||
| // TODO: replace *.html with the pattern of the tool output files | ||
| output: | ||
| path("GATOR/*"), emit: results | ||
|
|
||
| // Provenance files -- no change is needed here | ||
| tuple path('.command.sh'), path('.command.log') | ||
|
|
||
| // Specifies whether to run the process | ||
| // Here, we simply take the flag from the workflow parameters | ||
| // TODO: change snr to match the true/false workflow parameter in defaults.yml | ||
| when: mcp.workflow["gator"] | ||
|
|
||
| // The command to be executed inside the tool container | ||
| // The command must write all outputs to the current working directory (.) | ||
| // Opts.moduleOpts() will identify and return the appropriate module options | ||
| """ | ||
| python /app/gatorPipeline.py --projectDir . \ | ||
| --imagePath $img \ | ||
| --markerChannelMapPath $markers \ | ||
| --gatorModelPath $gatorModel \ | ||
| --segmentationPath $mask \ | ||
| --spatialTablePath $sft \ | ||
| --features $sft \ | ||
| ${Opts.moduleOpts(module, mcp)} | ||
| """ | ||
| } | ||
|
|
||
| workflow gator { | ||
|
|
||
| // Inputs: | ||
| // mcp - MCMICRO parameters (workflow, options, etc.) | ||
| // imgs - images | ||
| // sfts - spatial feature tables | ||
| take: | ||
| mcp | ||
| markers | ||
| gatorModels | ||
| imgs | ||
| masks | ||
| sfts | ||
|
|
||
| main: | ||
|
|
||
| // Match images against feature tables | ||
| id_imgs = imgs.map{ it -> tuple(Util.getImageID(it), it) } | ||
| id_sfts = sfts.map{ it -> tuple(Util.getFileID(it, '--'), it) } | ||
| id_masks = masks.map{ id, msk -> x = id.split('-',2); tuple(x[1], x[0], msk) } | ||
|
|
||
|
|
||
| // Apply the process to each (image, sft) pair | ||
| id_imgs.combine(id_sfts, by:0) | ||
| .map{ tag, img, sft -> tuple(img, sft) } | snr | ||
|
|
||
| // Return the outputs produced by the tool | ||
| emit: | ||
| snr.out.results | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this: