RcwlPipelines is a Bioconductor package that manages a collection of commonly used bioinformatics tools and pipeline based on Rcwl. These pre-built and pre-tested tools and pipelines are highly modularized with easy customization to meet different bioinformatics data analysis needs.

Rcwl and RcwlPipelines together forms a Bioconductor toolchain for use and development of reproducible bioinformatics pipelines in Common Workflow Language (CWL). The project also aims to develop a community-driven platform for open source, open development, and open review of best-practice CWL bioinformatics pipelines.

1 Installation

  1. Install the package from Bioconductor.
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("RcwlPipelines")

The development version is also available to download from GitHub.

BiocManager::install("rworkflow/RcwlPipelines")
  1. Load the package into the R session.
library(RcwlPipelines)

2 Project resources

The project website https://rcwl.org/ serves as a central hub for all related resources. It provides guidance for new users and tutorials for both users and developers. Specific resources are listed below.

2.1 The R recipes and cwl scripts

The R scripts to build the CWL tools and pipelines are now residing in a dedicated GitHub repository, which is intended to be a community effort to collect and contribute Bioinformatics tools and pipelines using Rcwl and CWL.

2.2 Tutorial book

The tutorial book provides detailed instructions for developing Rcwl tools/pipelines, and also includes examples of some commonly-used tools and pipelines that covers a wide range of Bioinformatics data analysis needs.

3 RcwlPipelines core functions

Here we show the usage of 3 core functions: cwlUpdate, cwlSearch and cwlLoad for updating, searching, and loading the needed tools or pipelines in R.

3.1 cwlUpdate

The cwlUpdate function syncs the current Rcwl recipes and returns a cwlHub object which contains the most updated Rcwl recipes. The mcols() function returns all related information about each available tool or pipeline.

The recipes will be locally cached, so users don’t need to call cwlUpdate every time unless they want to use a tool/pipeline that is newly added to RcwlPipelines. Here we are using the recipes from Bioconductor devel version.

## For vignette use only. users don't need to do this step.
Sys.setenv(cachePath = tempdir()) 
atls <- cwlUpdate(branch = "dev") ## sync the tools/pipelines.
atls
#> cwlHub with 196 records
#> cache path:  /tmp/Rtmp587B1r/Rcwl 
#> # last modified date:  2022-02-11 
#> # cwlSearch() to query scripts
#> # cwlLoad('title') to load the script
#> # additional mcols(): rid, rpath, Type, Container, mtime, ...
#> 
#>            title                      
#>   BFC1   | pl_AnnPhaseVcf             
#>   BFC2   | pl_BaseRecal               
#>   BFC3   | pl_BwaAlign                
#>   BFC4   | pl_COMPSRA_rn              
#>   BFC5   | pl_CombineGenotypeGVCFs    
#>   ...      ...                        
#>   BFC192 | tl_vcf_expression_annotator
#>   BFC193 | tl_vcf_readcount_annotator 
#>   BFC194 | tl_vep                     
#>   BFC195 | tl_vep_plugin              
#>   BFC196 | tl_vt_decompose            
#>          Command                                                            
#>   BFC1   VCFvep+dVCFcoverage+rVCFcoverage+VCFexpression+PhaseVcf            
#>   BFC2   BaseRecalibrator+ApplyBQSR+samtools_index+samtools_flagstat+samt...
#>   BFC3   bwa+sam2bam+sortBam+idxBam                                         
#>   BFC4   copy+compsra                                                       
#>   BFC5   CombineGVCFs+GenotypeGVCFs                                         
#>   ...    ...                                                                
#>   BFC192 vcf-expression-annotator                                           
#>   BFC193 vcf-readcount-annotator                                            
#>   BFC194 vep                                                                
#>   BFC195 vep                                                                
#>   BFC196 vt decompose
table(mcols(atls)$Type)
#> 
#> pipeline     tool 
#>       43      153

Currently, we have integrated 153 command line tools and 43 pipelines.

3.2 cwlSearch

We can use (multiple) keywords to search for specific tools/pipelines of interest, which internally search the mcols of “rname”, “rpath”, “fpath”, “Command” and “Containers”. Here we show how to search the alignment tool bwa mem.

