Skip to content

Commit 01d3761

Browse files
edmundmillerclaude
andcommitted
fix: correct nf-schema metadata extraction and control ID matching
Extract metadata correctly from nf-schema structure and transform control references to include replicate suffix for proper IP/control BAM pairing. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3970818 commit 01d3761

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

subworkflows/local/utils_nfcore_chipseq_pipeline/main.nf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,20 @@ def create_fastq_channel(data_list, String seq_center) {
320320
def meta_from_schema = data_list[0]
321321
def fastq_1 = data_list[1]
322322
def fastq_2 = data_list[2]
323-
def replicate = data_list[3] ?: 1
324-
def antibody = data_list[4] ?: ''
325-
def control = data_list[5] ?: ''
326-
def control_replicate = data_list[6] ?: 1
323+
def replicate = meta_from_schema.replicate ?: 1
324+
def antibody = meta_from_schema.antibody ?: ''
325+
def control = meta_from_schema.control ?: ''
326+
def control_replicate = meta_from_schema.control_replicate ?: 1
327+
328+
// Debug output can be enabled for troubleshooting
329+
// log.info "DEBUG: Processing sample - original_id: ${meta_from_schema.id}, replicate: ${replicate}, control: '${control}', control_replicate: ${control_replicate}"
327330

328331
def meta = [:]
329-
meta.id = meta_from_schema.id
332+
meta.id = "${meta_from_schema.id}_rep${replicate}"
330333
meta.single_end = (fastq_2 == null || fastq_2.toString().trim() == '' || fastq_2 instanceof List && fastq_2.isEmpty())
331334
meta.antibody = antibody
332-
meta.control = control
335+
// Transform control reference to include replicate suffix for proper IP/control pairing
336+
meta.control = control ? "${control}_rep${control_replicate}" : control
333337
meta.replicate = replicate
334338
meta.control_replicate = control_replicate
335339

workflows/chipseq.nf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,16 @@ workflow CHIPSEQ {
234234
meta, bam ->
235235
def meta_clone = meta.clone()
236236
meta_clone.remove('read_group')
237-
meta_clone.id = meta_clone.id - ~/_T\d+$/
237+
// Keep samples separate - no merging for this dataset
238+
// Add a unique grouping key to prevent unwanted merging
239+
meta_clone.group_key = meta_clone.id
238240
[ meta_clone, bam ]
239241
}
240242
.groupTuple(by: [0])
241243
.map {
242244
meta, bam ->
245+
// Remove the temporary grouping key
246+
meta.remove('group_key')
243247
[ meta, bam.flatten() ]
244248
}
245249
.set { ch_sort_bam }

0 commit comments

Comments
 (0)