diff --git a/docs/404.html b/docs/404.html index cac2a3b..bb558eb 100644 --- a/docs/404.html +++ b/docs/404.html @@ -90,7 +90,7 @@
@@ -175,11 +175,11 @@vignettes/api.Rmd
api.Rmd
The sevenbridges
package only supports v2+ versions of the API, since versions prior to V2 are not compatible with the Common Workflow Language (CWL). This package provides a simple interface for accessing and trying out various methods.
There are two ways of constructing API calls. For instance, you can use low-level API calls which use arguments like path
, query
, and body
. These are documented in the API reference libraries for the Seven Bridges Platform and the CGC. An example of a low-level request to “list all projects” is shown below. In this request, you can also pass query
and body
as a list.
library("sevenbridges") -a <- Auth(token = "your_token", platform = "aws-us") -a$api(path = "projects", method = "GET")
+library("sevenbridges") +a <- Auth(token = "your_token", platform = "aws-us") +a$api(path = "projects", method = "GET")
(Advanced user option) The second way of constructing an API request is to directly use the httr
package to make your API calls, as shown below.
a$project()
+a$project()
The sevenbridges
package is available on both the release
and devel
branch from Bioconductor.
To install it from the release
branch, use:
install.packages("BiocManager") -BiocManager::install("sevenbridges")
+install.packages("BiocManager") +BiocManager::install("sevenbridges")
To install it from the devel
branch, use:
install.packages("BiocManager") -BiocManager::install("sevenbridges", version = "devel")
+install.packages("BiocManager") +BiocManager::install("sevenbridges", version = "devel")
Since we are constantly improving our API and client libraries, please also visit our GitHub repository for the most recent news and the latest version of the package.
If you do not have devtools
This installation requires that you have the devtools
package. If you do not have this package, you can install it from CRAN.
install.packages("devtools")
+install.packages("devtools")
You may get an error for missing system dependencies such as curl
and openssl
. For example, in Ubuntu, you probably need to do the following first to install devtools
and to build vignettes since you need pandoc
.
apt-get update
apt-get install libcurl4-gnutls-dev libssl-dev pandoc pandoc-citeproc
If devtools
is already installed
Install the latest version for sevenbridges
from GitHub with the following:
install.packages("BiocManager") -install.packages("readr") ++ repos = BiocManager::repositories(), + build_vignettes = TRUE, dependencies = TRUE +)+install.packages("BiocManager") +install.packages("readr") -devtools::install_github( +devtools::install_github( "sbg/sevenbridges-r", - repos = BiocManager::repositories(), - build_vignettes = TRUE, dependencies = TRUE -)
If you have trouble with pandoc
and do not want to install it, set build_vignettes = FALSE
to avoid the vignettes build.
Auth
ObjectBefore you can access your account via the API, you have to provide your credentials. You can obtain your credentials in the form of an “authentication token” from the Developer Tab under Account Settings on the visual interface. Once you’ve obtained this, create an Auth
object, so it remembers your authentication token and the path for the API. All subsequent requests will draw upon these two pieces of information.
Let’s load the package first:
-library("sevenbridges")
You have three different ways to provide your token. Choose from one method below:
Method 1: Direct authentication
This is the most common method to construct the Auth
object. For example:
(a <- Auth(platform = "cgc", token = "your_token"))
+(a <- Auth(platform = "cgc", token = "your_token"))
Using platform: cgc
== Auth ==
url : https://cgc-api.sbgenomics.com/v2/
token : <your_token>
Method 2: Environment variables
To set the two environment variables in your system, you could use the function sbg_set_env()
. For example:
sbg_set_env("https://cgc-api.sbgenomics.com/v2", "your_token")
+sbg_set_env("https://cgc-api.sbgenomics.com/v2", "your_token")
Note that this change might be just temporary, please feel free to use the standard method to set persistent environment variables according to your operating system.
Create an Auth
object:
a <- Auth(from = "env")
+a <- Auth(from = "env")
Method 3: User configuration file
Assume we have already created the configuration file named credentials
under the directory $HOME/.sevenbridges/
:
[aws-us-rfranklin]
@@ -237,9 +247,11 @@
api_endpoint = https://gcp-api.sbgenomics.com/v2
auth_token = token_for_this_user
To load the user profile aws-us-rfranklin
from this configuration file, simply use:
a <- Auth(from = "file", profile_name = "aws-us-rfranklin")
+a <- Auth(from = "file", profile_name = "aws-us-rfranklin")
If profile_name
is not specified, we will try to load the profile named [default]
:
a <- Auth(from = "file")
+a <- Auth(from = "file")
Note: API paths (base URLs) differ for each Seven Bridges environment. Be sure to provide the correct path for the environment you are using. API paths for some of the environments are:
For example, you know there is an runif
function in the rocker/r-base
container, you can just do something like this. Please read another tutorial called “Describe and Execute CWL Tools/Workflows in R”, it introduced a simpler example with random number generator.
rbx <- Tool( - id = "runif", - label = "runif", - hints = requirements(docker(pull = "rocker/r-base"), cpu(1), mem(2000)), - baseCommand = "Rscript -e 'runif(100)'", - stdout = "output.txt", - outputs = output(id = "random", glob = "*.txt") -) -rbx$toJSON(pretty = TRUE)
+rbx <- Tool( + id = "runif", + label = "runif", + hints = requirements(docker(pull = "rocker/r-base"), cpu(1), mem(2000)), + baseCommand = "Rscript -e 'runif(100)'", + stdout = "output.txt", + outputs = output(id = "random", glob = "*.txt") +) +rbx$toJSON(pretty = TRUE)
{
"sbg:id": "runif",
"id": "#runif",
@@ -416,35 +426,38 @@
- If you don’t want to make a new container with command line interface and you can simply insert script temporarily for existing container. You can do things as quick as this, by provide a script in the ‘content’ of ‘fileDef’.
-# provide scripts
+
+# provide scripts
# make a new script file
-fd <- fileDef(
- name = "runif.R",
- content = "set.seed(1); runif(100)"
-)
-rbx <- Tool(
- id = "runif",
- label = "runif",
- hints = requirements(docker(pull = "rocker/r-base"), cpu(1), mem(2000)),
- requirements = requirements(fd),
- baseCommand = "Rscript runif.R", # run script you created.
- stdout = "output.txt",
- outputs = output(id = "random", glob = "*.txt")
-)
+fd <- fileDef(
+ name = "runif.R",
+ content = "set.seed(1); runif(100)"
+)
+rbx <- Tool(
+ id = "runif",
+ label = "runif",
+ hints = requirements(docker(pull = "rocker/r-base"), cpu(1), mem(2000)),
+ requirements = requirements(fd),
+ baseCommand = "Rscript runif.R", # run script you created.
+ stdout = "output.txt",
+ outputs = output(id = "random", glob = "*.txt")
+)
Note: in the above example, I made a mistake on purpose, so try to debug on the platform if the task fails : )
I will introduce “Tool” function, in the later section, don’t worry.
- For advanced developer/users: if you think a cool command line interface is worth doing, and convenient in any case, then go ahead and make one and create our own container will always be a better idea. this allow you to provide much formal interface at both command line level or container level.
Here is Dockerfile I used to generate the workflow I need
-fl <- system.file("docker/rnaseqGene", "Dockerfile",
- package = "sevenbridges"
-)
+
+fl <- system.file("docker/rnaseqGene", "Dockerfile",
+ package = "sevenbridges"
+)
Here is the current content of the Dockerfile
:
-
+
FROM rocker/tidyverse
-LABEL maintainer="nan.xiao@sevenbridges.com"
+LABEL maintainer="soner.koc@sevenbridges.com"
RUN Rscript -e 'source("http://bioconductor.org/workflows.R"); workflowInstall("rnaseqGene")'
@@ -473,11 +486,13 @@
- Test function inside container
Here is the command line I am using it’s called “performDE.R”
-fl <- system.file("docker/rnaseqGene/src", "performDE.R",
- package = "sevenbridges"
-)
+
+fl <- system.file("docker/rnaseqGene/src", "performDE.R",
+ package = "sevenbridges"
+)
Here is the current content of the Dockerfile
:
-
+
#!/usr/bin/Rscript
"usage: performDE.R [options]
@@ -551,11 +566,13 @@
Step 4: Add default report template to your app
As a developer, if you always have a fixed report template provided for you tool, you can hard-code your template into your Docker container, like you noticed in the Dockerfile I created, I insert a report R Markdown template. And in the command line interface, in the end, I pass it to rmarkdown::render
function as parameters ‘param’. In this way, you define your input in the header of R Markdown. Examples like this, this template I used here, is exactly the same report on Bioconductor’s RNA-Seq workflow website.
-fl <- system.file("docker/rnaseqGene/report", "rnaseqGene.Rmd",
- package = "sevenbridges"
-)
+
+fl <- system.file("docker/rnaseqGene/report", "rnaseqGene.Rmd",
+ package = "sevenbridges"
+)
Here is the current content (first 50 lines of the whole report) of the template:
-
+
---
title: "Uniform random number generator example"
date: "`r Sys.Date()`"
@@ -631,64 +648,66 @@
- Expression to specify the javascript expression (note:it’s convenient to do it with graphic user interface, because you can directly see the result of the expression)
- Enum: call ‘enum’.
-rbx <- Tool(
- id = "rnaseqGene",
- label = "rnaseqgene",
- description = "A RNA-seq Differiencial Expression Flow and Report",
- hints = requirements(docker(pull = "tengfei/rnaseqgene"), cpu(1), mem(2000)),
- baseCommand = "performDE.R",
- inputs = list(
- input(
- id = "bamfiles", label = "bam files",
- description = "a list of bam files",
- type = "File...", ## or type = ItemArray("File")
- prefix = "--bamfiles",
- itemSeparator = ","
- ),
- input(
- id = "design", label = "design matrix",
- type = "File",
- prefix = "--design"
- ),
- input(
- id = "gtffile", label = "gene feature files",
- type = "File",
- prefix = "--gtffile"
- ),
- input(
- id = "format", label = "report foramt html or pdf",
- type = enum("format", c("pdf", "html")),
- prefix = "--format"
- )
- ),
- outputs = list(
- output(
- id = "report", label = "report",
- description = "A reproducible report created by Rmarkdown",
- glob = Expression(
- engine = "#cwl-js-engine",
- script = "x = $job[['inputs']][['format']]; if(x == 'undefined' || x == null){x = 'html';};'rnaseqGene.' + x"
- )
- ),
- output(
- id = "heatmap", label = "heatmap",
- description = "A heatmap plot to show the Euclidean distance between samples",
- glob = "heatmap.pdf"
- ),
- output(
- id = "count", label = "count",
- description = "Reads counts matrix",
- glob = "count.csv"
- ),
- output(
- id = "de", label = "Differential expression table",
- description = "Differential expression table",
- glob = "de.csv"
- )
- )
-)
+
+rbx <- Tool(
+ id = "rnaseqGene",
+ label = "rnaseqgene",
+ description = "A RNA-seq Differiencial Expression Flow and Report",
+ hints = requirements(docker(pull = "tengfei/rnaseqgene"), cpu(1), mem(2000)),
+ baseCommand = "performDE.R",
+ inputs = list(
+ input(
+ id = "bamfiles", label = "bam files",
+ description = "a list of bam files",
+ type = "File...", ## or type = ItemArray("File")
+ prefix = "--bamfiles",
+ itemSeparator = ","
+ ),
+ input(
+ id = "design", label = "design matrix",
+ type = "File",
+ prefix = "--design"
+ ),
+ input(
+ id = "gtffile", label = "gene feature files",
+ type = "File",
+ prefix = "--gtffile"
+ ),
+ input(
+ id = "format", label = "report foramt html or pdf",
+ type = enum("format", c("pdf", "html")),
+ prefix = "--format"
+ )
+ ),
+ outputs = list(
+ output(
+ id = "report", label = "report",
+ description = "A reproducible report created by Rmarkdown",
+ glob = Expression(
+ engine = "#cwl-js-engine",
+ script = "x = $job[['inputs']][['format']]; if(x == 'undefined' || x == null){x = 'html';};'rnaseqGene.' + x"
+ )
+ ),
+ output(
+ id = "heatmap", label = "heatmap",
+ description = "A heatmap plot to show the Euclidean distance between samples",
+ glob = "heatmap.pdf"
+ ),
+ output(
+ id = "count", label = "count",
+ description = "Reads counts matrix",
+ glob = "count.csv"
+ ),
+ output(
+ id = "de", label = "Differential expression table",
+ description = "Differential expression table",
+ glob = "de.csv"
+ )
+ )
+)
By default it output YAML, but you can print it into JSON as well.
-rbx
+
+rbx
sbg:id: rnaseqGene
id: '#rnaseqGene'
inputs:
@@ -825,7 +844,8 @@
baseCommand:
- performDE.R
arguments: []
-rbx$toJSON(pretty = TRUE)
+
+rbx$toJSON(pretty = TRUE)
{
"sbg:id": "rnaseqGene",
"id": "#rnaseqGene",
@@ -990,14 +1010,17 @@
],
"arguments": []
}
-rbx$toJSON()
+
+rbx$toJSON()
{"sbg:id":"rnaseqGene","id":"#rnaseqGene","inputs":[{"type":["null",{"items":"File","type":"array"}],"label":"bam files","description":"a list of bam files","streamable":false,"default":"","id":"#bamfiles","inputBinding":{"position":0,"prefix":"--bamfiles","separate":true,"itemSeparator":",","shellQuote":false,"sbg:cmdInclude":true,"streamable":false,"separator":" "},"required":false},{"type":["null","File"],"label":"design matrix","description":"","streamable":false,"default":"","id":"#design","inputBinding":{"position":0,"prefix":"--design","separate":true,"shellQuote":false,"sbg:cmdInclude":true,"streamable":false,"separator":" "},"required":false},{"type":["null","File"],"label":"gene feature files","description":"","streamable":false,"default":"","id":"#gtffile","inputBinding":{"position":0,"prefix":"--gtffile","separate":true,"shellQuote":false,"sbg:cmdInclude":true,"streamable":false,"separator":" "},"required":false},{"type":["null",{"name":"format","symbols":["pdf","html"],"type":"enum"}],"label":"report foramt html or pdf","description":"","streamable":false,"default":"","id":"#format","inputBinding":{"position":0,"prefix":"--format","separate":true,"shellQuote":false,"sbg:cmdInclude":true,"streamable":false,"separator":" "},"required":false}],"outputs":[{"type":["null","File"],"label":"report","description":"A reproducible report created by Rmarkdown","streamable":false,"default":"","id":"#report","outputBinding":{"glob":{"engine":"#cwl-js-engine","script":"x = $job[['inputs']][['format']]; if(x == 'undefined' || x == null){x = 'html';};'rnaseqGene.' + x","class":"Expression"}}},{"type":["null","File"],"label":"heatmap","description":"A heatmap plot to show the Euclidean distance between samples","streamable":false,"default":"","id":"#heatmap","outputBinding":{"glob":"heatmap.pdf"}},{"type":["null","File"],"label":"count","description":"Reads counts matrix","streamable":false,"default":"","id":"#count","outputBinding":{"glob":"count.csv"}},{"type":["null","File"],"label":"Differential expression table","description":"Differential expression table","streamable":false,"default":"","id":"#de","outputBinding":{"glob":"de.csv"}}],"requirements":[],"hints":[{"class":"DockerRequirement","dockerPull":"tengfei/rnaseqgene"},{"class":"sbg:CPURequirement","value":1},{"class":"sbg:MemRequirement","value":2000}],"label":"rnaseqgene","description":"A RNA-seq Differiencial Expression Flow and Report","class":"CommandLineTool","baseCommand":["performDE.R"],"arguments":[]}
-# # or write to an external file
-# fl <- "~/Downloads/rnaseqGene.json"
-# write(rbx$toJSON(pretty = TRUE), fl)
+
+# # or write to an external file
+# fl <- "~/Downloads/rnaseqGene.json"
+# write(rbx$toJSON(pretty = TRUE), fl)
Now you want to add app to your project p
, by calling app_add
method, the first argument is name, the second is either a CWL JSON file, Tool
object, or Workflow
object.
-# add App you just created
-(rna.app <- p$app_add("rnaseqgene", rbx))
+
+# add App you just created
+(rna.app <- p$app_add("rnaseqgene", rbx))
Please go check your app in your project, check input output and how it maps to the UI.
metadata
: a list of meta otherwise search for the same file name ended with “.meta”
For example:
-fl <- system.file("extdata", "sample1.fastq", package = "sevenbridges") -(p <- a$project(id = "tengfei/quickstart")) ++fls <- list.files(dir.ext, recursive = TRUE, full.names = TRUE) +p$upload(fls, overwrite = TRUE)+fl <- system.file("extdata", "sample1.fastq", package = "sevenbridges") +(p <- a$project(id = "tengfei/quickstart")) # by default load .meta for the file -p$upload(fl, overwrite = TRUE) +p$upload(fl, overwrite = TRUE) # pass metadata -p$upload(fl, overwrite = TRUE, metadata = list(library_id = "testid2", platform = "Illumina x11")) +p$upload(fl, overwrite = TRUE, metadata = list(library_id = "testid2", platform = "Illumina x11")) # rename -p$upload(fl, - overwrite = TRUE, name = "sample_new_name.fastq", - metadata = list(library_id = "new_id") -) +p$upload(fl, + overwrite = TRUE, name = "sample_new_name.fastq", + metadata = list(library_id = "new_id") +) # upload folder -dir.ext <- system.file("extdata", package = "sevenbridges") -p$upload(dir.ext, overwrite = TRUE) +dir.ext <- system.file("extdata", package = "sevenbridges") +p$upload(dir.ext, overwrite = TRUE) # upload file list -fls <- list.files(dir.ext, recursive = TRUE, full.names = TRUE) -p$upload(fls, overwrite = TRUE)
For now try using our graphic user interface to import all files listed here:
-download.fl <- system.file("extdata/download.txt", package = "sevenbridges") -cat(readLines(download.fl), sep = "\n")
Warning in readLines(download.fl): incomplete final line found on '/Users/nanx/
-rpkgs/sevenbridges/extdata/download.txt'
++download.fl <- system.file("extdata/download.txt", package = "sevenbridges") +cat(readLines(download.fl), sep = "\n")
Warning in readLines(download.fl): incomplete final line found on '/Users/
+c02sn03cfvh6/rpkgs/sevenbridges/extdata/download.txt'
https://raw.githubusercontent.com/tengfei/resource/master/2016/04-01-hackathon/data/example_report.Rmd
https://raw.githubusercontent.com/tengfei/resource/master/2016/04-01-hackathon/data/hello-markdown.Rmd
https://raw.githubusercontent.com/tengfei/resource/master/2016/04-01-hackathon/data/hello.tar
@@ -1054,79 +1079,87 @@
https://raw.githubusercontent.com/tengfei/resource/master/2016/04-01-hackathon/data/SRR1039520_subset.bam
https://raw.githubusercontent.com/tengfei/resource/master/2016/04-01-hackathon/data/SRR1039521_subset.bam
To use the API to uplaod, let’s download it to a folder and upload via API.
-td <- tempfile() -dir.create(td) -for (f in readLines(download.fl)) { - download.file(f, file.path(td, basename(f))) -} ++p$upload(td)+td <- tempfile() +dir.create(td) +for (f in readLines(download.fl)) { + download.file(f, file.path(td, basename(f))) +} # double check -list.files(td) +list.files(td) # upload to the project you created -p$upload(td)
Copy this list, and then in your project, click “add files”, and choose “import from ftp” (tutorial).
When it’s finished, refresh your file page, you will be able to see all of them. The cool thing is that you can search file by ‘name’ not by id, it support fuzzy pattern match.
-# get file id you need as inout -(bamfiles.in <- p$file(".bam")) -(design.in <- p$file("sample_table.csv")) -(gtf.in <- p$file("Homo_sapiens.GRCh37.75_subset.gtf"))
+# get file id you need as inout +(bamfiles.in <- p$file(".bam")) +(design.in <- p$file("sample_table.csv")) +(gtf.in <- p$file("Homo_sapiens.GRCh37.75_subset.gtf"))
Note: you can also passed a list of files like this, to give exact file names
-bam1 <- p$file("SRR1039516_subset.bam") -bam2 <- p$file("SRR1039512_subset.bam") -bamfiles.in2 <- list(bam1, bam2)
+bam1 <- p$file("SRR1039516_subset.bam") +bam2 <- p$file("SRR1039512_subset.bam") +bamfiles.in2 <- list(bam1, bam2)
Now create a new draft task in your project, don’t forget to pass input.
-# add a new Task -(tsk <- p$task_add( - name = "RNA DE report new", - description = "RNA DE analysis report", - app = rna.app$id, - inputs = list( - bamfiles = bamfiles.in, - design = design.in, - gtffile = gtf.in - ) -)) ++tsk$run()+# add a new Task +(tsk <- p$task_add( + name = "RNA DE report new", + description = "RNA DE analysis report", + app = rna.app$id, + inputs = list( + bamfiles = bamfiles.in, + design = design.in, + gtffile = gtf.in + ) +)) # don't forget to run a draft task -tsk$run()
To monitor the task, run following command, it will tell you when it’s finished, but this is not running in the background now.
-# # monitor the task -# tsk$monitor()
+# # monitor the task +# tsk$monitor()
A better way is to use the Task hook function, it’s flexible, you can hook any function to a task status. For example, when it’s complete download the files. Now try to send your self a text message : )
-setTaskHook("completed", function() { - tsk$download("~/Downloads") -}) -tsk$monitor()
+setTaskHook("completed", function() { + tsk$download("~/Downloads") +}) +tsk$monitor()
To download all files from a completed tasks
-tsk$download("~/Downloads")
+tsk$download("~/Downloads")
To run task in batch mode, check ?batch
for more details. Here is an mock running:
# 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 - ) -)) ++(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 + ) +))+# 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 - ) -))
For more details, check R API tutorial.
If you are interested, you can still read my Dockerfile
, command line, tool generator and JSON.
I will suggest you directly copy the json into your project. Just to try add an app in a different way.
-fl <- system.file("docker/reporttool/rabix/reporttool.json", - package = "sevenbridges" -) -cat(readLines(fl), sep = "\n")
+fl <- system.file("docker/reporttool/rabix/reporttool.json", + package = "sevenbridges" +) +cat(readLines(fl), sep = "\n")
{
"sbg:id": "reporttool",
"id": "#reporttool",
@@ -1492,17 +1526,19 @@
"context": ""
}
Or just use API to add the raw JSON file
-# directly add json file -p <- a$project(id = "tengfei/hackathon") -(report.app <- p$app_add("report-tool", fl))
+# directly add json file +p <- a$project(id = "tengfei/hackathon") +(report.app <- p$app_add("report-tool", fl))
Checkout the Dockerfile
-fl <- system.file("docker/reporttool/Dockerfile", - package = "sevenbridges" -) -cat(readLines(fl), sep = "\n")
+fl <- system.file("docker/reporttool/Dockerfile", + package = "sevenbridges" +) +cat(readLines(fl), sep = "\n")
FROM rocker/tidyverse
-LABEL maintainer="nan.xiao@sevenbridges.com"
+LABEL maintainer="soner.koc@sevenbridges.com"
RUN rm -f /var/lib/dpkg/available \
&& rm -rf /var/cache/apt/* \
@@ -1515,21 +1551,23 @@
RUN chmod a+x /usr/local/bin/report.R
Checkout the command line
-fl <- system.file("docker/reporttool/src/report.R", - package = "sevenbriges" -) -cat(readLines(fl), sep = "\n")
+fl <- system.file("docker/reporttool/src/report.R", + package = "sevenbriges" +) +cat(readLines(fl), sep = "\n")
Checkout the tool generator
-fl <- system.file("docker/reporttool/rabix/generator.R", - package = "sevenbriges" -) -cat(readLines(fl), sep = "\n")
+fl <- system.file("docker/reporttool/rabix/generator.R", + package = "sevenbriges" +) +cat(readLines(fl), sep = "\n")
Even though in R with sevenbridges
package you can use %>>%
to connect two Tool object, but this only works for linear simple flow. For a complicated flow, we recommend you to use graphic user interface, it’s a lot of fun.
Even though in R with sevenbridges
package you can use %>>%
to connect two Tool object, but this only works for linear simple flow. For a complicated flow, we recommend you to use graphic user interface, it’s a lot of fun.
Now connect your RNA-seq tool with the report tool you just add it to your project, follow the tutorial here, then make a workflow like this:
And next run a task on the platform via UI like this:
@@ -1545,7 +1583,8 @@After you installed the package
-browseVignettes("sevenbridges")
+browseVignettes("sevenbridges")
or on the vignettes page.
vignettes/cgc-datasets.Rmd
cgc-datasets.Rmd
https://cgc-datasets-api.sbgenomics.com/
use Auth$api()
method so there is no need to type base URL or token again.
library("sevenbridges") ++a <- Auth( + url = "https://cgc-datasets-api.sbgenomics.com/", + token = "your_cgc_token" +) +a$api(path = "datasets")+library("sevenbridges") # create an Auth object -a <- Auth( - url = "https://cgc-datasets-api.sbgenomics.com/", - token = "your_cgc_token" -) -a$api(path = "datasets")
You can issue another GET
request to the href of the tcga object, if you want to access TCGA data.
a <- Auth( - url = "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0", - token = "your_cgc_token" -) -(res <- a$api()) # default method is GET ++names(res$"_links")+a <- Auth( + url = "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0", + token = "your_cgc_token" +) +(res <- a$api()) # default method is GET # list all resources/entities -names(res$"_links")
For example, to see a list of all TCGA files, send the request:
-(res <- a$api(path = "files"))
+(res <- a$api(path = "files"))
For example, to see the metadata schema for files send the request:
-a$api(path = "files/schema")
+a$api(path = "files/schema")
Get file id from Datasets API, then use public API to copy files. Make sure your project is “TCGA” compatible, otherwise if you are trying to copy controlled access data to your non-TCGA project, you will get
"HTTP Status 403: Insufficient privileges to access the requested file."
-(res <- a$api(path = "files")) ++a_cgc <- Auth(platform = "cgc", token = a$token) +a_cgc$copyFile(id = ids, project = "RFranklin/tcga-demo")+(res <- a$api(path = "files")) -get_id <- function(obj) sapply(obj$"_embedded"$files, function(x) x$id) -ids <- get_id(res) +get_id <- function(obj) sapply(obj$"_embedded"$files, function(x) x$id) +ids <- get_id(res) # create CGC auth -a_cgc <- Auth(platform = "cgc", token = a$token) -a_cgc$copyFile(id = ids, project = "RFranklin/tcga-demo")
body <- list( - entity = "samples", - hasCase = "0004D251-3F70-4395-B175-C94C2F5B1B81" -) -a$api(path = "query", body = body, method = "POST")
+body <- list( + entity = "samples", + hasCase = "0004D251-3F70-4395-B175-C94C2F5B1B81" +) +a$api(path = "query", body = body, method = "POST")
Count samples connected to a case
-a$api(path = "query/total", body = body, method = "POST")
+a$api(path = "query/total", body = body, method = "POST")
Issuing a GET
request to the href path will return the following data:
Note: api
function is a light layer of httr package, it’s different from Auth$api
call.
Suppose you want to see all cases for which the age at diagnosis is between 10 and 50. Then, you use the following query.
Note that the value of the metadata field hasAgeAtDiagnosis is a dictionary containing the keyfilter, whose value is a further dictionary with keysgt(greater than) and lt (less than) for the upper and lower bounds to filter by.
- +Suppose you want to see all cases that, as in the example, (Find cases with given age at diagnosis)(doc:find-all-cases-with-a-given-age-at-diagnosis), have an age at diagnosis of between 10 and 50, but that also have the disease “Kidney Chromophobe”. Then, use the following query:
- +body <- list( - "entity" = "cases", - "hasSample" = list( - "hasSampleType" = "Primary Tumor", - "hasPortion" = list( - "hasPortionNumber" = 11 - ) - ), - "hasNewTumorEvent" = list( - "hasNewTumorAnatomicSite" = c("Liver", "Pancreas"), - "hasNewTumorEventType" = list( - "filter" = list( - "contains" = "Recurrence" - ) - ) - ) -) -a$api(path = "query", body = body, method = "POST")
+body <- list( + "entity" = "cases", + "hasSample" = list( + "hasSampleType" = "Primary Tumor", + "hasPortion" = list( + "hasPortionNumber" = 11 + ) + ), + "hasNewTumorEvent" = list( + "hasNewTumorAnatomicSite" = c("Liver", "Pancreas"), + "hasNewTumorEventType" = list( + "filter" = list( + "contains" = "Recurrence" + ) + ) + ) +) +a$api(path = "query", body = body, method = "POST")
Issuing a GET
request to the href path
get_id <- function(obj) sapply(obj$"_embedded"$files, function(x) x$id) -names(res) ++(res <- a$api(path = "files", body = body)) +get_id(res)+get_id <- function(obj) sapply(obj$"_embedded"$files, function(x) x$id) +names(res) -body <- list( - "entity" = "cases", - "hasSample" = list( - "hasSampleType" = "Primary Tumor", - "hasPortion" = list( - "hasPortionNumber" = 11, - "hasID" = "TCGA-DD-AAVP-01A-11" - ) - ), - "hasNewTumorEvent" = list( - "hasNewTumorAnatomicSite" = "Liver", - "hasNewTumorEventType" = "Intrahepatic Recurrence" - ) -) +body <- list( + "entity" = "cases", + "hasSample" = list( + "hasSampleType" = "Primary Tumor", + "hasPortion" = list( + "hasPortionNumber" = 11, + "hasID" = "TCGA-DD-AAVP-01A-11" + ) + ), + "hasNewTumorEvent" = list( + "hasNewTumorAnatomicSite" = "Liver", + "hasNewTumorEventType" = "Intrahepatic Recurrence" + ) +) -(res <- a$api(path = "files", body = body)) -get_id(res)
vignettes/docker.Rmd
docker.Rmd
Our goal here is to making a CWL app to generate uniform random numbers, yes, the core function is runif()
, it’s a native function in R.
dput(runif)
+dput(runif)
## function (n, min = 0, max = 1)
## .Call(C_runif, n, min, max)
-
+
## [1] 0.985688783 0.412628483 0.429539246 0.419172236 0.426506559 0.887797565
## [7] 0.006096034 0.081215761 0.288657362 0.765342145
I will add one more parameter to set seed, here is the R script file called runif.R
.
At the beginning of the command line script, I use the docopt standard to write my tool help.
-"usage: runif.R [--n=<int> --min=<float> --max=<float> --seed=<float>]\n\noptions:\n --n=<int> number of observations. If length(n) > 1, the length is taken to be the number required [default: 1].\n --min=<float> lower limits of the distribution. Must be finite [default: 0].\n --max=<float> upper limits of the distribution. Must be finite [default: 1].\n --seed=<float> seed for set.seed() function [default: 1]" -> doc ++library("docopt")+"usage: runif.R [--n=<int> --min=<float> --max=<float> --seed=<float>]\n\noptions:\n --n=<int> number of observations. If length(n) > 1, the length is taken to be the number required [default: 1].\n --min=<float> lower limits of the distribution. Must be finite [default: 0].\n --max=<float> upper limits of the distribution. Must be finite [default: 1].\n --seed=<float> seed for set.seed() function [default: 1]" -> doc -library("docopt")
Let’s first do some testing in your R session before you make it a full functional command line tool.
-docopt(doc) # with no argumetns provided
+docopt(doc) # with no argumetns provided
## List of 8
## $ --n : chr "1"
## $ --min : chr "0"
@@ -290,7 +294,8 @@
## $ max : chr "1"
## $ seed : chr "1"
## NULL
-docopt(doc, "--n 10 --min=3 --max=5")
+docopt(doc, "--n 10 --min=3 --max=5")
## List of 8
## $ --n : chr "10"
## $ --min : chr "3"
@@ -302,26 +307,28 @@
## $ seed : chr "1"
## NULL
Looks like it works, now let’s add main function script for this command line tool.
-opts <- docopt(doc) -set.seed(opts$seed) -runif( - n = as.integer(opts$n), - min = as.numeric(opts$min), - max = as.numeric(opts$max) -)
+opts <- docopt(doc) +set.seed(opts$seed) +runif( + n = as.integer(opts$n), + min = as.numeric(opts$min), + max = as.numeric(opts$max) +)
## [1] 0.2655087
Add Shebang at the top of the file, this is a complete example for runif.R
command line will be like this
#!/usr/bin/Rscript -"usage: runif.R [--n=<int> --min=<float> --max=<float> --seed=<float>]\n\noptions:\n --n=<int> number of observations. If length(n) > 1, the length is taken to be the number required [default: 1].\n --min=<float> lower limits of the distribution. Must be finite [default: 0].\n --max=<float> upper limits of the distribution. Must be finite [default: 1].\n --seed=<float> seed for set.seed() function [default: 1]" -> doc - -library("docopt") -opts <- docopt(doc) -set.seed(opts$seed) -runif( - n = as.integer(opts$n), - min = as.numeric(opts$min), - max = as.numeric(opts$max) -)
+#!/usr/bin/Rscript +"usage: runif.R [--n=<int> --min=<float> --max=<float> --seed=<float>]\n\noptions:\n --n=<int> number of observations. If length(n) > 1, the length is taken to be the number required [default: 1].\n --min=<float> lower limits of the distribution. Must be finite [default: 0].\n --max=<float> upper limits of the distribution. Must be finite [default: 1].\n --seed=<float> seed for set.seed() function [default: 1]" -> doc + +library("docopt") +opts <- docopt(doc) +set.seed(opts$seed) +runif( + n = as.integer(opts$n), + min = as.numeric(opts$min), + max = as.numeric(opts$max) +)
Let’s test this command line.
$ runif.R --help
Loading required package: methods
@@ -354,8 +361,9 @@
min
max
-fl <- system.file("docker/sevenbridges/src", "runif2spin.R", package = "sevenbridges")
-cat(readLines(fl), sep = "\n")
+
+fl <- system.file("docker/sevenbridges/src", "runif2spin.R", package = "sevenbridges")
+cat(readLines(fl), sep = "\n")
#' ---
#' title: "Uniform random number generator example"
#' output:
@@ -380,43 +388,45 @@
Ignore the comment part, I will introduce spin/stich later. My base command will be something like
Rscript runif2spin.R 10 30 50
I just describe my tool in this way
-library("sevenbridges")
-
-fd <- fileDef(
- name = "runif.R",
- content = readr::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")
-)
+
+library("sevenbridges")
+
+fd <- fileDef(
+ name = "runif.R",
+ content = readr::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")
+)
Now copy-paste the JSON into your project app and run it in the cloud to test it
How about named arguments? I will still recommend use “docopt” package, but for simple way.
-fl <- system.file("docker/sevenbridges/src", "runif_args.R", package = "sevenbridges")
-cat(readLines(fl), sep = "\n")
+
+fl <- system.file("docker/sevenbridges/src", "runif_args.R", package = "sevenbridges")
+cat(readLines(fl), sep = "\n")
#' ---
#' title: "Uniform random number generator example"
#' output:
@@ -453,48 +463,50 @@
hist(r)
write.csv(r, file = "out.csv")
Rscript runif_args.R --n=10 --min=30 --max=50
-I just describe my tool in this way, note, I use separate=FALSE
and add =
to my prefix as a hack.
-fd <- fileDef(
- name = "runif.R",
- content = readr::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",
- separate = FALSE,
- prefix = "--n="
- ),
- input(
- id = "min",
- type = "float",
- separate = FALSE,
- prefix = "--min="
- ),
- input(
- id = "max",
- type = "float",
- separate = FALSE,
- prefix = "--max="
- )
- ),
- outputs = output(id = "random", glob = "output.txt")
-)
+I just describe my tool in this way, note, I use separate=FALSE
and add =
to my prefix as a hack.
+
+fd <- fileDef(
+ name = "runif.R",
+ content = readr::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",
+ separate = FALSE,
+ prefix = "--n="
+ ),
+ input(
+ id = "min",
+ type = "float",
+ separate = FALSE,
+ prefix = "--min="
+ ),
+ input(
+ id = "max",
+ type = "float",
+ separate = FALSE,
+ prefix = "--max="
+ )
+ ),
+ outputs = output(id = "random", glob = "output.txt")
+)
Alternative, you can use spin/stich from knitr to generate report directly from an R script with special format. For example, let’s use the above example
-fl <- system.file("docker/sevenbridges/src", "runif_args.R", package = "sevenbridges") -cat(readLines(fl), sep = "\n")
+fl <- system.file("docker/sevenbridges/src", "runif_args.R", package = "sevenbridges") +cat(readLines(fl), sep = "\n")
#' ---
#' title: "Uniform random number generator example"
#' output:
@@ -533,44 +545,45 @@
You command is something like this
Rscript -e "rmarkdown::render(knitr::spin('runif_args.R', FALSE))" --args --n=100 --min=30 --max=50
And so I describe my tool like this with Docker image rocker/hadleyverse
this contains knitr and rmarkdown package.
-fd <- fileDef(
- name = "runif.R",
- content = readr::read_file(fl)
-)
-
-rbx <- Tool(
- id = "runif",
- label = "runif",
- hints = requirements(docker(pull = "rocker/hadleyverse"), cpu(1), mem(2000)),
- requirements = requirements(fd),
- baseCommand = "Rscript -e \"rmarkdown::render(knitr::spin('runif.R', FALSE))\" --args",
- stdout = "output.txt",
- inputs = list(
- input(
- id = "number",
- type = "integer",
- separate = FALSE,
- prefix = "--n="
- ),
- input(
- id = "min",
- type = "float",
- separate = FALSE,
- prefix = "--min="
- ),
- input(
- id = "max",
- type = "float",
- separate = FALSE,
- prefix = "--max="
- )
- ),
- outputs = list(
- output(id = "stdout", type = "file", glob = "output.txt"),
- output(id = "random", type = "file", glob = "*.csv"),
- output(id = "report", type = "file", glob = "*.html")
- )
-)
+
+fd <- fileDef(
+ name = "runif.R",
+ content = readr::read_file(fl)
+)
+
+rbx <- Tool(
+ id = "runif",
+ label = "runif",
+ hints = requirements(docker(pull = "rocker/hadleyverse"), cpu(1), mem(2000)),
+ requirements = requirements(fd),
+ baseCommand = "Rscript -e \"rmarkdown::render(knitr::spin('runif.R', FALSE))\" --args",
+ stdout = "output.txt",
+ inputs = list(
+ input(
+ id = "number",
+ type = "integer",
+ separate = FALSE,
+ prefix = "--n="
+ ),
+ input(
+ id = "min",
+ type = "float",
+ separate = FALSE,
+ prefix = "--min="
+ ),
+ input(
+ id = "max",
+ type = "float",
+ separate = FALSE,
+ prefix = "--max="
+ )
+ ),
+ outputs = list(
+ output(id = "stdout", type = "file", glob = "output.txt"),
+ output(id = "random", type = "file", glob = "*.csv"),
+ output(id = "report", type = "file", glob = "*.html")
+ )
+)
You will get a report in the end.
Of course, we can figure out a way to do it in liftr
or knitr
. But R Markdown allow you to pass parameters to your R Markdown template, please read this tutorial Parameterized Reports. This doesn’t solve my problem that I want to directly describe command line interface in the markdown template. However, here is alternative method:
Create an command line interface to pass params
from docopt into rmarkdown::render()
function. In this way, we can pass as many as possible parameters from command line interface into our R Markdown template.
So here we go, here is updated methods and it’s also what I use for another tutorial about RNA-seq workflow.
-fl <- system.file("docker/sevenbridges/src/", "runif.R", package = "sevenbridges")
+fl <- system.file("docker/sevenbridges/src/", "runif.R", package = "sevenbridges")
Here is the current content of command line interface
#!/usr/local/bin/Rscript
'usage: runif.R [--n=<int> --min=<float> --max=<float> --seed=<float>]
@@ -665,11 +679,11 @@
diff --git a/docs/articles/docker_files/header-attrs-2.4/header-attrs.js b/docs/articles/docker_files/header-attrs-2.4/header-attrs.js
new file mode 100644
index 0000000..dd57d92
--- /dev/null
+++ b/docs/articles/docker_files/header-attrs-2.4/header-attrs.js
@@ -0,0 +1,12 @@
+// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
+// be compatible with the behavior of Pandoc < 2.8).
+document.addEventListener('DOMContentLoaded', function(e) {
+ var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
+ var i, h, a;
+ for (i = 0; i < hs.length; i++) {
+ h = hs[i];
+ if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
+ a = h.attributes;
+ while (a.length > 0) h.removeAttribute(a[0].name);
+ }
+});
diff --git a/docs/articles/index.html b/docs/articles/index.html
index 8bc82d7..b9d1269 100644
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -90,7 +90,7 @@
vignettes/rstudio.Rmd
rstudio.Rmd
The Dockerfile
is included with the package in inst/docker
folder.
Here is the current content of Dockerfile
:
fl <- system.file("docker/sevenbridges/", "Dockerfile", package = "sevenbridges") -cat(readLines(fl), sep = "\n")
+fl <- system.file("docker/sevenbridges/", "Dockerfile", package = "sevenbridges") +cat(readLines(fl), sep = "\n")
FROM rocker/tidyverse
-LABEL maintainer="nan.xiao@sevenbridges.com"
+LABEL maintainer="soner.koc@sevenbridges.com"
## Install common dependencies
RUN apt-get update && apt-get install -y \
@@ -299,11 +300,12 @@
In your browser, http://<url>:8787/
for RStudio Server, for example, if 192.168.99.100 is what returned, visit http://192.168.99.100:8787/
for RStudio Server.
For Shiny Server, per user app is hosted http://<url>:3838/users/<username of rstudio>/<app_dir>
, for example, for user rstudio
(a default user) and an app called 01_hello
, it will be http://<url>:3838/users/rstudio/01_hello/
. To develop your Shiny app from RStudio Server, you can log into your RStudio Server with your username, and create a fold at home folder called ~/ShinyApps
and develop Shiny apps under that folder, for example, you can create an app called 02_text
at ~/ShinyApps/02_text/
.
Let’s try this, please log into your RStudio at http://<url>:8787
now, then try to copy some example over to your home folder under ~/ShinyApps/
-dir.create("~/ShinyApps")
-file.copy(
+
+dir.create("~/ShinyApps")
+file.copy(
"/usr/local/lib/R/site-library/shiny/examples/01_hello/",
- "~/ShinyApps/", recursive = TRUE
-)
+ "~/ShinyApps/", recursive = TRUE
+)
If you logged in with the username rstudio
, then visit http://192.168.99.100:3838/rstudio/01_hello
you should be able to see the hello example.
Note: Generic Shiny apps can also be hosted http://<url>:3838/
or for particular app, http://<url>:3838/<app_dir>
and inside the Docker container, it is hosted under /srv/shiny-server/
.
Nan Xiao. Author, maintainer. +
Soner Koc. Author, maintainer.
Tengfei Yin. Author. +
Nan Xiao. Author.
Emile Young. Contributor. +
Tengfei Yin. Author.
Dusan Randjelovic. Contributor.
Emile Young. Contributor. +
+Seven Bridges Genomics. Copyright holder, funder.
@@ -190,11 +194,11 @@First, check the version of R you are using with the following command (in R):
-R.version.string
+R.version.string
If you are not running the latest release version of R, install or upgrade with these instructions. If you are using RStudio, restart RStudio after installing R. RStudio will detect the new installation.
This is recommended for most users as it is the most stable version.
You can install the package from the release
branch on Bioconductor using BiocManager
:
install.packages("BiocManager") -BiocManager::install("sevenbridges")
+install.packages("BiocManager") +BiocManager::install("sevenbridges")
If you are developing tools under the devel
branch or use the development version of R and Bioconductor, install the package from the Bioconductor devel
branch. You probably also want to install R-devel first by following the directions in “Using the ‘Devel’ Version of Bioconductor”.
To install the sevenbridges
package from the devel
branch, use
install.packages("BiocManager") -BiocManager::install("sevenbridges", version = "devel")
+install.packages("BiocManager") +BiocManager::install("sevenbridges", version = "devel")
To try the latest features, please install the package directly from GitHub. We push to the Bioconductor branch (release
and devel
) regularly.
Installing the sevenbridges
package from GitHub requires you have the devtools
package. If you do not have devtools
, install it from CRAN first.
install.packages("devtools")
+install.packages("devtools")
You may get an error for missing system dependecies such as curl and ssl. You probably need to do the following first in order to install devtools
and to build vignettes since you need pandoc
under Ubuntu.
apt-get update
apt-get install libcurl4-gnutls-dev libssl-dev pandoc pandoc-citeproc
After devtools
is installed, install the latest version of sevenbridges
from GitHub:
install.packages("BiocManager") ++ repos = BiocManager::repositories(), + build_vignettes = TRUE, dependencies = TRUE +)+install.packages("BiocManager") -devtools::install_github( +devtools::install_github( "sbg/sevenbridges-r", - repos = BiocManager::repositories(), - build_vignettes = TRUE, dependencies = TRUE -)
If you have trouble with pandoc
and do not want to install it, set build_vignettes = FALSE
to avoid building the vignettes.
# Direct authentication -a <- Auth(token = "your_token", platform = "cgc") ++a <- Auth(token = "your_token", url = "https://cgc-api.sbgenomics.com/v2")+# Direct authentication +a <- Auth(token = "your_token", platform = "cgc") # or use base url -a <- Auth(token = "your_token", url = "https://cgc-api.sbgenomics.com/v2")
sbg_set_env(token = "your_token", url = "https://cgc-api.sbgenomics.com/v2") -a <- Auth(from = "env")
+sbg_set_env(token = "your_token", url = "https://cgc-api.sbgenomics.com/v2") +a <- Auth(from = "env")
a <- Auth(from = "file", profile_name = "aws-us-username")
+a <- Auth(from = "file", profile_name = "aws-us-username")
Please check vignette("api", package = "sevenbridges")
for technical details about all available authentication methods.
A complete API R client with a user-friendly, object-oriented API with printing and support operations for API requests relating to users, billing, projects, files, apps, and tasks. Short examples are also included, as shown below:
-# Get a project by pattern-matching its name -p <- a$project("demo") ++p$upload("folder_path", metadata = list(platform = "Illumina"))+# Get a project by pattern-matching its name +p <- a$project("demo") # Get a project by its id -p <- a$project(id = "username/demo") +p <- a$project(id = "username/demo") # Delete files from a project -p$file("sample.tz")$delete() +p$file("sample.tz")$delete() # Upload fies from a folder to a project and include file metadata -p$upload("folder_path", metadata = list(platform = "Illumina"))
A task monitoring hook which allows you to add a hook function to specific task statuses as you monitor a task. For example, you can opt to receive an email when the task is completed or specify to download all files produced by the task, as shown below:
-setTaskHook("completed", function() { - tsk$download("~/Downloads") -}) -tsk$monitor()
+setTaskHook("completed", function() { + tsk$download("~/Downloads") +}) +tsk$monitor()
Batch tasks by metadata and by item.
-# Batch by item -(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 - ) -)) ++(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 + ) +))+# Batch by item +(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. Note that input files must # have relevant 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 - ) -))
A Common Workflow Language (CWL) Tool interface to directly describe your tool in R, export it to JSON or YAML, or add it to your online project. This package defines a complete set of CWL object, so you can describe tools as follows:
-fd <- fileDef(name = "runif.R", content = readr::read_file(fl)) ++rbx$toYAML()+fd <- fileDef(name = "runif.R", content = readr::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") -) +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") +) # Print CWL JSON -rbx$toJSON(pretty = TRUE) +rbx$toJSON(pretty = TRUE) # Print CWL YAML -rbx$toYAML()
Utilities for Tool
and Flow
, for example
library("sevenbridges") ++t1$input_matrix()+library("sevenbridges") # convert a SBG CWL JSON file -t1 <- system.file("extdata/app", "tool_star.json", package = "sevenbridges") +t1 <- system.file("extdata/app", "tool_star.json", package = "sevenbridges") # convert json file into a Tool object -t1 <- convert_app(t1) +t1 <- convert_app(t1) # shows all input matrix -t1$input_matrix()
In your browser, you can see where the RStudio server is located from the path http://<url>:8787/
. For example, if 192.168.99.100 is returned, visit http://192.168.99.100:8787/
for Rstudio.
For the Shiny server, each app__ is hosted at http://<url>:3838/users/<username of rstudio>/<app_dir>
for the Shiny server. For example, an app called 01_hello
owned by user rstudio
(a default user) has the path http://<url>:3838/users/rstudio/01_hello/
. To develop your Shiny apps as an Rstudio user, you can login your RStudio server and create a folder in your home folder called ~/ShinyApps
. There, you can develop shiny apps in that folder. For example, you can create an app called 02_text
at ~/ShinyApps/02_text/
.
Log into your RStudio at http://<url>:8787
. Then, try to copy an app to your home folder, as follows:
dir.create("~/ShinyApps") -file.copy( ++ recursive = TRUE +)+dir.create("~/ShinyApps") +file.copy( "/usr/local/lib/R/site-library/shiny/examples/01_hello/", "~/ShinyApps/", - recursive = TRUE -)
If you are logged in as user rstudio
, visit http://192.168.99.100:3838/rstudio/01_hello
. You should be able to see the “hello” example.
Note: Generic Shiny apps can also be hosted at http://<url>:3838/
or, for a particular app, at http://<url>:3838/<app_dir>
. Inside the Docker container, it’s hosted under /srv/shiny-server/
.
The best place to ask questions about the sevenbridges
package is the mailing list.
Q: Does this package support Seven Bridges’ API v1 which was not CWL compatible?
A: No. This package only supports API v2 +. For API v1, please check out the sbgr package. Note that API v1 and associated legacy project types will be deprecated eventually.
Q: Which version of the Common Workflow Language (CWL) is supported?
A: We support draft 2 and are making progress on supporting draft 3.
Q: Is there a Python binding for the API?
A: Yes, the official Python client is here. Recipes and tutorials using the Python bindings are here.
Q: Why do I get warning messages when I use the API R client?
A: The warning only exists in Rstudio and is potentially a bug in Rstudio. To ignore, it use options(warn = -1)
NEWS.md
+
data.table::rbindlist()
when possible to increase the data frame binding performance.authorization
in Auth
and api()
to allow specifying the token
as the access token from Seven Bridges single sign-on (SSO).created_by
, created_on
, and modified_on
to the Project
class following the recent API improvements. This enables better project filtering when querying projects. See the vignette for details."aws-us"
, "aws-eu"
, "ali-cn"
, "cgc"
, "cavatica"
, and "f4c"
in Auth()
calls.description
to the Files
class following the recent API improvements.use_interruptible
for project_new()
and use_interruptible_instances
for task_add()
. This will allow users to enable/disable the spot instance feature on both the project level and individual task level. See the new section “Run tasks using spot instances” in the API vignette for details.BiocManager
for installation instructions.rabix-cli
(Bunny) to 1.0.2 for the Docker container.get_token()
for getting the authentication token for different Seven Bridges platforms. The old function misc_get_token()
is deprecated.misc_make_metadata()
is deprecated, use Metadata()
for metadata constructor instead.misc_make_metadata()
is deprecated, use Metadata()
for metadata constructor instead.
Added fields
as query default in API calls, the same with limit
, offset
; now requests on file details will use fields = "_all"
directly so that only one request is issued. The same applies to updating a upload logic for folder/multiple files (54488bc). Thanks: Raunaq Malhotra.
Added functions input_matrix()
and output_matrix()
(2ec7c84) to extract input/output matrix from CWL JSON files directly, without converting CWL JSON to Tool
or Flow
objects. This is a faster implementation compared to the old method, and more stable to custom fields.
Added functions input_matrix()
and output_matrix()
(2ec7c84) to extract input/output matrix from CWL JSON files directly, without converting CWL JSON to Tool
or Flow
objects. This is a faster implementation compared to the old method, and more stable to custom fields.
id
app id
project
project id
if (FALSE) { -a <- Auth(url = "https://api.sbgenomics.com/v2/", token = "your_token") ++app <- a$public_app(id = "admin/sbg-public-data/star") +app$input_matrix() +app$output_matrix()} +if (FALSE) { +a <- Auth(url = "https://api.sbgenomics.com/v2/", token = "your_token") # get a public app -app <- a$public_app(id = "admin/sbg-public-data/rna-seq-alignment-star") -app$input_matrix() -app$output_matrix() +app <- a$public_app(id = "admin/sbg-public-data/rna-seq-alignment-star") +app$input_matrix() +app$output_matrix() # get a public app -app <- a$public_app(id = "admin/sbg-public-data/star") -app$input_matrix() -app$output_matrix()}
from
[character] Authentication method. Could be "direct"
(pass the credential information to the arguments directly),
"env"
(read from pre-set system environment variables),
@@ -223,7 +223,7 @@
api(
...,
limit = getOption("sevenbridges")$limit,
@@ -322,18 +322,20 @@ Methods
Examples
# Direct authentication (default)
# replace with your auth token
-token <- "your_token"
-a <- Auth(platform = "cgc", token = token)#> if (FALSE) {
+token <- "your_token"
+a <- Auth(platform = "cgc", token = token)
+#> if (FALSE) {
# Authentication with environment variables
# This will read system environments variables
# `SB_API_ENDPOINT` and `SB_AUTH_TOKEN` by default
-a <- Auth(from = "env")
+a <- Auth(from = "env")
# Authentication with user configuration file
# This will load profile `default` from config
# file `~/.sevenbridges/credentials` by default
-a <- Auth(from = "file")
-}
+a <- Auth(from = "file")
+}
+
loadContents
[logical] Only applies when type is File. Read up to the first 64 KiB of text from the file and place it in the "contents" field of the file object for manipulation by @@ -192,7 +192,8 @@
Binding(loadContents = TRUE, secondaryFiles = "./test.txt")#> loadContents: yes +@@ -206,11 +207,11 @@Binding(loadContents = TRUE, secondaryFiles = "./test.txt") +#> loadContents: yes #> secondaryFiles: ./test.txt #>Contents
diff --git a/docs/reference/CCBList.html b/docs/reference/CCBList.html index 6ce57dc..3821edf 100644 --- a/docs/reference/CCBList.html +++ b/docs/reference/CCBList.html @@ -91,7 +91,7 @@
characterORCommandLineBindingList Class
CCBList(...)+
CCBList(...)