Noob: Help writing this shell for salmon quantification?
2
0
Entering edit mode
2.5 years ago
cdeantoneo31 ▴ 20

I am a total noob here trying to analyze my RNA seq data. I've just started trying to use Salmon for my quantifications, and wanted to use their suggested script for running all of the samples in a loop instead of having to type them all in.

#!/bin/bash
for fn in data/DRR0161{25..40};
do
samp=`basename ${fn}`
echo "Processing sample ${samp}"
salmon quant -i athal_index -l A \
         -1 ${fn}/${samp}_1.fastq.gz \
         -2 ${fn}/${samp}_2.fastq.gz \
         -p 8 --validateMappings -o quants/${samp}_quant
done

However, whenever I try to edit the script for my own files, it gives me an error that basically involves it formatting the file names incorrectly (example below)

    #!/bin/bash
    for fn in *_01.fq.gz;
    do
    samp=`basename ${fn}`
    echo "Processing sample ${samp}"
    salmon quant -i mouse_transcriptome_index -l A \
             -1 ${fn}/${samp}_01.fq.gz \
             -2 ${samp}_02.fq.gz \
             -p 8 -o quants/${samp}_quant
    done

Processing sample *_01.fq.gz
Version Info Exception: server did not respond before timeout
### salmon (selective-alignment-based) v1.5.2
### [ program ] => salmon
### [ command ] => quant
### [ index ] => { mouse_transcriptome_index }
### [ libType ] => { A }
### [ mates1 ] => { *_01.fq.gz/*_01.fq.gz_01.fq.gz }
### [ mates2 ] => { *_01.fq.gz_02.fq.gz }
### [ threads ] => { 8 }
### [ output ] => { quants/*_01.fq.gz_quant }
Logs will be written to quants/*_01.fq.gz_quant/logs
[2021-10-27 13:11:44.725] [jointLog] [info] setting maxHashResizeThreads to 8
[2021-10-27 13:11:44.725] [jointLog] [info] Fragment incompatibility prior below threshold.  Incompatible fragments will be ignored.
[2021-10-27 13:11:44.725] [jointLog] [info] Usage of --validateMappings implies use of minScoreFraction. Since not explicitly specified, it is being set to 0.65
[2021-10-27 13:11:44.725] [jointLog] [info] Setting consensusSlack to selective-alignment default of 0.35.
[2021-10-27 13:11:44.725] [jointLog] [info] parsing read library format
[2021-10-27 13:11:44.725] [jointLog] [info] There is 1 library.
Exception : [
The following errors were detected with the read files
======================================================
ERROR: file [*_01.fq.gz/*_01.fq.gz_01.fq.gz] does not appear to exist!

This is how my files are named

WT_8h_1_01.fq.gz   Za2_8h_1_02.fq.gz
WT_8h_1_02.fq.gz   Za2_8h_2_01.fq.gz
WT_8h_2_01.fq.gz   Za2_8h_2_02.fq.gz
WT_8h_2_02.fq.gz   Za2_8h_1_01.fq.gz

I would appreciate any help in figuring out what I am doing wrong. I have tried changing a bunch of different things but always ultimately end up with the script looking for the wrong files.

salmon rna-seq • 2.0k views
ADD COMMENT
2
Entering edit mode
2.5 years ago

I think you are executing script in wrong directory. Wherever you are executing, files are not there. Even if there are, script would fail due to other issues in the script. Please post output from pwd (bash/zsh), from which ever directory you are executing the script from. Please also post the output from find . -type f -name "*_01.fq.gz"

ADD COMMENT
0
Entering edit mode

you guys were right, i was in the complete wrong directory. That's what I get for making like 6 different folders within folders.

tysm

ADD REPLY
2
Entering edit mode
2.5 years ago
cfos4698 ★ 1.1k

As cpad0112 said make sure you are in the correct directory. Other corrections:

  • you needed to remove another instance of ${fn}/
  • the basename command might not work as you're expecting

Try running the following while you are in the same directory as your reads:

    #!/bin/bash
    for fn in *_01.fq.gz;
    do
    samp=${fn%_01.fq.gz}
    echo "Processing sample ${samp}"
    salmon quant -i mouse_transcriptome_index -l A \
             -1 ${samp}_01.fq.gz \
             -2 ${samp}_02.fq.gz \
             -p 8 -o quants/${samp}_quant
    done
ADD COMMENT
0
Entering edit mode

samp variable may not be necessary.

#! /usr/bin/env bash

for fn in *_01.fq.gz;
do
 echo "Processing sample ${fn%_01.fq.gz}"
 echo salmon quant -i mouse_transcriptome_index -l A \
     -1 ${fn} \
     -2 ${fn/_01.fq.gz/_02.fq.gz} \
     -p 8 -o quants/${fn/_01.fq.gz/}_quant;
done
ADD REPLY

Login before adding your answer.

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