Rfastp 1.0.0
The Rfastp package provides an interface to the all-in-one preprocessing for FastQ files toolkit fastp(Chen et al. 2018).
Use the BiocManager package to download and install the package from
Bioconductor as follows:
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("Rfastp")If required, the latest development version of the package can also be installed from GitHub.
BiocManager::install("remotes")
BiocManager::install("RockefellerUniversity/Rfastp")Once the package is installed, load it into your R session:
library(Rfastp)The package contains three example fastq files, corresponding to a single-end fastq file, a pair of paired-end fastq files.
se_read1 <- system.file("extdata","Fox3_Std_small.fq.gz",package="Rfastp")
pe_read1 <- system.file("extdata","reads1.fastq.gz",package="Rfastp")
pe_read2 <- system.file("extdata","reads2.fastq.gz",package="Rfastp")
outputPrefix <- tempfile(tmpdir = tempdir())Rfastp support multiple threads, set threads number by parameter thread.
se_json_report <- rfastp(read1 = se_read1, 
    outputFastq = paste0(outputPrefix, "_se"), thread = 4)pe_json_report <- rfastp(read1 = pe_read1, read2 = pe_read2,
    outputFastq = paste0(outputPrefix, "_pe"))pe_merge_json_report <- rfastp(read1 = pe_read1, read2 = pe_read2, merge = TRUE,
    outputFastq = paste0(outputPrefix, '_unpaired'),
    mergeOut = paste0(outputPrefix, "_merged.fastq.gz"))umi_json_report <- rfastp(read1 = pe_read1, read2 = pe_read2, 
    outputFastq = paste0(outputPrefix, '_umi1'), umi = TRUE, umiLoc = "read1",
    umiLength = 16)the following example will add prefix string before the UMI sequence in the sequence name. An “_" will be added between the prefix string and UMI sequence. The UMI sequences will be inserted into the sequence name before the first space.
umi_json_report <- rfastp(read1 = pe_read1, read2 = pe_read2, 
    outputFastq = paste0(outputPrefix, '_umi2'), umi = TRUE, umiLoc = "read1",
    umiLength = 16, umiPrefix = "#", umiNoConnection = TRUE, 
    umiIgnoreSeqNameSpace = TRUE)Trim poor quality bases at 3’ end base by base with quality higher than 5; trim poor quality bases at 5’ end by a 29bp window with mean quality higher than 20; disable the polyG trimming, specify the adapter sequence for read1.
clipr_json_report <- rfastp(read1 = se_read1, 
    outputFastq = paste0(outputPrefix, '_clipr'),
    disableTrimPolyG = TRUE,
    cutLowQualFront = TRUE,
    cutFrontWindowSize = 29,
    cutFrontMeanQual = 20,
    cutLowQualTail = TRUE,
    cutTailWindowSize = 1,
    cutTailMeanQual = 5,
    minReadLength = 29,
    adapterSequenceRead1 = 'GTGTCAGTCACTTCCAGCGG'
)rfastq can accept multiple input files, and it will concatenate the input files into one and the run fastp.
pe001_read1 <- system.file("extdata","splited_001_R1.fastq.gz",
    package="Rfastp")
pe002_read1 <- system.file("extdata","splited_002_R1.fastq.gz",
    package="Rfastp")
pe003_read1 <- system.file("extdata","splited_003_R1.fastq.gz",
    package="Rfastp")
pe004_read1 <- system.file("extdata","splited_004_R1.fastq.gz",
    package="Rfastp")
inputfiles <- c(pe001_read1, pe002_read1, pe003_read1, pe004_read1)
cat_rjson_report <- rfastp(read1 = inputfiles, 
    outputFastq = paste0(outputPrefix, "_merged1"))pe001_read2 <- system.file("extdata","splited_001_R2.fastq.gz",
    package="Rfastp")
pe002_read2 <- system.file("extdata","splited_002_R2.fastq.gz",
    package="Rfastp")
pe003_read2 <- system.file("extdata","splited_003_R2.fastq.gz",
    package="Rfastp")
pe004_read2 <- system.file("extdata","splited_004_R2.fastq.gz",
    package="Rfastp")
inputR2files <- c(pe001_read2, pe002_read2, pe003_read2, pe004_read2)
catfastq(output = paste0(outputPrefix,"_merged2_R2.fastq.gz"), 
    inputFiles = inputR2files)dfsummary <- qcSummary(pe_json_report)p1 <- curvePlot(se_json_report)
p1p2 <- curvePlot(se_json_report, curve="content_curves")
p2dfTrim <- trimSummary(pe_json_report)usage of rfastp:
?rfastpusage of catfastq:
?catfastqusage of qcSummary:
?qcSummaryusage of trimSummary:
?trimSummaryusage of curvePlot:
?curvePlotThank you to Ji-Dung Luo for testing/vignette review/critical feedback, Doug Barrows for critical feedback/vignette review and Ziwei Liang for their support. # Session info
sessionInfo()## R version 4.0.3 (2020-10-10)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.5 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.12-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.12-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
##  [4] LC_COLLATE=C               LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
## [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] Rfastp_1.0.0     BiocStyle_2.18.0
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.5          pillar_1.4.6        compiler_4.0.3      BiocManager_1.30.10
##  [5] plyr_1.8.6          tools_4.0.3         digest_0.6.27       evaluate_0.14      
##  [9] lifecycle_0.2.0     tibble_3.0.4        gtable_0.3.0        pkgconfig_2.0.3    
## [13] rlang_0.4.8         magick_2.5.0        yaml_2.2.1          xfun_0.18          
## [17] stringr_1.4.0       dplyr_1.0.2         knitr_1.30          generics_0.0.2     
## [21] vctrs_0.3.4         grid_4.0.3          tidyselect_1.1.0    glue_1.4.2         
## [25] R6_2.4.1            rmarkdown_2.5       bookdown_0.21       farver_2.0.3       
## [29] ggplot2_3.3.2       purrr_0.3.4         reshape2_1.4.4      magrittr_1.5       
## [33] scales_1.1.1        ellipsis_0.3.1      htmltools_0.5.0     colorspace_1.4-1   
## [37] labeling_0.4.2      stringi_1.5.3       munsell_0.5.0       crayon_1.3.4       
## [41] rjson_0.2.20Chen, Shifu, Yanqing Zhou, Yaru Chen, and Jia Gu. 2018. “fastp: an ultra-fast all-in-one FASTQ preprocessor.” Bioinformatics 34 (17):i884–i890. https://doi.org/10.1093/bioinformatics/bty560.