——title: "_systemPipeR_: NGS工作流和报告生成环境" author: " author: Thomas Girke (thomas.girke@ucr.edu)" date: "Last update: ' r format(Sys.time(), '%d %B, %Y') ' "围嘴。 ```{r style,echo = false,结果='asis'}生物焦质:: markdown()选项(width = 100,max.print = 1000)knitr :: opts_chunk $ set(eval = as.logical(sys。getEnv(“knitr_eval”,“true”),cache = as.logical(sys.getenv(“true”),“true”)),警告= false,message = false)```注意:最新版本可以找到本教程这里以及一个简短的幻灯片概述[这里](https://docs.google.com/presentation/d/175aup31LvnbIJUAvEEoSkpGsKgtBJ2RpQYd0Gs23dLo/embed?start=false&loop=false&delayms=60000)。#介绍幻灯片见[此处](https://docs.google.com/presentation/d/175aup31LvnbIJUAvEEoSkpGsKgtBJ2RpQYd0Gs23dLo/embed?start=false&loop=false&delayms=60000)。# Background [_ ' systemPipeR ' _](//www.andersvercelli.com/packages/devel/bioc/html/systemPipeR.html)为广泛的下一代序列(NGS)应用程序(如RNA-Seq, ChIP-Seq, VAR-Seq和Ribo-Seq)构建和运行自动化的端到端的分析工作流提供实用工具[@Girke2014-oy]。重要的特性包括跨不同NGS应用程序的统一工作流接口,自动报告生成,以及支持在本地计算机或计算集群上运行R和命令行软件,如NGS对齐器或峰值/变量调用器。后者支持交互式作业提交和批量提交到集群的排队系统。例如,_ ' systemPipeR ' _可以用于大多数命令行对齐器,如' BWA ' [@Li2013-oy;@Li2009-oc], ' TopHat2 ' [@Kim2013-vg]和' Bowtie2 ' [@Langmead2012-bs],以及基于r的NGS对齐子[_ ' Rsubread ' _](//www.andersvercelli.com/packages/devel/bioc/html/Rsubread.html) [@Liao2013-bn]和[_ ' gsnap (gmapR) ' _](//www.andersvercelli.com/packages/devel/bioc/html/gmapR.html) [@Wu2010-iq]。有效地处理复杂的样本集。定义良好的样本注释基础设施促进了实验设计,该基础设施提高了NGS领域许多典型分析工作流的可重复性和用户友好性[@Lawrence2013-kt]。_ ' sytemPipeR ' _环境的动机和优点: Facilitates design of complex NGS workflows involving multiple R/Bioconductor packages 2. Common workflow interface for different NGS applications 3. Makes NGS analysis with Bioconductor utilities more accessible to new users 4. Simplifies usage of command-line software from within R 5. Reduces complexity of using compute clusters for R and command-line software 6. Accelerates runtime of workflows via parallelzation on computer systems with mutiple CPU cores and/or multiple compute nodes 6. Automates generation of analysis reports to improve reproducibility A central concept for designing workflows within the _`sytemPipeR`_ environment is the use of workflow management containers called _`SYSargs`_ (see Figure 1). Instances of this S4 object class are constructed by the _`systemArgs`_ function from two simple tabular files: a _`targets`_ file and a _`param`_ file. The latter is optional for workflow steps lacking command-line software. Typically, a _`SYSargs`_ instance stores all sample-level inputs as well as the paths to the corresponding outputs generated by command-line- or R-based software generating sample-level output files, such as read preprocessors (trimmed/filtered FASTQ files), aligners (SAM/BAM files), variant callers (VCF/BCF files) or peak callers (BED/WIG files). Each sample level input/outfile operation uses its own _`SYSargs`_ instance. The outpaths of _`SYSargs`_ usually define the sample inputs for the next _`SYSargs`_ instance. This connectivity is established by writing the outpaths with the _`writeTargetsout`_ function to a new _`targets`_ file that serves as input to the next _`systemArgs`_ call. Typically, the user has to provide only the initial _`targets`_ file. All downstream _`targets`_ files are generated automatically. By chaining several _`SYSargs`_ steps together one can construct complex workflows involving many sample-level input/output file operations with any combinaton of command-line or R-based software. ![](images/SystemPipeR_Workflow.png)
**图1:** Systempiper **工作流程设计结构*

运行_`sytempiper`_工作流程的预期方法是通过_` * .rnw`_或_` * .rmd`_文件,它可以在交互模式下或从r或r的单个命令执行命令行使用[_`makefile`_](https://github.com/tgirke/systempiper/blob/master/inst/extdata/makefile)。这种方式,可以以完全自动化的方式在PDF或HTML格式中以完全自动化的方式生成全面和可重复的分析报告,利用R的高函数报告实用程序,用于设置自定义项目报告,提供为_` * .rnw`_提供文件由帮助程序包_`systempiperdata`_和_`systempiper`_的vignettes子目录中。这些报告模板的相应PDF可在此处提供:[_`SystempipernaSeq`_](https://github.com/tgirke/systempiper/blob/master/vignettes/systempiphaseq.pdf?raw=true),[_`systempiperiboseq`_](https://github.com/tgirke/systempiper/blob/master/vignettes/systempiperiboseq.pdf?raw=true),[_`systempipechipseq`_](https://github.com/tgirke/systempiper/blob/master/vignettes/systempipechipseq.pdf?raw=true)和[_`systempipevarseq`_](https://github.com/tgirke/systempiper/blob/master/vignettes/systempipevarseq.pdf?raw=true)。有效地与_` * .rnw`_或_` * .rmd`_文件一起工作,基本知识[_`sweave`_](https://www.stat.uni-muenchen.de/~eleisch/sweave/)或[_`knitr`_](http://yihui.name/knitr/)和[_`latex`_](http://www.latex-project.org/)或[_`r markdownv2`_](http://rmarkdown.rstudio.com/)是必需的。
[返回目录]()
#入门##下载本教程的最新版本,在本教程中有一个较新版本,下载其`systempiper_intro.rmd`源并在您的R IDE中打开它(例如Vim-R或Rstudio)。```{r download_latest,eval = false} download.file(“https://raw.githubusercontent.com/tgirke/systempiperdata/master/vignettes/systempiper_intro.rmd”,“systempiper_intro.rmd”)```##安装R软件以运行[_`systempiper`_](http://www.biocidodder.org/packages/devel/bioc/html//ystempiper.html)可以从[_cran_]下载(http:// cran。at.r-project.org/)。可以使用_`bioclite`_ install命令从r控制台安装_`systempiper`_环境。关联的数据包[_`systempiperdata`_](https://github.com/tgirke/systempiperdata)可以同样安装。后者是用于生成_`Systempiper`_工作流环境的帮助程序包,其中包含包含快速测试和运行工作流程所需的所有参数文件和所需的示例数据。```{r install,eval = false} source(“http://biocondudion.org/bioclite.r”)#sources the bioclite.r安装脚本bioclite(“systempiper”)#安装systempiper bioclite(“systempiperdata”)#安装systempiperdata```
[返回目录]()
##加载包和文档```{r文档,eval = false}库(“systempiper”)#加载包库(帮助=“systempiper”)#列表包信息小插图(“systempiper”)#打开小插图````
[返回目录]()
##加载样本数据和工作流模板此概述Vignette使用的Mini示例FASTQ文件以及相关的工作流程报告Vignettes可以通过_`systempiperdata`_软件包加载,如下所示。所选数据集[`srp010938`](http://www.ncbi.nlm.nih.gov/sra/?Term=srp010938)包含18个成对端(PE)读取_ARabidposis thaliana_ [Howard2013-FQ]。为了最大限度地减少测试期间的处理时间,每个FASTQ文件已经分配到90,000-100,000个随机采样的PE读取到_A的每种染色体的前100,000个核苷酸。Thalina_ Genome。相应的相应参考基因组序列(FASTA)及其GFF注释文件(在同一下载中提供)已相应截断。这样,整个测试样本数据集需要小于200MB的磁盘存储空间。已选择PE读取集以用于该测试数据集以进行灵活性,因为它可以用于测试需要SE(单端)读取或PE读取的两种类型的分析例程。以下内容在R会话的当前工作目录中生成完全填充的_`Systempiper`_工作流环境(此处用于RNA-SEQ)。此时,包包括RNA-SEQ,CHIP-SEQ,VAR-SEQ和RIBO-SEQ的工作流模板。将来将提供额外的NGS应用程序的模板。 ```{r genRna_workflow, eval=FALSE} library(systemPipeRdata) genWorkenvir(workflow="rnaseq") setwd("rnaseq") ``` The working environment of the sample data loaded in the previous step contains the following preconfigured directory structure. Directory names are indicated in_**灰色**_。用户可以根据需要更改此结构,但需要相应地调整工作流中的代码。*_ **工作流/ ** _(_e.g.__rnaseq / _)+这是运行工作流的R会话的目录。+运行脚本(_ \ *。rnw_或_ \ *。rmd_)和样本注释(_targets.txt_)文件位于这里。+注意,此目录可以有任何名称(_e.g.__ ** rnaseq ** __ ** varseq ** _)。更改其名称不需要运行脚本中的任何修改。+重要子目录:+_ ** param / ** _+存储参数文件,例如:_\*。param_, _ \ *。tmpl_和_ \ \ _run.sh_。+_**数据/**_+ FASTQ样本+参考FASTA文件+注释+等+_ **结果/ ** _+对齐,变体和峰值文件(BAM,VCF,BAD)+表格结果文件+图像和绘图+等。以下参数文件包含在每个工作流程模板中:1。_`targets.txt`_:所提供的首字母用户;下游_`targets _ *。txt`_文件自动生成2. _` * .param`_:定义输入/输出文件操作的参数,_e.g.__`trim.param`_,_`bwa.param`_,_`vartools.parm`_,... 3. _` * _run.sh`_:可选bash脚本,_e.g._:_`gatk_run.sh`_ 4.计算群集环境(跳过单机):+ _`.batchjobs`_:为_`batchjobs`_ + _` * .tmpl`_的类型定义调度程序类型:指定系统使用的调度程序的参数_e.g._扭矩,sge,starcluster,slurm等。
[返回目录]()
_ ' targets ' _ file定义了所有的输入文件(例如:_ FASTQ, BAM, BCF)和分析工作流的样本比较。下面显示了包中包含的示例_ ' targets ' _文件的格式。它也可以从_' systemPipeR ' _'的GitHub知识库[这里](https://github.com/tgirke/systemPipeR/blob/master/inst/extdata/targets.txt)查看和下载。在具有单一类型输入文件的目标文件中,这里是单端(SE)读取的FASTQ文件,前三列是强制性的,包括它们的列名,而PE读取的FASTQ文件是强制性的四列。所有后续列都是可选的,并且可以根据需要添加任意数量的附加列。###结构_ ' targets ' _ file for single end (SE) samples ' ' {r targetsSE, eval=TRUE}文件(“extdata”、“目标。systemPipeR . txt", package="systemPipeR")char = " # ")要处理自定义数据,用户需要生成一个_ ' targets ' _文件,其中包含到他们自己的FASTQ文件的路径,然后在_ ' targetspath ' _下提供到相应的_ ' targets ' _文件的路径。
[返回目录]()
###Alte _`targets`_ for配对结束的文件(pe)样本```{r targetspe,eval = true} targetspath < - system.file(“extdata”,“targetspe.txt”,package =“systempiper“)read.delim(targetspath,comment.char =”#“)[1:2,1:6]```
[返回目录]()
###样本比较采样比较在_`targets`_文件的标题行中定义,以'``# ’”。函数_ ' readComp ' _导入比较信息并将其存储在_ ' list ' _中。另外,_ ' readComp ' _可以从相应的_ ' SYSargs ' _对象中获得比较信息(见下文)。注意,这些标题行是可选的。它们主要用于根据某些生物学期望控制比较分析,例如在基于简单的成对比较的RNA-Seq实验中识别差异表达基因。```{r targetscomp, eval=TRUE} readComp(file=targetspath, format="vector", delim="-")' ' '
[返回目录]()
_ ' param ' _文件定义了所选命令行软件的参数。下面显示了这个包提供的样例_ ' param ' _文件的格式。' ' ' {r param_structure, eval = TRUE} parampath < -系统。文件(“extdata”、“大礼帽。param”,包= " systemPipeR”)_`systemArgs` `函数导入_`param` `文件和_`targets`文件的定义,并将所有相关信息存储在_`SYSargs` `对象(S4类)中。要在没有命令行软件的情况下运行管道,可以将_ ' NULL ' _分配给_ ' sysma ' _,而不是_ ' param ' _文件。此外,可以通过提供目标文件(其中_ ' FileName ' _列提供到BAM文件的路径)来使用预先生成的BAM文件启动_ ' systemPipeR ' _工作流。注意,在下面的示例中,_ ' suppressWarnings() ' _的使用只与构建这个小部件相关。在典型的工作流中,应该删除它。有几种访问方法是根据_ ' SYSargs ' _对象的槽名命名的。 ```{r sysarg_access, eval=TRUE} names(args) ``` Of particular interest is the _`sysargs()`_ method. It constructs the system commands for running command-lined software as specified by a given _`param`_ file combined with the paths to the input samples (_e.g._ FASTQ files) provided by a _`targets`_ file. The example below shows the _`sysargs()`_ output for running TopHat2 on the first PE read sample. Evaluating the output of _`sysargs()`_ can be very helpful for designing and debugging _`param`_ files of new command-line software or changing the parameter settings of existing ones. ```{r sysarg_access2, eval=TRUE} sysargs(args)[1] modules(args) cores(args) outpaths(args)[1] ``` The content of the _`param`_ file can also be returned as JSON object as follows (requires _`rjson`_ package). ```{r sysarg_json, eval=TRUE} systemArgs(sysma=parampath, mytargets=targetspath, type="json") ```
[返回目录]()
#更多细节见`systempiper`vignette [这里](https://biocumon.org/packages/release/bioc/vignettes/systempiper/inst/doc/systempiper.html#workflow-overview)。#workflow demo ribo-seq示例[这里](https://htmlpreview.github.io/?https://raw.githubusercontent.com/tgirke/systempiperdata/master/inst/seizdata/workflows/riboseq/systempiperiboseq.html)
[返回目录]()
#版本信息```{r senutioninfo} sessioninfo()````
[返回目录]()
#参考文献