alignment with STAR for loop multiples files
0
0
Entering edit mode
21 months ago
eridanus ▴ 30

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 alignment STAR • 1.2k views
1
Entering edit mode

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}

1
Entering edit mode
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....