Question: alignment with STAR for loop multiples files
0
gravatar for eridanus
5 months ago by
eridanus20
eridanus20 wrote:

Hello! I am trying to align multiple fastq files with a loop in Bash (with STAR commands). But it does not work. I think the problem is with --outFileNamePrefix command, but because I am a beginner I cannot fix it. I should note that the directory where the fastq files are saved is totally different than the directory that output files are saved, maybe is this the problem? Thank you so much!! My code is the following one:

for i in my_path/*.fastq;
do ./STAR --genomeDir /path_to_genindex/ \
    --readFilesIn $i \
    --outFilterType BySJout \
    --outFilterMultimapNmax 20 \
    --alignSJoverhangMin 8 \
    --alignSJDBoverhangMin 1 \
    --outFilterMismatchNmax 999 \
    --outFilterMismatchNoverLmax 0.1 \
    --alignIntronMin 20 \
    --alignIntronMax 1000000 \
    --alignMatesGapMax 1000000 \
    --outSAMattributes NH HI NM MD \
    --outSAMtype BAM SortedByCoordinate \
    --quantMode GeneCounts \
    --outFileNamePrefix /my_path/samples/${i%my_path/}
done
rna-seq star alignment • 263 views
ADD COMMENTlink modified 5 months ago by GenoMax96k • written 5 months ago by eridanus20
1

Pick apart the actual sample name from full file name. That then gives you the freedom to reconstruct new names as needed.

Try this:

for i in *R1*.fastq.gz; do name=$(basename ${i} _R1_001.fastq.gz); echo ${name}; done

Once you have the basic sample name use that to extend your loop with right set of options. Following is just an example.

-- readFilesIn ${name}_R1_001.fastq.gz ${name}_R2_001.fastq.gz
-- outFileNamePrefix /path_to/${name}
ADD REPLYlink modified 5 months ago • written 5 months ago by GenoMax96k
1
for i in my_path/*.fastq;

Hello! I am trying to align multiple fastq files with a loop in Bash

you should learn how to use a workflow manager : snakemake, nextflow....

ADD REPLYlink written 5 months ago by Pierre Lindenbaum134k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1033 users visited in the last hour
_