FeatureCounts Error (ERROR: temporary directory is not writable)
1
0
Entering edit mode
3.4 years ago
foxiw ▴ 10

Hi.

Ive been trying to run feaureCounts on my bam files, however I keep getting this error:

ERROR: temporary directory is not writable: '/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/featurecounts//mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord'

Which is odd because I've been working with trimmomatic, star, and picard and I haven't had any issue like this. My script is as follows:

    #!/bin/bash
#SBATCH --partition=defq       # the requested queue
#SBATCH --nodes=1              # number of nodes to use
#SBATCH --tasks-per-node=1     #
#SBATCH --cpus-per-task=2      #
#SBATCH --mem-per-cpu=10G       # in megabytes, unless unit explicitly stated
#SBATCH --time=3:0:0
#SBATCH --error=%J.err         # redirect stderr to this file
#SBATCH --output=%J.out        # redirect stdout to this file
#SBATCH --mail-type=BEGIN,END,FAIL     # email on job start, end, and/or failure


#Load module

module load subread-2.0.0-gcc-8.3.1-l7x34bp

#Shortcuts

workingdir=/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord
refdir=/mnt/scratch/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/genomeDir


#Make storage directory

mkdir $workingdir/featurecounts

#Loop and run featue counts command

LIST=$workingdir/*Aligned.sortedByCoord.out.bam

for i in $LIST;
do
        featureCounts -T 4 -s 0 \
                -a $refdir/Mus_musculus.GRCm39.104.gtf \
                -o $workingdir/featurecounts/$i.featurecount \
                $workingdir/$i
done

Any help would be much appreciated.

RNA-seq FeatureCounts • 4.6k views
ADD COMMENT
1
Entering edit mode

main issue is likely not having write permission in that specific directory (I know :) ). Can you post the permission status of that folder? Did you script create that featurecount directory in it?

moreover, in your loop you are writing/reading from a dir that I think is not what you expect. Can you add an echo $i in your loop? At first sight $i will also include the directory name again, so likely something will go awol there.

ADD REPLY
0
Entering edit mode

Noob question but how would I check the permission status in linux? Yes, it did create the featurecounts directory (nothing in it though).

I've added the echo (see below)

LIST=$workingdir/*Aligned.sortedByCoord.out.bam

for i in $LIST;
do
        echo $i
        featureCounts -T 4 -s 0 \
                -a $refdir/Mus_musculus.GRCm39.104.gtf \
                -o $workingdir/featurecounts/$i.featurecount \
                $workingdir/$i
done

And I got this in my out log file:

/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample10merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample11merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample12merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample13merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample1merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample2merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample3merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample4merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample5merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample6merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample7merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample8merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
/mnt/data/GROUP-sbiim1/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/star/sortedbycoord/Sample9merge_trimmed_2.fastq.gz-.Aligned.sortedByCoord.out.bam
ADD REPLY
0
Entering edit mode

Figured it out lol. Permission status is as follows:

drwxr-xr-x. 3 c1818206 biosi    4096 Jun 30 17:42 sortedbycoord
ADD REPLY
0
Entering edit mode

Hi all,

I got a similar error: ERROR: temporary directory is not writable: 'Users/Chris/Bash_script/quants'.

My code:

featureCounts -s 2 -a Users/Chris/Bash_script/hg38/Homo_sapiens.GRCh38.106.gtf -o Users/Chris/Bash_script/quants/demo_featurecounts.txt Users/Chris/Bash_script/HISAT2/demo_trimmed.bam

Would anyone please tell me how to fix it? Thank you so much!

ADD REPLY
1
Entering edit mode

You are most likely missing a leading / in front of all file paths.

Users/Chris/Bash_script/hg38/Homo_sapiens.GRCh38.106.gtf

needs to be

/Users/Chris/Bash_script/hg38/Homo_sapiens.GRCh38.106.gtf
ADD REPLY
0
Entering edit mode

Thank GenoMax for your suggestion!

I tried to add / like this:

featureCounts -s 2 -a /Users/Chris/Bash_script/hg38/Homo_sapiens.GRCh38.106.gtf -o /Users/Chris/Bash_script/quants/demo_featurecounts.txt /Users/Chris/Bash_script/HISAT2/demo_trimmed.bam

Then I got a different error:

Failed to open the annotation file /Users/Chris/Bash_script/hg38/Homo_sapiens.GRCh38.106.gtf, or its format is incorrect, or it contains no 'exon' features.

ADD REPLY
1
Entering edit mode

Looks like /Users/Chris/Bash_script/hg38/Homo_sapiens.GRCh38.106.gtf file path is not correct. Make sure you provide correct path for all files. I assume you have simply downloaded Ensembl GTF file and have not made any changes, so "exon" part is not applicable.

ADD REPLY
0
Entering edit mode

You are right. For some reasons, the correct path is:

/Users/Chris/Bash_script/hg38/Homo_sapiens.GRCh38.107.gtf

ADD REPLY
4
Entering edit mode
3.4 years ago
biomon ▴ 60

I think it's because you have an error in your code, you have the directory appearing twice.

LIST=$workingdir/*Aligned.sortedByCoord.out.bam

for i in $LIST;
do
        echo $i
        featureCounts -T 4 -s 0 \
                -a $refdir/Mus_musculus.GRCm39.104.gtf \
                -o $workingdir/featurecounts/$i.featurecount \

## so here you are actually getting -o $workingdir/featurecounts/$workingdir/(SAMPLE_X)Aligned.sortedByCoord.out.bam


                $workingdir/$i
done

Try this instead:

LIST=$workingdir/*Aligned.sortedByCoord.out.bam

for i in $LIST;
do
        echo $i
SAMPLE=$basename($i .bam).featurecount

        featureCounts -T 4 -s 0 \
                -a $refdir/Mus_musculus.GRCm39.104.gtf \
                -o $SAMPLE
                $workingdir/$i
done

Also as a side note you don't need to loop, you can easily just go with one line:

featureCounts -T 4 -s 0 -a /mnt/scratch/c1818206/fastqs/merged_files/trimmedfiles/trimmedfiles_final/genomeDir/Mus_musculus.GRCm39.104.gtf -o counts.file *.Aligned.sortedByCoord.out.bam

Hope you get it working!

ADD COMMENT
0
Entering edit mode

Hi,

Yes - I figured out that I didn't need to loop featurecounts. So I did away with the loop and it worked! This has been my first time going through an RNAseq pipline with my own data so its been a challenge but also rewarding.

Thank you very much for your comment; it is the answer so I'll mark it now :)

ADD REPLY

Login before adding your answer.

Traffic: 2419 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