query: Discover and query Gen3 resources

Description Usage Arguments Details Value Examples

Description

projects() returns projects available to the currently authenticated user

schema() returns all type names (objects) defined in the Gen3 schema. Type names form the basis of queries.

fields() returns fields defined on the type name. A field has associated values that can be retrieved by queries.

values() returns values corresponding to fields of type_name. Each row represents a record in the database.

query_graphql() allows arbitrary queries against the graphql database.

Usage

1
2
3
4
5
6
7
8
9
projects()

schema(as = c("brief", "full"))

fields(type_name, as = c("brief", "full"))

values(type_name, ..., .n = 10)

query_graphql(query)

Arguments

as

for fields(), "brief" returns fields that do not start with an underscore. "full" returns all fields.

type_name

character(1) name of the type to be queried.

...

character(1) field(s) to be queried.

.n

integer(1) number of records to retieve. The special value .n = 0 retrieves all records.

query

character(1) valid graphql query to be evaluated by the database.

Details

Generally, GraphQL schema() fields starting with '_', e.g., 'subjects_count', are returned with the leading '' replaced by '.', e.g., '.subjects_count'.

Value

projects() returns a tibble with project_id, id, and study_description. There are as many rows as there are projects accessbile to the current user.

schema() returns a tibble with with a single columm ("name") corresponding to the type names available in Gen3.

fields() returns a tibble with columns type_name, field (name of corresponding fields in type name) and type (type of field, e.g., String, Int).

values() returns a tibble with type_name and field names as columns, with one row for each record queried.

query_graphql() returns JSON-like list-of-lists following the structure of the query, but with terminal data.frame-like collections simplified to a tibbles.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Authenticate first; prefer authentication with credentials
response <- tryCatch(authenticate(), error = identity)
if (inherits(response, "error")) {
    ## perhaps credentials are cached...
    cache <- tools::R_user_dir("Gen3", "cache")
    credentials <- file.path(cache, "credentials.json")
    stopifnot(
        `no credentials file, cannot authenticate` = file.exists(credentials)
    )
    authenticate(credentials)
}

projects() 

schema()

fields("subject")

values("subject", "id", "sex")

query <- '{
    subject(
        project_id: "open_access-1000Genomes"
        first: 0
    ) {
        id
        sex
        population
        submitter_id
    }
}'
result <- query_graphql(query)
result

Bioconductor/Gen3 documentation built on Aug. 13, 2020, 4:13 p.m.