1
$\begingroup$

I’m using STAR to align fastq files from SMART-seq2. I have raw data folder containing sub-folders with samples names the sub-folders each contain fastq file. How can I make a bash command in order for STAR to go in each of sub-folders and make alignment for the fastq file and retrieve the bam files in one folder?

Folder structure:

/plates/plate_1/rawdata/A1/A1_R1.fastq
/plates/plate_1/rawdata/B1/B1_R1.fastq
...
/plates/plate_1/rawdata/O24/O24_R1.fastq
/plates/plate_1/rawdata/P24/P24_R1.fastq

It’s 384 sample folders A1, A2, B3, F5,,, so on

$\endgroup$
1
  • $\begingroup$ Thanks I added the path structure $\endgroup$ Mar 5, 2021 at 7:13

1 Answer 1

2
$\begingroup$

It seems the sequencing is single-end, and there is only one fastq per sample. If so:

staridx=/path/to/star/genome/index

mkdir /plates/star/
cd /plates/star/

files=$(find /plates/plate_1/rawdata/ -name "*_R1.fastq")

for i in ${files}
do

  sample=$(basename $i "_R1.fastq")

  STAR --genomeDir $staridx --runThreadN 8 --outFileNamePrefix ${sample}. \
    --readFilesIn $i --outSAMtype BAM

done

All fastq files will be mapped individually, and all bam files will be saved to /plates/star/.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.