FeatureCounts Error (ERROR: temporary directory is not writable)
1
0
Entering edit mode
5 months 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 • 447 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
4
Entering edit mode
4 months 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: 1498 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