Channels are asynchronous, which means that outputs from a set of processes will not necessarily be produced in the same order as the corresponding inputs went in. However, the first element into a channel queue is the first out of the queue (First in - First out). This allows processes to run as soon as they receive input from a channel. Channels only send data in one direction, from a producer (a process/operator), to a consumer (another process/operator).
Nextflow distinguishes between two different kinds of channels: queue and value channels.
Queue channels are a type of channel in which data is consumed (used up) to make input for a process/operator. Queue channels can be created in two ways:
The second type of Nextflow channel is a value channel. A value channel is bound to a single value (singleton). A value channel can be used an unlimited number times since its content is not consumed. This is also useful for processes that need to reuse input from a channel, for example, a reference genome sequence file that is required by multiple steps within a process, or by more than one process.
In Nextflow DSL1 queue channels can only be used once in a workflow, either connecting workflow input to process input, or process output to input for another process. In DSL2 we can use a queue channel multiple times.
Queue (consumable) channels can be created using the following channel factory methods.
Channel.of
Channel.fromList
Channel.fromPath
Channel.fromFilePairs
Channel.fromSRA
ch1 = Channel.value('GRCh38')
ch2 = Channel.value(['chr1','chr2','chr3','chr4','chr5'])
chromosome_ch = Channel.of( 'chr1','chr3','chr5','chr7')
ch1.mix(ch2).collect()
Channel.fromPath(“/data/yeast/reads/*”)
Channel.fromPath(“/data/yeast/reads/*_{1,2}.fq”)
Channel.fromFilePairs(“/data/yeast/reads/*_{1,2}.fq”,size:2)
filter(Number)
map({it.replaceAll(“chr”,””)})
flatten()
collect()
collect()