An explanation about how to install and use the R package can be found here: R
In this document we will create an example tutorial to learn how to work with the R client.
# Load the R package library(opencgaR) # We need to define the host where OpenCGA is installed. # Users following this tutorial will need to change the host variable to point to their own installation. con <- initOpencgaR(host = "localhost:8080/opencga/", version = "v1") # 'con' will be an instance of our OpencgaR class and will need to be passed to any method # And login passing the main configuration and defining our user credentials con <- opencgaLogin(opencga = con, userid = "user", passwd = "userPassword") # First, we will look for the first 10 families containing a particular disorder families <- familyClient(con, family = NULL, action="search", params=list(study="RD38", limit=10, disorders="Rod-cone dystrophy", include="id,members.id")) # families will be a data frame containing all the Family fields we have included # To see the family ids we will need to families$id # To see the list of members of the families for each family, we will need to run something like for (i in c(1:10)) { print (families$id[i]) print (families$members[[i]]$id) } # Next, we will fetch the first 10 variant ids associated to the previous families falling in the 'BMPR2' gene # To do so, we will first create a function to fetch those variants given a familyId getVariants <- function(familyId, con) { variants <- analysisVariantClient(con, action="query", params=list(study="RD38",gene="BMPR2",family=familyId,includeSamples="None",limit=10)) return (variants$id) } # And now, we can get those results by running the following line: variants <- sapply(families$id, getVariants, con=con) # This way, we will get a list of familyId -> list of 10 associated variant ids