Skip to content

Commit 2dc5965

Browse files
committed
fix genotyping connection to clonal analysis
1 parent 0adede0 commit 2dc5965

3 files changed

Lines changed: 32 additions & 13 deletions

File tree

conf/test_genotyping.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ params {
2828
// Genotyping
2929
genotyping = true
3030
single_clone_representative = true
31-
// Skip clonal analysis
32-
skip_clonal_analysis = true
31+
clonal_threshold = 0.1
32+
skip_report_threshold = true
3333
}

subworkflows/local/clonal_analysis.nf

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,16 @@ workflow CLONAL_ANALYSIS {
8484
it[0].species,
8585
it[0].single_cell,
8686
it[0].locus,
87-
it[1] ] }
87+
it[1],
88+
it[2] ] }
8889
.groupTuple()
8990
.map{ get_meta_tabs(it) }
90-
.set{ ch_repertoire_groupped }
91+
.set{ ch_repertoire_grouped }
92+
93+
ch_repertoire_grouped.dump(tag: "ch_repertoire_grouped")
9194

9295
CLONAL_ASSIGNMENT(
93-
ch_repertoire_reference,
96+
ch_repertoire_grouped,
9497
clone_threshold.collect(),
9598
[]
9699
)
@@ -104,6 +107,8 @@ workflow CLONAL_ANALYSIS {
104107
.map { it -> [ [id:'all_reps'], it ] }
105108
.set{ch_all_repertoires_cloned}
106109

110+
ch_all_repertoires_cloned.dump(tag: "ch_all_repertoires_cloned")
111+
107112
if (!params.skip_all_clones_report){
108113

109114
ch_all_repertoires_cloned_samplesheet = ch_all_repertoires_cloned.map{ it -> it[1] }
@@ -134,17 +139,23 @@ workflow CLONAL_ANALYSIS {
134139

135140
// Function to map
136141
def get_meta_tabs(arr) {
142+
if (arr[2].unique().size() > 1) {
143+
error "Multiple subject_id found for ${arr[0]} (${arr[2].join(', ')}). Please check your input parameters and ensure that all samples with the same 'cloneby' value have the same 'subject_id' value."
144+
}
145+
137146
def meta = [:]
138147
meta.id = [arr[0]].unique().join("")
139148
meta.sample_ids = arr[1]
140-
meta.subject_id = arr[2]
141-
meta.species = arr[3]
149+
meta.subject_id = arr[2].unique().join("")
150+
meta.species = arr[3].unique().join("")
142151
meta.single_cell = arr[4].unique().join("")
143152
meta.locus = arr[5].unique().join("")
144153

145154
def array = []
146155

147-
array = [ meta, arr[6].flatten() ]
148-
156+
array = [ meta, arr[6].flatten(), arr[7].unique() ]
157+
if (arr[7].size() > 1) {
158+
error "Multiple reference fasta files found for ${meta.id}. Please check your input parameters and ensure that all samples with the same ${params.genotypeby} value (parameter 'genotype_by') have the same ${params.cloneby} value (parameter 'clone_by')."
159+
}
149160
return array
150161
}

subworkflows/local/novel_alleles_and_genotyping.nf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,24 @@ workflow NOVEL_ALLELES_AND_GENOTYPING {
119119

120120
// Function to map
121121
def get_meta_tabs(arr) {
122+
if (arr[2].unique().size() > 1) {
123+
error "Multiple subject IDs found for ${arr[0]} (${arr[2].join(', ')}). It is not possible to perform joint genotyping of samples from different subjects. Please check the 'genotypeby' parameter."
124+
}
125+
122126
def meta = [:]
123127
meta.id = [arr[0]].unique().join("")
124128
meta.sample_ids = arr[1]
125-
meta.subject_id = arr[2]
126-
meta.species = arr[3]
129+
meta.subject_id = arr[2].unique().join("")
130+
meta.species = arr[3].unique().join("")
127131
meta.single_cell = arr[4].unique().join("")
128132
meta.locus = arr[5].unique().join("")
129-
130133
def array = []
131134

132-
array = [ meta, arr[6].flatten(), arr[7][0] ]
135+
array = [ meta, arr[6].flatten(), arr[7].unique() ]
136+
if (arr[7].size() > 1) {
137+
error "Multiple reference fasta files found for ${meta.id}."
138+
}
139+
140+
133141
return array
134142
}

0 commit comments

Comments
 (0)