From d4fa90d534b6df04377e3b5902ec6129f1ce6d9f Mon Sep 17 00:00:00 2001 From: Chris Cheshire Date: Wed, 31 Jan 2024 16:44:53 +0000 Subject: [PATCH] Update igg control mapping --- bin/check_samplesheet.py | 29 +++++++++++++++++++++++++++++ workflows/cutandrun.nf | 9 ++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/bin/check_samplesheet.py b/bin/check_samplesheet.py index 628a54b8..f7de0739 100755 --- a/bin/check_samplesheet.py +++ b/bin/check_samplesheet.py @@ -244,6 +244,35 @@ def check_samplesheet(file_in, file_out, use_control): "WARNING: Parameter --use_control was set to false, but an control group was found in " + str(file_in) + "." ) + # Calculate the exact control/replicate id combo + if use_control == "true": + for group, reps in sorted(sample_run_dict.items()): + + # Calculate the ctrl group + ctrl_group = None + is_ctrl = False + for replicate, info in sorted(reps.items()): + ctrl_group = info[0][2] + if ctrl_group == '': + is_ctrl = True + break + + # Continue if ctrl + if is_ctrl: + continue + + # Get num reps + num_reps = len(reps) + num_ctrl_reps = len(sample_run_dict[ctrl_group]) + + # Assign actual ctrl rep id + for rep, info in sorted(reps.items()): + if num_reps == num_ctrl_reps: + ctrl_group_new = ctrl_group + "_" + str(rep) + else: + ctrl_group_new = ctrl_group + "_1" + info[0][2] = ctrl_group_new + ## Write validated samplesheet with appropriate columns if len(sample_run_dict) > 0: out_dir = os.path.dirname(file_out) diff --git a/workflows/cutandrun.nf b/workflows/cutandrun.nf index 5b8a3e01..2cac82e6 100644 --- a/workflows/cutandrun.nf +++ b/workflows/cutandrun.nf @@ -486,15 +486,14 @@ workflow CUTANDRUN { /* * CHANNEL: Create target/control pairings */ - ch_bedgraph_control.map{ row -> [row[0].control_group + row[0].replicate, row] } - .cross( ch_bedgraph_target.map{ row -> [row[0].control_group + row[0].replicate, row] } ) + ch_bedgraph_control.map{ row -> [row[0].control_group + "_" + row[0].replicate, row] } + .cross( ch_bedgraph_target.map{ row -> [row[0].control_group, row] } ) .map { row -> [ row[1][1][0], row[1][1][1], row[0][1][1] ] } .set { ch_bedgraph_paired } // EXAMPLE CHANNEL STRUCT: [[META], TARGET_BEDGRAPH, CONTROL_BEDGRAPH] - //ch_bedgraph_paired | view SEACR_CALLPEAK_IGG ( ch_bedgraph_paired, @@ -510,8 +509,8 @@ workflow CUTANDRUN { /* * CHANNEL: Create target/control pairings */ - ch_bam_control.map{ row -> [row[0].control_group + row[0].replicate, row] } - .cross( ch_bam_target.map{ row -> [row[0].control_group + row[0].replicate, row] } ) + ch_bam_control.map{ row -> [row[0].control_group + "_" + row[0].replicate, row] } + .cross( ch_bam_target.map{ row -> [row[0].control_group, row] } ) .map { row -> [ row[1][1][0], row[1][1][1], row[0][1][1] ]