Skip to content

Commit

Permalink
better map
Browse files Browse the repository at this point in the history
  • Loading branch information
maxulysse committed Apr 25, 2024
1 parent f64ab18 commit eb33fac
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions workflows/imcyto/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ workflow IMCYTO {
// Group full stack files by sample and roi_id
//
IMCTOOLS.out.full_stack_tiff
.map { flattenTiff(it) }
.map{ meta, tiff -> [ [meta + [roi:tiff[0].getParent().getParent().getName()]], tiff ]}
.transpose(by: [1])
.flatten()
.collate(2)
.groupTuple()
Expand All @@ -100,7 +101,8 @@ workflow IMCYTO {
//

IMCTOOLS.out.ilastik_stack
.map { flattenTiff(it) }
.map{ meta, tiff -> [ [meta + [roi:tiff[0].getParent().getParent().getName()]], tiff ]}
.transpose(by: [1])
.flatten()
.collate(2)
.groupTuple()
Expand Down Expand Up @@ -167,27 +169,6 @@ workflow IMCYTO {

}

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FUNCTIONS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

// Function to get list of [ [ id: sample_id, roi: roi_id ], path_to_file ]
def flattenTiff(ArrayList channel) {
def new_array = []
def file_list = channel[1]
for (int i=0; i<file_list.size(); i++) {
def item = []
def meta = channel[0].clone()
meta.roi = file_list[i].getParent().getParent().getName()
item.add(meta)
item.add(file_list[i])
new_array.add(item)
}
return new_array
}

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE END
Expand Down

0 comments on commit eb33fac

Please sign in to comment.