t1 <- cwlSearch(c("bwa", "mem"))
t1
#> cwlHub with 1 records
#> cache path:  /tmp/Rtmp587B1r/Rcwl 
#> # last modified date:  2021-10-25 
#> # cwlSearch() to query scripts
#> # cwlLoad('title') to load the script
#> # additional mcols(): rid, rpath, Type, Container, mtime, ...
#> 
#>            title  Command
#>   BFC118 | tl_bwa bwa mem
mcols(t1)
#> DataFrame with 1 row and 14 columns
#>           rid       rname         create_time         access_time
#>   <character> <character>         <character>         <character>
#> 1      BFC118      tl_bwa 2024-03-15 22:46:45 2024-03-15 22:46:45
#>                    rpath       rtype                  fpath last_modified_time
#>              <character> <character>            <character>          <numeric>
#> 1 /tmp/Rtmp587B1r/Rcwl..       local /tmp/Rtmp587B1r/Rcwl..                 NA
#>          etag   expires        Type     Command              Container
#>   <character> <numeric> <character> <character>            <character>
#> 1          NA        NA        tool     bwa mem biocontainers/bwa:v0..
#>                 mtime
#>           <character>
#> 1 2021-10-25 12:58:45

3.3 cwlLoad

The last core function cwlLoad loads the Rcwl tool/pipeline into the R working environment. The code below loads the tool with a user-defined name bwa to do the read alignment.

bwa <- cwlLoad(title(t1)[1])  ## "tl_bwa"
bwa <- cwlLoad(mcols(t1)$fpath[1]) ## equivalent to the above. 
bwa
#> class: cwlProcess 
#>  cwlClass: CommandLineTool 
#>  cwlVersion: v1.0 
#>  baseCommand: bwa mem 
#> requirements:
#> - class: DockerRequirement
#>   dockerPull: biocontainers/bwa:v0.7.17-3-deb_cv1
#> inputs:
#>   threads (int): -t 
#>   RG (string?): -R 
#>   Ref (File):  
#>   FQ1 (File):  
#>   FQ2 (File?):  
#> outputs:
#> sam:
#>   type: File
#>   outputBinding:
#>     glob: '*.sam'
#> stdout: bwaOutput.sam

Now the R tool of bwa is ready to use.

4 Customize a tool or pipeline

To fit users’ specific needs,the existing tool or pipline can be easily customized. Here we use the rnaseq_Sf pipeline to demonstrate how to access and change the arguments of a specific tool inside a pipeline. This pipeline covers RNA-seq reads quality summary by fastQC, alignment by STAR, quantification by featureCounts and quality control by RSeQC.

rnaseq_Sf <- cwlLoad("pl_rnaseq_Sf")
#> fastqc loaded
#> STAR loaded
#> sortBam loaded
#> samtools_index loaded
#> samtools_flagstat loaded
#> featureCounts loaded
#> gtfToGenePred loaded
#> genePredToBed loaded
#> read_distribution loaded
#> geneBody_coverage loaded
#> STAR loaded
#> gCoverage loaded
plotCWL(rnaseq_Sf)

There are many default arguments defined for the tool of STAR inside the pipeline. Users might want to change some of them. For example, we can change the value for --outFilterMismatchNmax argument from 2 to 5 for longer reads.

arguments(rnaseq_Sf, "STAR")[5:6]
#> [[1]]
#> [1] "--readFilesCommand"
#> 
#> [[2]]
#> [1] "zcat"
arguments(rnaseq_Sf, "STAR")[[6]] <- 5
arguments(rnaseq_Sf, "STAR")[5:6]
#> [[1]]
#> [1] "--readFilesCommand"
#> 
#> [[2]]
#> [1] "5"

We can also change the docker image for a specific tool (e.g., to a specific version). First, we search for all available docker images for STAR in biocontainers repository. The Source server could be quay or dockerhub.

searchContainer("STAR", repo = "biocontainers", source = "quay")
#> DataFrame with 0 rows and 0 columns

Then, we can change the STAR version into 2.7.8a (tag name: 2.7.8a–0).

requirements(rnaseq_Sf, "STAR")[[1]]
#> $class
#> [1] "DockerRequirement"
#> 
#> $dockerPull
#> [1] "quay.io/biocontainers/star:2.7.9a--h9ee0642_0"
requirements(rnaseq_Sf, "STAR")[[1]] <- requireDocker(
    docker = "quay.io/biocontainers/star:2.7.8a--0")
requirements(rnaseq_Sf, "STAR")[[1]]
#> $class
#> [1] "DockerRequirement"
#> 
#> $dockerPull
#> [1] "quay.io/biocontainers/star:2.7.8a--0"

5 Run a tool or pipeline

Once the tool or pipeline is ready, we only need to assign values for each of the input parameters, and then submit using one of the functions: runCWL, runCWLBatch and cwlShiny. More detailed Usage and examples can be refer to the Rcwl vignette.

To successfully run the tool or pipeline, users either need to have all required command line tools pre-installed locally, or using the docker/singularity runtime by specifying docker = TRUE or docker = "singularity" argument inside runCWL or runCWLBatch function. Since the Bioconductor building machine doesn’t have all the tools installed, nor does it support the docker runtime, here we use some pseudo-code to demonstrate the tool/pipeline execution.

