diff --git a/chipseq-pipeline.nf b/chipseq-pipeline.nf index 763614b..427224b 100755 --- a/chipseq-pipeline.nf +++ b/chipseq-pipeline.nf @@ -231,7 +231,7 @@ process mapping { singleBams = Channel.create() groupedBams = Channel.create() -bams.groupTuple(by: [0,3,4]) +bams.groupTuple(by: [0,3,4,5,6]) .choice(singleBams, groupedBams) { it[2].size() > 1 ? 1 : 0 } @@ -246,7 +246,7 @@ process mergeBam { script: def cpus = task.cpus - def prefix = prefix.sort().join(':') + prefix = prefix.sort().join(':') """ ( samtools view -H ${bam} | grep -v '@RG'; @@ -261,6 +261,8 @@ process mergeBam { """ } +mergedBams.println() +return singleBams .mix(mergedBams) @@ -391,7 +393,7 @@ controlBams sampleId = replicateId.replaceAll(/${params.replicatePattern}$/,'') [sampleId, bam, control, mark, view] } -.groupTuple(by:[0,3,4]) +.groupTuple(by:[0,3,4], sort: {it.baseName}) .set {bamsZerone} def globalFragmentLength = params.fragmentLength ?: defaults.fragmentLength @@ -610,9 +612,9 @@ process zerone { def awkScaleMergedBed = '$0~/^#/ || $NF=$NF*1000' def awkMatrix2Bed = '$0~/^#/ || $0=$1 OFS $2 OFS $3 OFS $NF*1000' """ - zerone -c ${params.zeroneMinConfidence} -0 ${control.sort().join(",")} -1 ${bam.sort().join(",")} > ${prefix}_zerone.01 + zerone -c ${params.zeroneMinConfidence} -0 ${control.join(",")} -1 ${bam.join(",")} > ${prefix}_zerone.01 awk -F"\\t" '${awkMatrix2Bed}' OFS="\\t" ${prefix}_zerone.01 > ${prefix}_zerone.bed - zerone -c ${params.zeroneMinConfidence} -l -0 ${control.sort().join(",")} -1 ${bam.sort().join(",")} | awk -F"\\t" '${awkScaleMergedBed}' OFS="\\t" > ${prefix}_zerone_merged.bed + zerone -c ${params.zeroneMinConfidence} -l -0 ${control.join(",")} -1 ${bam.join(",")} | awk -F"\\t" '${awkScaleMergedBed}' OFS="\\t" > ${prefix}_zerone_merged.bed """ }