-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
76 lines (65 loc) · 2.55 KB
/
main.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
nextflow.enable.dsl=2
script_folder = "$baseDir/bin"
include {data_collection} from "$script_folder/workflows.nf"
include {gap_filling} from "$script_folder/workflows.nf"
include {deduplicating} from "$script_folder/workflows.nf"
include {cellpose_segmentation} from "$script_folder/workflows.nf"
include {mesmer_segmentation} from "$script_folder/workflows.nf"
include {roi_making} from "$script_folder/workflows.nf"
include {sc_data_extraction} from "$script_folder/workflows.nf"
Closure compare_file_names = {a, b -> a.name <=> b.name}
workflow {
// Data Collection
data_collection(params.input_path)
sample_metadata = data_collection.out.data_csv
.splitCsv(header : true)
.multiMap { row ->
sample: row.sample
dapi: row.dapi
counts: row.counts}
samples = sample_metadata.sample.toSortedList().flatten().view()
dapi = sample_metadata.dapi.toSortedList().flatten().view()
counts = sample_metadata.counts.toSortedList().flatten().view()
// Gap Filling with MindaGap
if (params.fill_gaps == true){
gap_filling(samples, dapi)
images = gap_filling.out.gap_filled_image
.toSortedList(compare_file_names).flatten().view()
} else {
images = dapi
}
// Deduplicate transcripts with MindaGap
if (params.deduplicate == true){
deduplicating(samples, counts, params.tile_size_x, params.tile_size_y, \
params.window_size, params.max_freq, params.min_mode)
transcripts = deduplicating.out.deduplicated_transcripts
.toSortedList(compare_file_names).flatten().view()
} else {
transcripts = counts
}
// Cell Segmentation
if(params.segmentation_tool == "cellpose"){
segmentation = cellpose_segmentation(samples, \
params.model_name, params.probability_threshold, \
params.cell_diameter, images)
}else if (params.segmentation_tool == "mesmer") {
segmentation = mesmer_segmentation(samples, images, \
params.maxima_threshold, params.maxima_smooth, params.interior_threshold, \
params.interior_smooth, params.small_objects_threshold, \
params.fill_holes_threshold, params.radius)
} else {
return
}
cell_masks = segmentation.mask_images
.toSortedList(compare_file_names).flatten().view()
// ROI Making
if(params.do_zip){
roi_making(samples, cell_masks)
roi_zips = roi_making.out.zipped_rois
.toSortedList(compare_file_names).flatten().view()
}
// Single Cell Data Extraction
sc_data_extraction(samples, cell_masks, transcripts)
single_cell_data = sc_data_extraction.out.sc_data
.toSortedList(compare_file_names).flatten().view()
}