Learn R Programming

sevenbridges: R Package for Seven Bridges Platform from API client to CWL generator

Bioconductor-Stable | Bioconductor-Devel

Table of Contents

Events Features Installation Tutorial IDE docker image Issues report Q and A

Events

[html] [R markdown] [R script]

Features

  • Complete API R client with user friendly API in object-oriented fashion with user friendly printing, support operation on users, billing, project, file, app, task etc, short example.
## get project by pattern matching name
p = a$project("demo")
## get exact project by id
p = a$project(id = "tengfei/demo")
## detele files from a project
p$file("sample.tz")$delete()
## upload fies from a folder to a project with metadata
p$upload("folder_path", metadata = list(platform = "Illumina"))
  • Task monitoring hook allow you to add hook function to task status when you monitor a task, for example, when task is finished sent you email or download all files.
setTaskHook("completed", function(){
    tsk$download("~/Downloads")
})
tsk$monitor()
  • Task batching by item and metadata
## batch by items
(tsk <- p$task_add(name = "RNA DE report new batch 2", 
                   description = "RNA DE analysis report", 
                   app = rna.app$id,
                   batch = batch(input = "bamfiles"),
                   inputs = list(bamfiles = bamfiles.in, 
                                 design = design.in,
                                 gtffile = gtf.in)))

## batch by metadata, input files has to have metadata fields specified
(tsk <- p$task_add(name = "RNA DE report new batch 3", 
                   description = "RNA DE analysis report", 
                   app = rna.app$id,
                   batch = batch(input = "fastq", 
                                 c("metadata.sample_id", 
                                 "metadata.library_id")),
                   inputs = list(bamfiles = bamfiles.in, 
                                 design = design.in,
                                 gtffile = gtf.in)))
  • Cross platform support from Seven Bridges, such as NCI Cancer genomics cloud or Seven bridges on google and AWS, you can use it.

  • Authentication management for multiple platforms/users via config file.

## standard 
a = Auth(token = "fake_token", url = "api_url")
## OR from config file, multiple platform/user support
a = Auth(username = "tengfei", platform = "cgc")
  • CWL Tool interface, you can directly describe your tool in R, export to JSON/YAML, or add it to your online project. This package defines a complete set

of CWL object. So you can describe tools like this

library(readr)
fd <- fileDef(name = "runif.R",
              content = read_file(fl))
rbx <- Tool(id = "runif", 
            label = "runif",
            hints = requirements(docker(pull = "rocker/r-base"), 
                                 cpu(1), mem(2000)),
            requirements = requirements(fd),
            baseCommand = "Rscript runif.R",
            stdout = "output.txt",
            inputs = list(input(id = "number",
                                type = "integer",
                                position = 1),
                          input(id = "min",
                                type = "float",
                                position = 2),
                          input(id = "max",
                                type = "float",
                                position = 3)),
            outputs = output(id = "random", glob = "output.txt")) 
## output cwl JSON            
rbx$toJSON(pretty = TRUE) 
## output cwl YAML
rbx$toYAML()
  • Describe simple linear workflow by connect Tool objects like this
tool1 %>>% tool2 %>>% tool3

Installation

[Bioconductor: Stable]

For most users, I will recommend this installation, it's most stable. The current release of Bioconductor is version 3.3; it works with R version 3.3.0. Users of older R and Bioconductor versions must update their installation to take advantage of new features. If you don't want to update your R, please install from github directly as introduced in next section. It's quite easy.

Now check your R version

 R.version.string

If you are not running latest R, first install R 3.3 following instruction here, after you successfully installed R 3.3, if you are using Rstudio, please close and restart Rstudio, it will detect the new install. Then install sevenbridges package.

source("http://bioconductor.org/biocLite.R")
biocLite("sevenbridges")

[Latest]

You can always install the latest development version of the package from GitHub, it's always the most latest version, fresh new, with all new features and hot fixes, we push to bioconductor branch (release/devel) regularly.

# install.packages("devtools") if devtools was not installed
source("http://bioconductor.org/biocLite.R")
library(devtools)
install_github("sbg/sevenbridges-r", build_vignettes=TRUE, 
  repos=BiocInstaller::biocinstallRepos(),
  dependencies=TRUE)

If you have trouble with pandoc, set build_vignettes = FALSE to avoid vignettes build,

[Bioconductor: Devel]

Install from bioconductor devel branch if you are developing tools in devel branch or if you are users who use devel version for R and Bioconductor. You need to install R-devel first, please follow the instruction "Using the Devel Version of Bioconductor". After upgrade of R. This is kind of tricky and hard, if you just want to try latest feature, please install directly from github as next installation instruction.

source("http://bioconductor.org/biocLite.R")
useDevel(devel = TRUE)
biocLite("sevenbridges")

To load the package in R, simply call

library("sevenbridges")

Tutorials

We have 3 different version (from stable to latest), 1) bioconductor stable 2) bioconductor devel 3) github for different levels of users and developers, so here are all tutorials and their corresponding version:

  • Complete Guide for API R Client

[github] [bioc-stable] [bioc-devel]

  • Tutorial: use R for Cancer Genomics Cloud

