- Created by Nacho Medina, last modified by Marta Bleda on Jun 01, 2020
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 14 Current »
Overview
OpenCGA implements an R REST client library called opencgaR to execute any query or operation through the REST web services API. The client offers programmatic access to the implemented REST web services, facilitating the access and analysis of data stored in OpenCGA. From version 2.0.0 data is returned in a new RestResponse object which contains metadata and the results. The client also implements some handy methods to return information from this object.
opencgaR has been implemented by Marta Bleda. The code is open-source and can be found at https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/R. It can be installed easily by downloading the pre-build package. Please, find more details on how to use the R library at Using the R client.
Installation
The R client requires at least R version 3.4, although most of the code is fully compatible with earlier versions. The pre-build R package of the R client can be downloaded from the OpenCGA v2.0.0 GitHub Release at https://github.com/opencb/opencga/releases and installed using the install.packages
function in R. install.packages
can also install a source package from a remote `.tar.gz` file by providing the URL to such file (code below).
## Install opencgaR by providing the URL to the package install.packages("opencgaR_2.0.0.tar.gz", repos=NULL, type="source")
Getting started
Connection and authentication into an OpenCGA instance
A set of methods have been implemented to deal with the connectivity and login to the REST host. Connection to the host is done in two steps using the functions initOpencgaR and opencgaLogin for defining the connection details and login, respectively.
The initOpencgaR function accepts either host and version information or a configuration file (as a list()
or in YAML or JSON format). The opencgaLogin function establishes the connection with the host, it requires an opencgaR object (created using initOpencgaR
function) and the login details: user and password. User and password can optionally be introduced interactively through a popup window using interactive=TRUE
, to avoid typing user credentials within the R script or a config file.
The code below shows three different ways to initialise the OpenCGA connection with the REST server.
## Initialise connection specifying host and REST version con <- initOpencgaR(host = "http://bioinfo.hpc.cam.ac.uk/opencga-prod/", version = "v2") ## Initialise connection using a configuration in R list conf <- list(version="v2", rest=list(host="http://bioinfo.hpc.cam.ac.uk/opencga-prod/")) con <- initOpencgaR(opencgaConfig=conf) ## Initialise connection using a configuration file (in YAML or JSON format) conf <- "/path/to/conf/client-configuration.yml" con <- initOpencgaR(opencgaConfig=conf)
Once the connection has been initialised users can login specifying their OpenCGA user ID and password.
## Log in con <- opencgaLogin(opencga = con, userid = "demouser", passwd = "demouser")
## Look for the first 5 sample IDs of the study "study" sample_result = oc.samples.search(study='study', limit=5, include='id')
| endpointName | Endpoint WS | parameters accepted | | -- | :-- | --: | | groupByAudit | /{apiVersion}/admin/audit/groupBy | count, limit, fields[*], entity[*], action, before, after, date | | indexStatsCatalog | /{apiVersion}/admin/catalog/indexStats | | | installCatalog | /{apiVersion}/admin/catalog/install | body[*] | | jwtCatalog | /{apiVersion}/admin/catalog/jwt | body[*] | | createUsers | /{apiVersion}/admin/users/create | body[*] | | importUsers | /{apiVersion}/admin/users/import | body[*] | | syncUsers | /{apiVersion}/admin/users/sync | body[*] |
Table of Contents:
- No labels