<p>not gnuparallel but <strong>nextflow</strong>. I don't know macs and what is 'first.bam' and 'second.bam' is not clear not me but I hope you'll get the idea.</p>

<p>The nextflow:</p>

<pre><code>Channel.fromPath(params.bams).splitCsv(header: false,sep:'\t',strip:true).map{T-&gt;file(T[0])}.into{bams1;bams2}

boolean isControl(file) {
    return file.name.endsWith("_Input_sorted.bam_rem.bam") || file.name.endsWith("_IgG_sorted.bam_rem.bam ");
    }

bams1.filter{T-&gt;isControl(T)}.set{controls}
bams2.filter{T-&gt;!isControl(T)}.set{experiment}

process mac {
    maxForks 14
    tag "<span class="math-container">${bam1} vs $</span>{bam2}"
    input:
        set bam1 , bam2  from experiment.combine(controls)
    output:
        file("output.peaks") into mac_peak
    script:
    """
    # check syntax please
    macs2 callpeak -t {bam1.toRealPath()}  -c ${bam2.toRealPath()} -g hs -n out-model -q 0.01 --outdir output.peaks
    """
    }     
</code></pre>

<p>invoke:</p>

<pre><code>find /dir1/dir2 -type f -name "*.bam" &gt; input.list

nextflow run --bams input.list workflow.nf
</code></pre>

CC BY-SA 4.0
2020-03-02T17:23:40.727Z
okay let me give it a try first and update you.
kcm
CC BY-SA 4.0
2020-03-02T17:48:48.163Z
my first try ended up like this "Not a valid project name: workflow.nf" I need to read the basics of nextflow
kcm
CC BY-SA 4.0
2020-03-03T06:21:27.133Z
first bam is my Control_H2BUb and PTPN6_g2_6_H2Bub , and it should be compared with samples labelled Control_Input,Control_IgG and PTPN6_g2_6_Input which are second bam. But the catch is the Control lablled samples should always be compared with the control labelled and same goes with PTPN6 labelled
kcm
CC BY-SA 4.0
2020-03-02T13:47:48.827Z
2020-03-02T13:47:48.827Z
Pierre
<p>These are the list of files </p>

<pre><code>Control_Input_sorted.bam_rem.bam  
Control_H2BUb_sorted.bam_rem.bam  
Control_IgG_sorted.bam_rem.bam 
PTPN6_g2_6_H2Bub_sorted.bam_rem.bam  
PTPN6_g2_6_Input_sorted.bam_rem.bam
</code></pre>

<p>So to get unique files i do this</p>

<pre><code> ls -1 *bam | sort | sed -r 's/_sorted.bam_rem.bam//g' | sort | uniq 
Control_Input
Control_H2BUb
Control_IgG
PTPN6_g2_6_H2Bub
PTPN6_g2_6_Input
</code></pre>

<p>Now i have to run each sample against input and IgG for peak-calling.
Like  <code>Control_H2BUb_sorted.bam_rem.bam</code> against </p>

<pre><code>Contol_Input_sorted.bam_rem.bam &amp; Control_IgG_sorted.bam_rem.bam and 


PTPN6_g2_6_H2Bub_sorted.bam_rem.bam against PTPN6_g2_6_Input_sorted.bam_rem.bam
</code></pre>

<p>So how do I parse and execute using gnu parallel.</p>

<p>I came across this <a href="http://crazyhottommy.blogspot.com/2015/09/macs2-parallel-peak-calling.html" rel="nofollow noreferrer">tutorial</a> where it does something like this</p>

<pre><code>cat sample_names.txt | parallel --max-procs=12 'macs2 callpeak -t {}-A-NC.sorted.bam \
 -c {}-G-NC.sorted.bam -g hs -n {}-A-NC-sharp-model -q 0.01 --outdir {}-A-NC-sharp-model-peaks 2&gt; {}-A-NC-sharp-model.stderr'
</code></pre>

<p>Now im not sure how to pass the file names as argument for IP and Input or IgG.</p>

<p>If i use logic a little bit i have to fix Control and PTPN6_g2_6 as constant naming!.</p>

<p>Any suggestion or help would be really appreciated.</p>

<shell><macs2>
gnu parallel for macs peak calling
# gnu parallel for macs peak calling

(Asked by: username_0 on 2020-03-02)

These are the list of files 
Control_Input_sorted.bam_rem.bam  
Control_H2BUb_sorted.bam_rem.bam  
Control_IgG_sorted.bam_rem.bam 
PTPN6_g2_6_H2Bub_sorted.bam_rem.bam  
PTPN6_g2_6_Input_sorted.bam_rem.bam

So to get unique files i do this
 ls -1 *bam | sort | sed -r 's/_sorted.bam_rem.bam//g' | sort | uniq 
Control_Input
Control_H2BUb
Control_IgG
PTPN6_g2_6_H2Bub
PTPN6_g2_6_Input

Now i have to run each sample against input and IgG for peak-calling.
Like  Control_H2BUb_sorted.bam_rem.bam against 
Contol_Input_sorted.bam_rem.bam & Control_IgG_sorted.bam_rem.bam and 


PTPN6_g2_6_H2Bub_sorted.bam_rem.bam against PTPN6_g2_6_Input_sorted.bam_rem.bam

So how do I parse and execute using gnu parallel.
I came across this tutorial where it does something like this
cat sample_names.txt | parallel --max-procs=12 'macs2 callpeak -t {}-A-NC.sorted.bam \
 -c {}-G-NC.sorted.bam -g hs -n {}-A-NC-sharp-model -q 0.01 --outdir {}-A-NC-sharp-model-peaks 2> {}-A-NC-sharp-model.stderr'

Now im not sure how to pass the file names as argument for IP and Input or IgG.
If i use logic a little bit i have to fix Control and PTPN6_g2_6 as constant naming!.
Any suggestion or help would be really appreciated.

**Tags:** shell, macs2

---

## 1 answers

### Answer by username_1 on 2020-03-02. Score: 1 | Accepted answer

not gnuparallel but nextflow. I don't know macs and what is 'first.bam' and 'second.bam' is not clear not me but I hope you'll get the idea.
The nextflow:
Channel.fromPath(params.bams).splitCsv(header: false,sep:'\t',strip:true).map{T->file(T[0])}.into{bams1;bams2}

boolean isControl(file) {
    return file.name.endsWith("_Input_sorted.bam_rem.bam") || file.name.endsWith("_IgG_sorted.bam_rem.bam ");
    }

bams1.filter{T->isControl(T)}.set{controls}
bams2.filter{T->!isControl(T)}.set{experiment}

process mac {
    maxForks 14
    tag "${bam1} vs ${bam2}"
    input:
        set bam1 , bam2  from experiment.combine(controls)
    output:
        file("output.peaks") into mac_peak
    script:
    """
    # check syntax please
    macs2 callpeak -t {bam1.toRealPath()}  -c ${bam2.toRealPath()} -g hs -n out-model -q 0.01 --outdir output.peaks
    """
    }     

invoke:
find /dir1/dir2 -type f -name "*.bam" > input.list

nextflow run --bams input.list workflow.nf

> **Comments:**
> **username_0**: okay let me give it a try first and update you.  
> **username_0**: my first try ended up like this "Not a valid project name: workflow.nf" I need to read the basics of nextflow  
> **username_0**: first bam is my Control_H2BUb and PTPN6_g2_6_H2Bub , and it should be compared with samples labelled Control_Input,Control_IgG and PTPN6_g2_6_Input which are second bam. But the catch is the Control lablled samples should always be compared with the control labelled and same goes with PTPN6 labelled  

---