[github] [bioc-stable] [bioc-devel]

  • Creating Your Docker Container and Command Line Interface

[github] [bioc-stable] [bioc-devel]

  • Describe CWL Tools/Workflows in R and Execution

[github] [bioc-stable] [bioc-devel]

  • Using Rstudio and Shiny

[github] [bioc-stable] [bioc-devel]

  • Reference

[bioc-stable] [bioc-devel]

Launch Rstudio Server and Shiny Server with sevenbridges IDE docker container

docker run  -d -p 8787:8787 -p 3838:3838 tengfei/sevenbridges

check out the ip from docker machine if you are on mac os.

docker-machine ip default

In your browser,

http://<url>:8787/ for Rstudio

http://<url>:3838/<username of rstudio>/app_dir for Shiny server

For example, if 192.168.99.100 is what returned, visit http://192.168.99.100:8787/ for Rstudio.

Note: for users of that Rstudio, just create ShinyApps folder under your home folder, then put your apps under that folder, so you can visit http://<url>:3838/<username of rstudio>/<app name> for your shiny apps. For example

In your Rstudio server launched from container, please run

file.copy("/usr/local/lib/R/site-library/shiny/examples/01_hello/", "~/ShinyApps/", recursive = TRUE)

If you are login as username 'rstudio', then visit http://192.168.99.100:3838/rstudio/01_hello you should be able to see the hello example.

Issue report

All feedback are welcomed! Please file bug/issue/request on the issue page here on github, we will try to respond asap.

Q&A

To ask a question about this package, the best place will be Bioconductor support website, go visit support website, and tag your post with package name sevenbridges.

  • Q: Does this package support older API which is not cwl compatible? A: No it only supports API v2 +, for older version, please check sbgr package, but

please note that the old API or project type will be deprecated.

  • Q: Which version of CWL (common workflow language) supported now? A: Draft 2, progress on draft 3.

  • Q: Is there a python binding for the API? A: Yes, official python client is here. And lots python recipes are now here

  • Q: Why I always get warning message when I use API R client? A: It only exists in Rstudio, potentially a bug in Rstudio. To ignore it use options(warn = -1)

© Seven Bridges Genomics 2012 - 2016. Licensed under the MIT license.

Copy Link

Version

Version

1.2.4

License

Apache License 2.0

Maintainer

Tengfei Yin

Last Published

February 15th, 2017

Functions in sevenbridges (1.2.4)

api

wrapper of http logic for SBG API
addIdNum

add # prefix to id
Auth-class

Class Auth
batch

batch function for task batch execution
App-class

App class
asList

Convert a object slots/fields to a list, json, yaml file
CommandInputParameter-class

CommandInputParameter Class
Binding-class

Binding
CommandInputSchema-class

CommandInputSchema Class
CCBList

characterORCommandLineBindingList Class
delete

Delete file or files
get_cwl_class

get class from cwl json file
CommandLineBinding-class

CommandLineBinding Class
CommandOutputSchema-class

CommandOutputSchema
convert_app

Convert App or a cwl JSON file to Tool or Flow object
download

Download file or files
CommandOutputBinding-class

CommandOutputBinding Class
CWL-class

Class CWL
CommandOutputParameter-class

CommandOutputParameter Class
CommandLineTool-class

CommandLineTool Class
SBGWorkflow-class

Build workflow
FS-class

FS class
Metadata-class

Meta schema
misc_get_token

Opens browser to copy the auth token
misc_upload_cli

Upload files using SBG uploader
CPURequirement-class

Rabix specifc Requirements
Parameter-class

Paramter class (reference class)
response

Get raw response from an Item object
setTaskHook

set task function hook
test_tool_bunny

Test tools in rabix/bunny
FileList

FileList Class
Files-class

Files class
ProcessRequirement-class

ProcessRequirement Class
Process-class

Process Class
sevenbridges-package

R Client for Seven Bridges Genomics API
setListClass

List Class generator.
Expression-class

Expression Class
ExpressionTool-class

ExpressionTool Class
lift_docopt

lift a docopt string
link

link two nodes to form a new Workflow
SchemaList

SchemaList
set_test_env

Set testing env
test_tool_cwlrun

Test tools with cwl-runner
upload_init

Initializes the upload of the specified file
WorkflowOutputParameter-class

Workflow
upload_info_part

Returns AWS S3 signed URL for a part of the file upload
upload_info

Returns upload information for the ongoing upload
test_tool_rabix

Test tools in rabix/rabix-devel (DEPRECATED)
DSCList

DSC list
PrimitiveSingleEnum-class

Pre-defiend enums
misc_get_uploader

Download SBG uploader and extract to a specified directory
project_details

Returns the details of the project
misc_make_metadata

Specify the parameters of the file metadata and return a list, JSON string, or write to a file
project_members

Returns a list of all users invited to the project and their privileges
upload_complete_all

Reports the complete file upload
Tool-class

Rabix CommandLineTool Class
Handler-class

Handler instance
CLB

Shorthand functions for cwl packages constructors
Item-class

Class Item
status_check

check request status
upload_complete_part

Reports the completion of the part upload
upload_delete

Aborts the upload
WorkflowStepInput-class

WorkflowStepInputList