MACS2: Albeit outdir definition, my output goes to folder of input
1
0
Entering edit mode
5.6 years ago
gdeniz ▴ 20

Hi, I seem to have a problem getting my output in the right location. Using the following call..

workdir="$1"
files=($(awk '{print $1}' $2 ))
infile="$workdir"/bam/${files[$SGE_TASK_ID]}.sorted.dedup.bam 
macs2 predictd -i $infile -f BAM -g mm -m 5 50 --outdir "$workdir"/macs2/qc --rfile ${$infile%.sorted.dedup.bam}_model.r

..my input goes to $workdir/bam

Any suggestions? Thanks!

ChIP-Seq MACS2 • 1.4k views
ADD COMMENT
2
Entering edit mode
5.6 years ago
Ram 43k

Your quoting is off by a bit. Here is some cleaned up code:

workdir="$1"
files=($(awk '{print $1}' $2 ))
infile="${workdir}/bam/${files[$SGE_TASK_ID]}.sorted.dedup.bam"
macs2 predictd -i ${infile} -f BAM -g mm -m 5 50 --outdir "${workdir}/macs2/qc" --rfile ${$infile%.sorted.dedup.bam}_model.r

The double quotes should work with the parameter expansion quotes ({}), not isolate the variable to an extent that it renders the context meaningless. EDIT: Your style of quoting is not wrong, it's just different. Sorry!

ADD COMMENT
0
Entering edit mode

Thanks for your suggestions, always happy to improve my quoting. Unfortunately, this didn't seem to solve the issue:

INFO  @ Tue, 04 Sep 2018 08:41:05: # Generate R script for model : /mnt/iscsi_speed/bam/SRR1202461_model.r

Any other ideas? Do you think it is a quoting issue?

ADD REPLY
0
Entering edit mode

Can you verify that the command looks OK? Change the last line to

echo "macs2 predictd -i ${infile} -f BAM -g mm -m 5 50 --outdir \"${workdir}/macs2/qc\" --rfile ${$infile%.sorted.dedup.bam}_model.r"

Also, it would help if you could give an example of how you invoke the script, with actual parameters.

ADD REPLY
0
Entering edit mode

I get the following error:

/opt/sge625/sge/default/spool/go-node-38/job_scripts/114466: line 17: macs2 predictd -i ${infile} -f BAM -g mm -m 5 50 --outdir "${workdir}/macs2/qc" --rfile ${$infile%.sorted.dedup.bam}_model.r: bad substitution

Here an attempt to clarify my parameters:

workdir="/mnt/iscsi_speed"
samples="${workdir}/samplesheet.txt"  #tab-separated text file with file basename in first column
files=($(awk '{print $1}' $samples ))
infile="${workdir}/bam/${files[0]}.sorted.dedup.bam"
macs2 predictd -i ${infile} -f BAM -g mm -m 5 50 --outdir "${workdir}/macs2/qc" --rfile ${$infile%.sorted.dedup.bam}_model.r
ADD REPLY
1
Entering edit mode

Should've spotted this early on: change ${$infile%.sorted.dedup.bam} to ${infile%.sorted.dedup.bam}

ADD REPLY
0
Entering edit mode

Here is the echo'd output:

macs2 predictd -i /mnt/iscsi_speed/blelloch/deniz/buecker2014/naive/bam/SRR1202453.sorted.dedup.bam -f BAM -g mm -m 5 50 --outdir "/mnt/iscsi_speed/macs2/qc" --rfile /mnt/iscsi_speed/bam/SRR1202453_model.r
ADD REPLY
0
Entering edit mode

That echo call made me realize what is wrong:

the $infile variable seems to overwrite the output dir because it contains an absolute path. Changing the call option to:

--rfile $(basename ${infile%.sorted.dedup.bam}_model.r)

solves the problem.

Thanks for pointing me towards the answer!

ADD REPLY

Login before adding your answer.

Traffic: 2909 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6