轉(zhuǎn)錄組分析使用stringtie定量后,如果使用DESeq2進(jìn)行下游分析瓷叫,需要使用prepDE.py生成read counts矩陣屯吊,prepDE.py需要fastq文件的read平均長度,可用以下腳本實(shí)現(xiàn)摹菠。
運(yùn)行方式:
sh fastq_average_read_length.sh /home/user/fastq_dir (fastq文件路徑)
腳本內(nèi)容:
#!/bin/bash
P=${1}
ls ${P} | grep "_paired_fastq.gz" | less > ${P}/fastq_paired_list.txt
for i in $(cat "${P}/fastq_paired_list.txt") ; do
zcat ${P}/${i} | awk '{if(NR%4==2) print length($1)}'| awk -v i="${i}" '{sum+=$1} END {print i, sum/NR}' ;
done > fastq_average_length.txt
cat fastq_average_length.txt | awk '{sum+=$2} END {print "samples_average", sum/NR}' | less >> fastq_average_length.txt
sed -i "1ifastq average_read_length" fastq_average_length.txt