inputs(rnaseq_Sf)
rnaseq_Sf$in_seqfiles <- list("sample_R1.fq.gz",
                              "sample_R2.fq.gz")
rnaseq_Sf$in_prefix <- "sample"
rnaseq_Sf$in_genomeDir <- "genome_STAR_index_Dir"
rnaseq_Sf$in_GTFfile <- "GENCODE_version.gtf"

runCWL(rnaseq_Sf, outdir = "output/sample", docker = TRUE)

Users can also submit parallel jobs to HPC for multiple samples using runCWLBatch function. Different cluster job managers, such as “multicore”, “sge” and “slurm”, are supported using the BiocParallel::BatchtoolsParam.

library(BioParallel)
bpparam <- BatchtoolsParam(workers = 2, cluster = "sge",
                           template = batchtoolsTemplate("sge"))

inputList <- list(in_seqfiles = list(sample1 = list("sample1_R1.fq.gz",
                                                    "sample1_R2.fq.gz"),
                                     sample2 = list("sample2_R1.fq.gz",
                                                    "sample2_R2.fq.gz")),
                  in_prefix = list(sample1 = "sample1",
                                   sample2 = "sample2"))

paramList <- list(in_genomeDir = "genome_STAR_index_Dir",
                  in_GTFfile = "GENCODE_version.gtf",
                  in_runThreadN = 16)

runCWLBatch(rnaseq_Sf, outdir = "output",
            inputList, paramList,
            BPPARAM = bpparam)

6 SessionInfo

sessionInfo()
#> R version 4.3.3 (2024-02-29)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.18-bioc/R/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#> [1] RcwlPipelines_1.18.1 BiocFileCache_2.10.1 dbplyr_2.4.0        
#> [4] Rcwl_1.18.0          S4Vectors_0.40.2     BiocGenerics_0.48.1 
#> [7] yaml_2.3.8           BiocStyle_2.30.0    
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyselect_1.2.1      dplyr_1.1.4           blob_1.2.4           
#>  [4] filelock_1.0.3        R.utils_2.12.3        fastmap_1.1.1        
#>  [7] promises_1.2.1        digest_0.6.35         base64url_1.4        
#> [10] mime_0.12             lifecycle_1.0.4       ellipsis_0.3.2       
#> [13] RSQLite_2.3.5         magrittr_2.0.3        compiler_4.3.3       
#> [16] rlang_1.1.3           sass_0.4.8            progress_1.2.3       
#> [19] tools_4.3.3           igraph_2.0.3          utf8_1.2.4           
#> [22] data.table_1.15.2     knitr_1.45            prettyunits_1.2.0    
#> [25] brew_1.0-10           htmlwidgets_1.6.4     bit_4.0.5            
#> [28] curl_5.2.1            reticulate_1.35.0     RColorBrewer_1.1-3   
#> [31] batchtools_0.9.17     BiocParallel_1.36.0   withr_3.0.0          
#> [34] purrr_1.0.2           R.oo_1.26.0           grid_4.3.3           
#> [37] fansi_1.0.6           git2r_0.33.0          xtable_1.8-4         
#> [40] debugme_1.1.0         cli_3.6.2             rmarkdown_2.26       
#> [43] DiagrammeR_1.0.11     crayon_1.5.2          generics_0.1.3       
#> [46] rstudioapi_0.15.0     httr_1.4.7            visNetwork_2.1.2     
#> [49] DBI_1.2.2             cachem_1.0.8          stringr_1.5.1        
#> [52] parallel_4.3.3        BiocManager_1.30.22   basilisk_1.14.3      
#> [55] vctrs_0.6.5           Matrix_1.6-5          jsonlite_1.8.8       
#> [58] dir.expiry_1.10.0     bookdown_0.38         hms_1.1.3            
#> [61] bit64_4.0.5           jquerylib_0.1.4       glue_1.7.0           
#> [64] codetools_0.2-19      stringi_1.8.3         later_1.3.2          
#> [67] tibble_3.2.1          pillar_1.9.0          basilisk.utils_1.14.1
#> [70] rappdirs_0.3.3        htmltools_0.5.7       R6_2.5.1             
#> [73] evaluate_0.23         shiny_1.8.0           lattice_0.22-5       
#> [76] R.methodsS3_1.8.2     png_0.1-8             backports_1.4.1      
#> [79] memoise_2.0.1         httpuv_1.6.14         bslib_0.6.1          
#> [82] Rcpp_1.0.12           checkmate_2.3.1       xfun_0.42            
#> [85] pkgconfig_2.0.3