Skip to content

Commit

Permalink
Update igg control mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-cheshire committed Jan 31, 2024
1 parent f0a800a commit d4fa90d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
29 changes: 29 additions & 0 deletions bin/check_samplesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions workflows/cutandrun.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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] ]
Expand Down

0 comments on commit d4fa90d

Please sign in to comment.