Skip to content

Commit

Permalink
Update groupTuple for merging and fix input sorting for Zerone - reso…
Browse files Browse the repository at this point in the history
…lves #3
  • Loading branch information
emi80 committed Dec 15, 2017
1 parent f0319d7 commit 02f0b04
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions chipseq-pipeline.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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';
Expand All @@ -261,6 +261,8 @@ process mergeBam {
"""
}

mergedBams.println()
return

singleBams
.mix(mergedBams)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
"""
}

Expand Down

0 comments on commit 02f0b04

Please sign in to comment.