We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent df69b8f commit b5c63a9Copy full SHA for b5c63a9
docs/snippets/grouptuple-groupkey.nf
@@ -1,12 +1,13 @@
1
-chr_frequency = ["chr1": 2, "chr2": 3]
2
-
3
Channel.of(
4
- ['region1', 'chr1', '/path/to/region1_chr1.vcf'],
5
- ['region2', 'chr1', '/path/to/region2_chr1.vcf'],
6
- ['region1', 'chr2', '/path/to/region1_chr2.vcf'],
7
- ['region2', 'chr2', '/path/to/region2_chr2.vcf'],
8
- ['region3', 'chr2', '/path/to/region3_chr2.vcf']
+ ['chr1', ['/path/to/region1_chr1.vcf', '/path/to/region2_chr1.vcf']],
+ ['chr2', ['/path/to/region1_chr2.vcf', '/path/to/region2_chr2.vcf', '/path/to/region3_chr2.vcf']],
9
)
10
- .map { region, chr, vcf -> tuple( groupKey(chr, chr_frequency[chr]), vcf ) }
+ .flatMap { chr, vcfs ->
+ vcfs.collect { vcf ->
+ tuple(groupKey(chr, vcfs.size()), vcf) // preserve group size with key
+ }
+ .view { v -> "scattered: ${v}" }
11
.groupTuple()
12
- .view()
+ .map { key, vcfs -> tuple(key.getGroupTarget(), vcfs) } // unwrap group key
13
+ .view { v -> "gathered: ${v}" }
docs/snippets/grouptuple-groupkey.out
@@ -1,2 +1,7 @@
-[chr1, [/path/to/region1_chr1.vcf, /path/to/region2_chr1.vcf]]
-[chr2, [/path/to/region1_chr2.vcf, /path/to/region2_chr2.vcf, /path/to/region3_chr2.vcf]]
+scattered: [chr1, /path/to/region1_chr1.vcf]
+scattered: [chr1, /path/to/region2_chr1.vcf]
+scattered: [chr2, /path/to/region1_chr2.vcf]
+scattered: [chr2, /path/to/region2_chr2.vcf]
+scattered: [chr2, /path/to/region3_chr2.vcf]
+gathered: [chr1, [/path/to/region1_chr1.vcf, /path/to/region2_chr1.vcf]]
+gathered: [chr2, [/path/to/region1_chr2.vcf, /path/to/region2_chr2.vcf, /path/to/region3_chr2.vcf]]
0 commit comments