1- include { DADA2_LEARN_ERRORS } from ' ../../modules/local/learnerrors'
2- include { DADA2_DEREP_SEQS } from ' ../../modules/local/dada2derepseqs'
3- include { DADA2_POOLED_DENOISE } from ' ../../subworkflows/local/dada2_pooled_denoise'
4- include { DADA2_PER_SAMPLE_DENOISE } from ' ../../subworkflows/local/dada2_per_sample_denoise'
1+ include { DADA2_LEARN_ERRORS } from ' ../../modules/local/learnerrors'
2+ include { DADA2_DEREP_SEQS } from ' ../../modules/local/dada2derepseqs'
3+ include { DADA2_POOLED_DENOISE } from ' ../../subworkflows/local/dada2_pooled_denoise'
4+ include { DADA2_PER_SAMPLE_DENOISE as DADA2_PER_SAMPLE_DENOISE_ROUND1 } from ' ../../subworkflows/local/dada2_per_sample_denoise'
5+ include { DADA2_PER_SAMPLE_DENOISE as DADA2_PER_SAMPLE_DENOISE_ROUND2 } from ' ../../subworkflows/local/dada2_per_sample_denoise'
6+ include { DADA2_PER_SAMPLE_DENOISE } from ' ../../subworkflows/local/dada2_per_sample_denoise'
57
68workflow DADA2_DENOISE {
79
@@ -37,20 +39,20 @@ workflow DADA2_DENOISE {
3739 // For this 'batch' run, we use two channels combining the data and
3840 // include whether they are R1 or R1 (a 'readmode') to distinguish them. ch_trimmed_batch
3941
40- ch_dereps_per_read = ch_dereps
42+ ch_trimmed_per_read = ch_trimmed
4143 .map {
4244 [ ' R1' , it[0 ]. single_end ? it[1 ] : it[1 ][0 ] ]
4345 }
4446 .concat(
45- ch_dereps
47+ ch_trimmed
4648 .filter { ! it[0 ]. single_end }
4749 .map {
4850 [ ' R2' , it[1 ][1 ] ]
4951 }
5052 )
5153 .groupTuple(sort : true )
5254
53- DADA2_LEARN_ERRORS (ch_dereps_per_read )
55+ DADA2_LEARN_ERRORS (ch_trimmed_per_read )
5456 ch_errs = DADA2_LEARN_ERRORS . out. error_models
5557
5658 // deal with priors here, which are optional inputs
@@ -64,14 +66,48 @@ workflow DADA2_DENOISE {
6466 if (params. pool == " parallel" ) {
6567 DADA2_PER_SAMPLE_DENOISE (
6668 per_sample_errs,
67- ch_trimmed_parallel ,
69+ ch_dereps ,
6870 for_priors,
69- rev_priors)
71+ rev_priors,
72+ " single-pass" )
7073 ch_merged = DADA2_PER_SAMPLE_DENOISE . out. merged_seqs
7174 ch_inferred = DADA2_PER_SAMPLE_DENOISE . out. inferred
7275 ch_filtered_seqtab = DADA2_PER_SAMPLE_DENOISE . out. filtered_seqtable
76+ ch_versions = ch_versions. mix(DADA2_PER_SAMPLE_DENOISE . out. versions)
7377 } else {
74- error " parallel-pseudo pooling not supported yet"
78+ // error "parallel-pseudo pooling not supported yet"
79+
80+ // For now we keep these separate since this method is *highly*
81+ // experimental!!!!
82+
83+ // Round 1, generate a new set of priors
84+ // Note this can also take an older set of prior data
85+ DADA2_PER_SAMPLE_DENOISE_ROUND1 (
86+ per_sample_errs,
87+ ch_dereps,
88+ for_priors,
89+ rev_priors,
90+ " Round1" )
91+ rnd1_ch_merged = DADA2_PER_SAMPLE_DENOISE_ROUND1 . out. merged_seqs
92+ rnd1_ch_inferred = DADA2_PER_SAMPLE_DENOISE_ROUND1 . out. inferred
93+ rnd1_ch_filtered_seqtab = DADA2_PER_SAMPLE_DENOISE_ROUND1 . out. filtered_seqtable
94+ rnd1_for_priors = DADA2_PER_SAMPLE_DENOISE_ROUND1 . out. for_priors
95+ rnd1_rev_priors = DADA2_PER_SAMPLE_DENOISE_ROUND1 . out. rev_priors
96+ ch_versions = ch_versions. mix(DADA2_PER_SAMPLE_DENOISE_ROUND1 . out. versions)
97+
98+ // Round 2, using priors from round 1 but same error models and dereps
99+ DADA2_PER_SAMPLE_DENOISE_ROUND2 (
100+ per_sample_errs,
101+ ch_dereps,
102+ rnd1_for_priors,
103+ rnd1_rev_priors,
104+ " Round2" )
105+ ch_merged = DADA2_PER_SAMPLE_DENOISE_ROUND2 . out. merged_seqs
106+ ch_inferred = DADA2_PER_SAMPLE_DENOISE_ROUND2 . out. inferred
107+ ch_filtered_seqtab = DADA2_PER_SAMPLE_DENOISE_ROUND2 . out. filtered_seqtable
108+ rnd2_for_priors = DADA2_PER_SAMPLE_DENOISE_ROUND2 . out. for_priors
109+ rnd2_rev_priors = DADA2_PER_SAMPLE_DENOISE_ROUND2 . out. rev_priors
110+ ch_versions = ch_versions. mix(DADA2_PER_SAMPLE_DENOISE_ROUND2 . out. versions)
75111 }
76112 } else {
77113 // TODO: can we even use priors with 'true' or 'pseudo'?
@@ -84,9 +120,21 @@ workflow DADA2_DENOISE {
84120 // and this step, which optionally pools them. For really large runs
85121 // this will use a ton of memory
86122
123+ ch_dereps_per_read = ch_dereps
124+ .map {
125+ [ ' R1' , it[0 ]. single_end ? it[1 ] : it[1 ][0 ] ]
126+ }
127+ .concat(
128+ ch_dereps
129+ .filter { ! it[0 ]. single_end }
130+ .map {
131+ [ ' R2' , it[1 ][1 ] ]
132+ }
133+ )
134+ .groupTuple(sort : true )
135+
87136 DADA2_POOLED_DENOISE (
88- ch_errs,
89- DADA2_LEARN_ERRORS . out. dereps_full
137+ ch_errs, ch_dereps_per_read
90138 )
91139
92140 ch_merged = DADA2_POOLED_DENOISE . out. merged_seqs
0 commit comments