生信:一起读官方文档 Fastp 篇

45 阅读4分钟

一起读官方文档 Fastp 篇

参考文章:

fastp:www.jianshu.com/p/6f492058d…

Trimmomatic:www.biotrainee.com/thread-1484…

fastp介绍

Fastp是一款用于高通量测序数据预处理和质量控制的开源软件。它被广泛应用于测序数据的清洗、修剪和过滤,以提高后续分析的准确性和效率。Fastp具有高度自动化和高性能的特点,能够快速处理大规模的测序数据。

fastp -h 看一下帮助文档

初学主要有几个参数需要注意:

1. 接头处理:fastp 默认自动对接头处理,所以使用 fastp 这个软件对于双端测序数据就不需要进行设置接头序列并进行 cutadapter 了

什么是接头?

接头(Adapter)指的的是在文库构建过程中, 为了后续的 PCR 扩增和序列化, 人为加入到 DNA/RNA 分子末端的一小段已知序列。

常见的接头序列长度在20-30个碱基。例如 Illumina 测序平台使用的接头序列:

Read1: AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC

Read2: AGATCGGAAGAGCGTCGTGTAGGGAAAGAGTGT

在实验添加接头的目的是为了在测序过程中, 标记不同reads来自于哪些分子, 以及确定reads的方向等。

但是在实际测序中, 有时候会出现接头残留或者接头跳跃等问题, 导致reads中包含错误的接头序列。这时就需要进行接头修剪来过滤这些错误序列, 获得干净的读段以进行下游分析。

所以接头本质上是已知的人工序列, 但会对测序质量产生一定的负面影响, 需要通过修剪步骤进行控制。

这个概念可能先学习过 Trimmomatic 会有更好的理解

2. 滑窗质量裁剪

通过 -5 或 -3 开启

很多时候,一个read的低质量序列都是集中在read的末端,也有少部分是在read的开头。fastp支持像Trimmomatic那样对滑动窗口中的碱基计算平均质量值,然后将不符合的滑窗直接剪裁掉。使用-5参数开启在5’端,也就是read的开头的剪裁,使用-3参数开启在3’端,也就是read的末尾的剪裁。使用-W参数指定滑动窗大小,默认是4,使用-M参数指定要求的平均质量值,默认是20,也就是Q20。

3. 通过overlap矫正碱基

img

通过 -c 参数开启自动校正碱基

-c, --correction		enable base correction in overlapped regions (only for PE data), default is disable]

下面是经常用到的参数文档

usage: fastp -i <in1> -o <out1> [-I <in1> -O <out2>] [options...]
options:
  # I/O options   即输入输出文件设置
  -i, --in1                          read1 input file name (string)
  -o, --out1                         read1 output file name (string [=])
  -I, --in2                          read2 input file name (string [=])
  -O, --out2                         read2 output file name (string [=])
  -6, --phred64                      indicates the input is using phred64 scoring (it'll be converted to phred33, so the output will still be phred33)
  -z, --compression                  compression level for gzip output (1 ~ 9). 1 is fastest, 9 is smallest, default is 2. (int [=2])

  # adapter trimming options   过滤序列接头参数设置
  -A, --disable_adapter_trimming     adapter trimming is enabled by default. If this option is specified, adapter trimming is disabled
  -a, --adapter_sequence               the adapter for read1. For SE data, if not specified, the adapter will be auto-detected. For PE data, this is used if R1/R2 are found not overlapped. (string [=auto])
      --adapter_sequence_r2            the adapter for read2 (PE data only). This is used if R1/R2 are found not overlapped. If not specified, it will be the same as <adapter_sequence> (string [=])

  # per read cutting by quality options   划窗裁剪
  -5, --cut_by_quality5              enable per read cutting by quality in front (5'), default is disabled (WARNING: this will interfere deduplication for both PE/SE data)
  -3, --cut_by_quality3              enable per read cutting by quality in tail (3'), default is disabled (WARNING: this will interfere deduplication for SE data)
  -W, --cut_window_size              the size of the sliding window for sliding window trimming, default is 4 (int [=4])

  # base correction by overlap analysis options   通过overlap来校正碱基
  -c, --correction                   enable base correction in overlapped regions (only for PE data), default is disabled

  # reporting options
  -j, --json                         the json format report file name (string [=fastp.json])
  -h, --html                         the html format report file name (string [=fastp.html])
  -R, --report_title                 should be quoted with ' or ", default is "fastp report" (string [=fastp report])
  
  # threading options   设置线程数
  -w, --thread                       worker thread number, default is 3 (int [=3])

注意:-w, --thread: 用于指定线程数,默认值为3, 可以设置为更大数值进行多线程加速。

平时使用直接默认即可:

# fastp质控
for i in `tail -n +2 metadata.txt| cut -f1`
do

fastp -w 20 -i raw/${i}_R1.fq.gz -I raw/${i}_R2.fq.gz \
-o clean/${i}_R1.fastq -O clean/${i}_R2.fastq \
--report_title "${i} fastp report" \
--json clean/${i}_fastp.json --html clean/${i}_fastp.html

done