This is a test version of Biostars. For the public version, visit https://www.biostars.org.
error in macs2 usage

I am working with macs2 to find the peaks. I used this command to get .narrowpeak file:

macs2 callpeak -t 866992_part.bam -c 866991_part.bam -f BAM --nomodel -g hs -n example -B -q 0.01 --outdir  peakCall

but bave this error:

AttributeError: 'Namespace' object has no attribute 'tempdir'

if I try this command:

macs2 callpeak -t 866992_part.bam -c 866991_part.bam -f BAM --nomodel -g hs -n example -B -q 0.01 --outdir  /peakCall

, will gives this error:

Output directory (/peakCall) could not be created. Terminating program.

do you know how I can resolve this problem?

next-gen

The second command probably fails because you try to write to the root directory / where you don't have permission as a regular user (I assume you are on a Unix system).

The error from the first command is trickier to troubleshoot from here... This issue seems related https://github.com/taoliu/MACS/issues/61 . What version of macs2 are you using (i.e. what is the output of macs2 --version)?

Also, can you post the full output you see on screen i.e. not just the line AttributeError: 'Namespace' ...?

macs2 2.1.1.20160309

 866992_part.bam -c 866991_part.bam -f BAM --nomodel -g hs -n example -B -q 0.01 --outdir ~/peakCall
INFO  @ Mon, 02 Jan 2017 10:49:21: 
# Command line: callpeak -t 866992_part.bam -c 866991_part.bam -f BAM --nomodel -g hs -n example -B -q 0.01 --outdir /home/peakCall
# ARGUMENTS LIST:
# name = example
# format = BAM
# ChIP-seq file = ['866992_part.bam']
# control file = ['866991_part.bam']
# effective genome size = 2.70e+09
# band width = 300
# model fold = [5, 50]
# qvalue cutoff = 1.00e-02
# Larger dataset will be scaled towards smaller dataset.
# Range for calculating regional lambda is: 1000 bps and 10000 bps
# Broad region calling is off
# Paired-End mode is off

Traceback (most recent call last):
  File "/usr/bin/macs2", line 614, in <module>
    main()
  File "/usr/bin/macs2", line 56, in main
    run( args )
  File "build/bdist.linux-x86_64/egg/MACS2/callpeak_cmd.py", line 68, in run
AttributeError: 'Namespace' object has no attribute 'tempdir'
b

I tried what is mentioned in the link you sent and got the same error

Try macs2 callpeak -t 866992_part.bam -c 866991_part.bam -f BAM --nomodel -g hs -n example -B -q 0.01 --outdir peakCall

3 answers

Have you figured this one out, Sara? I'm running into the exact same issue (using build 2.1.1.20160309). My command looks like:

macs2 callpeak --nomodel --format SAM -t /path/to/somefile.sam --shift -100 --extsize 200 -B --broad --outdir /the/output/dir/

I've also tried without --outdir, but no luck.

BTW, looks like a bug but I'm waiting on the author to confirm. I didn't see where that variable is used anywhere else, so I just changed that line cited in the error message to hardcode the temp directory in my cluster:

tempfile.tempdir = '/tmp/'

Maybe this was intended to have a --tempdir argument that hasn't been implemented yet. So far, it's running...

I can guarantee that the tempdir argument does exist, I use it in my current pipeline. You need at least version macs2 2.1.1.20160309.

was this ever resolved im getting the same error today and i cant find a post with the solution

Traceback (most recent call last): File "/usr/bin/macs2", line 614, in <module> main() File "/usr/bin/macs2", line 56, in main run( args ) File "/usr/local/lib/python2.7/dist-packages/MACS2/callpeak_cmd.py", line 68, in run tempfile.tempdir = options.tempdir AttributeError: 'Namespace' object has no attribute 'tempdir'

Log in to answer this question.