Skip to content

Commit

Permalink
Add nextflow script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Milk committed Aug 22, 2024
1 parent bc8067c commit 1d66fc3
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.DS_Store
.DS_Store

work/
84 changes: 84 additions & 0 deletions workflow/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2

params.slide_table = null
params.tile_px = 256
params.report_dir = "reports"
params.models = "resnet50"

process PREPROCESS {
publishDir params.report_dir, mode: 'move'

input:
tuple val(wsi), val(storage)
val tile_px

output:
path '*_report.txt', emit: report
tuple val(wsi), val(storage), emit: slide

script:

def wsi_base = wsi.baseName

"""
lazyslide preprocess ${wsi} ${tile_px} --output ${storage}
touch ${wsi_base}_report.txt
"""
}

process FEATURE {

input:
tuple val(wsi), val(storage)
each model

script:
"""
lazyslide feature ${wsi} ${model} --output ${storage}
"""
}



workflow {

log.info """
██ █████ ███████ ██ ██ ███████ ██ ██ ██████ ███████
██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██
██ ███████ ███ ████ ███████ ██ ██ ██ ██ █████
██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██
███████ ██ ██ ███████ ██ ███████ ███████ ██ ██████ ███████
===================================================================
Workflow information:
Workflow: ${workflow.projectDir}
Input parameters:
Slide table: ${file(params.slide_table)}
"""

slides_ch = Channel
.fromPath( params.slide_table, checkIfExists: true )
.splitCsv( header: true )
.map { row ->
def slide_file = file(row.file, checkIfExists: true)
def slide_storage = row.storage
if (row.storage == null) { slide_storage = slide_file.parent / slide_file.baseName + ".zarr" }
return tuple(slide_file, slide_storage)
}

// slides_ch.view()

out_ch = PREPROCESS(slides_ch, params.tile_px)

// println "Ouput of PREPROCESS: "
// out_ch.slide.view()

models = Channel.of(params.models?.split(','))

FEATURE(out_ch.slide, models)

}
18 changes: 18 additions & 0 deletions workflow/modules/qc/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2

process SlideQC {

input:
val mpp
val
path slide

output:
path("*.qc.csv") into qc_ch

script:
"""
lazyslide qc $slide
"""
}

0 comments on commit 1d66fc3

Please sign in to comment.