requireNamespace("knitr") knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
In this example, we're going to run a simple remote gor query using the gorr
package.
First load the gorr
package, the tidyverse
package is recommended in general, but not required for this example
library(gorr) library(magrittr) # pipe library(tibble)
First we'll need to establish a connection to our direct query API. To do that we'll need to call gor_connect
and provide it with the relevant parameters pointing to the direct-query-service, i.e. api_key
and project
:
api_key <- Sys.getenv("GOR_API_KEY") conn <- gor_connect(api_key, project = Sys.getenv("GOR_API_PROJECT")) conn
If everything goes as planned, we'll have a conn
object to
pass into the gor_query
function to finally run a query:
result <- gor_query("gor #dbsnp# | top 100", conn)
The results come back as an R data.frame
:
print(result)
It should also be noted that larger gor queries can be constructed inside a string block and piped directly into the
gor_query
function:
chr21_results <- " gor -p chr21 #dbsnp# | where len(reference)=1 and len(allele)=1 | calc snptype reference+'/'+allele | hide rsIDs | top 100" %>% gor_query(conn)
print(chr21_results)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.