Title: | Interface to the 'OpenGWAS' Database API |
---|---|
Description: | Interface to the 'OpenGWAS' database API <https://api.opengwas.io/api/>. Includes a wrapper to make generic calls to the API, plus convenience functions for specific queries. |
Authors: | Gibran Hemani [aut, cre, cph] , Ben Elsworth [aut] , Tom Palmer [aut] , Rita Rasteiro [aut] |
Maintainer: | Gibran Hemani <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.2 |
Built: | 2024-11-20 05:20:57 UTC |
Source: | https://github.com/MRCIEU/ieugwasr |
Look up allele frequencies and LD scores for 1000 genomes populations by chrpos
afl2_chrpos(chrpos, reference = "1000g", opengwas_jwt = get_opengwas_jwt())
afl2_chrpos(chrpos, reference = "1000g", opengwas_jwt = get_opengwas_jwt())
chrpos |
list of |
reference |
Default= |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Data frame containing ancestry specific LD scores and allele frequencies for each variant
Data frame includes 1000 genomes metadata including sample sizes, allele frequency and LD score, separated by 5 super populations (EUR = European, AFR = African, EAS = East Asian, AMR = Admixed American, SAS = South Asian)
afl2_list( variantlist = c("reduced", "hapmap3")[1], opengwas_jwt = get_opengwas_jwt() )
afl2_list( variantlist = c("reduced", "hapmap3")[1], opengwas_jwt = get_opengwas_jwt() )
variantlist |
Choose pre-defined list. reduced = ~20k SNPs that are common in all super populations (default). hapmap3 = ~1.3 million hm3 SNPs |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Data frame containing ancestry specific LD scores and allele frequencies for each variant
Look up allele frequencies and LD scores for 1000 genomes populations by rsid
afl2_rsid(rsid, reference = "1000g", opengwas_jwt = get_opengwas_jwt())
afl2_rsid(rsid, reference = "1000g", opengwas_jwt = get_opengwas_jwt())
rsid |
Vector of rsids |
reference |
Default= |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Data frame containing ancestry specific LD scores and allele frequencies for each variant
There are a number of different GET and POST endpoints in the GWAS database API. This is a generic way to access them.
api_query( path, query = NULL, opengwas_jwt = get_opengwas_jwt(), method = "GET", silent = TRUE, encode = "json", timeout = 300, override_429 = FALSE )
api_query( path, query = NULL, opengwas_jwt = get_opengwas_jwt(), method = "GET", silent = TRUE, encode = "json", timeout = 300, override_429 = FALSE )
path |
Either a full query path (e.g. for get) or an endpoint (e.g. for post) queries |
query |
If post query, provide a list of arguments as the payload. |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
method |
|
silent |
|
encode |
Default = |
timeout |
Default = |
override_429 |
Default=FALSE. If allowance is exceeded then the query will error before submitting a request to avoid getting blocked. If you are sure you want to submit the request then set this to TRUE. |
httr response object
MR-Base server status
api_status()
api_status()
list of values regarding status
Every rsid is searched for against each requested GWAS id. To get a list of
available GWAS ids, or to find their meta data, use gwasinfo
.
Can request LD proxies for instances when the requested rsid is not present
in a particular GWAS dataset. This currently only uses an LD reference panel
composed of Europeans in 1000 genomes version 3.
It is also restricted to biallelic single nucleotide polymorphisms (no indels),
with European MAF > 0.01.
associations( variants, id, proxies = 1, r2 = 0.8, align_alleles = 1, palindromes = 1, maf_threshold = 0.3, opengwas_jwt = get_opengwas_jwt() )
associations( variants, id, proxies = 1, r2 = 0.8, align_alleles = 1, palindromes = 1, maf_threshold = 0.3, opengwas_jwt = get_opengwas_jwt() )
variants |
Array of variants e.g. |
id |
Array of GWAS studies to query. See |
proxies |
|
r2 |
Minimum proxy LD rsq value. Default= |
align_alleles |
Try to align tag alleles to target alleles (if |
palindromes |
Allow palindromic SNPs (if |
maf_threshold |
MAF threshold to try to infer palindromic SNPs. Default = |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Dataframe
Extract batch name from study ID
batch_from_id(id)
batch_from_id(id)
id |
Array of study IDs |
Array of batch names
Get list of data batches in IEU GWAS database
batches(opengwas_jwt = get_opengwas_jwt())
batches(opengwas_jwt = get_opengwas_jwt())
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
data frame
Deprectated. Use get_opengwas_jwt()
instead. See https://mrcieu.github.io/ieugwasr/articles/guide.html#authentication for more information.
check_access_token()
check_access_token()
NULL or access_token depending on current authentication state
This function checks if a recent query indicated that the OpenGWAS allowance has been used up. To prevent the IP being blocked, it will error if the new query is being submitted before the reset time.
If the allowance has been used up, it displays a message indicating the time when the allowance will be reset.
By default, the function will throw an error if the allowance has been used up, but this behavior can be overridden by setting override_429
to TRUE
.
check_reset(override_429 = FALSE)
check_reset(override_429 = FALSE)
override_429 |
Logical value indicating whether to override the allowance reset check (default: FALSE) |
Check datasets that are in process of being uploaded
editcheck(id, opengwas_jwt = get_opengwas_jwt())
editcheck(id, opengwas_jwt = get_opengwas_jwt())
id |
ID |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Dataframe
Look up sample sizes when meta data is missing from associations
fill_n(d, opengwas_jwt = get_opengwas_jwt())
fill_n(d, opengwas_jwt = get_opengwas_jwt())
d |
Output from |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Updated version of d
Retrieve OpenGWAS JSON Web Token from .Renviron file
get_opengwas_jwt()
get_opengwas_jwt()
JWT string
Parse out json response from httr object
get_query_content(response)
get_query_content(response)
response |
Output from httr |
Parsed json output from query, often in form of data frame. If status code is not successful then return the actual response
Get list of studies with available GWAS summary statistics through API
gwasinfo(id = NULL, opengwas_jwt = get_opengwas_jwt())
gwasinfo(id = NULL, opengwas_jwt = get_opengwas_jwt())
id |
List of MR-Base IDs to retrieve. If |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Dataframe of details for all available studies
Uses ~20k SNPs selected for common frequency across 5 major super populations
infer_ancestry(d, snpinfo = NULL, opengwas_jwt = get_opengwas_jwt())
infer_ancestry(d, snpinfo = NULL, opengwas_jwt = get_opengwas_jwt())
d |
Data frame containing at least |
snpinfo |
Output from |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
data frame ordered by most likely ancestry, each row represents a super population and cor column represents the correlation between the GWAS dataset and the 1000 genomes super population allele frequencies
Uses PLINK clumping method, where SNPs in LD within a particular window will be pruned. The SNP with the lowest p-value is retained.
ld_clump( dat = NULL, clump_kb = 10000, clump_r2 = 0.001, clump_p = 0.99, pop = "EUR", opengwas_jwt = get_opengwas_jwt(), bfile = NULL, plink_bin = NULL )
ld_clump( dat = NULL, clump_kb = 10000, clump_r2 = 0.001, clump_p = 0.99, pop = "EUR", opengwas_jwt = get_opengwas_jwt(), bfile = NULL, plink_bin = NULL )
dat |
Dataframe. Must have a variant name column ( |
clump_kb |
Clumping kb window. Default is very strict, |
clump_r2 |
Clumping r2 threshold. Default is very strict, |
clump_p |
Clumping sig level for index variants. Default = |
pop |
Super-population to use as reference panel. Default = |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT.#' |
bfile |
If this is provided then will use the API. Default = |
plink_bin |
If |
This function interacts with the OpenGWAS API, which houses LD reference panels for the 5 super-populations in the 1000 genomes reference panel. It includes only bi-allelic SNPs with MAF > 0.01, so it's quite possible that a variant you want to include in the clumping process will be absent. If it is absent, it will be automatically excluded from the results.
You can check if your variants are present in the LD reference panel using
ld_reflookup()
.
This function does put load on the OpenGWAS servers, which makes life more
difficult for other users. We have implemented a method and made available
the LD reference panels to perform clumping locally, see
ld_clump()
and related vignettes for details.
Data frame
Perform clumping on the chosen variants using through API
ld_clump_api( dat, clump_kb = 10000, clump_r2 = 0.1, clump_p, pop = "EUR", opengwas_jwt = get_opengwas_jwt() )
ld_clump_api( dat, clump_kb = 10000, clump_r2 = 0.1, clump_p, pop = "EUR", opengwas_jwt = get_opengwas_jwt() )
dat |
Dataframe. Must have a variant name column ( |
clump_kb |
Clumping kb window. Default is very strict, |
clump_r2 |
Clumping r2 threshold. Default is very strict, |
clump_p |
Clumping sig level for index variants. Default = |
pop |
Super-population to use as reference panel. Default = |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT.#' @param bfile If this is provided then will use the API. Default = |
Data frame of only independent variants
Wrapper for clump function using local plink binary and ld reference dataset
ld_clump_local(dat, clump_kb, clump_r2, clump_p, bfile, plink_bin)
ld_clump_local(dat, clump_kb, clump_r2, clump_p, bfile, plink_bin)
dat |
Dataframe. Must have a variant name column ( |
clump_kb |
Clumping kb window. Default is very strict, |
clump_r2 |
Clumping r2 threshold. Default is very strict, |
clump_p |
Clumping sig level for index variants. Default = |
bfile |
If this is provided then will use the API. Default = |
plink_bin |
Specify path to plink binary. Default = |
data frame of clumped variants
This function takes a list of SNPs and searches for them in a specified super-population in the 1000 Genomes phase 3 reference panel. It then creates an LD matrix of r values (signed, and not squared). All LD values are with respect to the major alleles in the 1000G dataset. You can specify whether the allele names are displayed.
ld_matrix( variants, with_alleles = TRUE, pop = "EUR", opengwas_jwt = get_opengwas_jwt(), bfile = NULL, plink_bin = NULL )
ld_matrix( variants, with_alleles = TRUE, pop = "EUR", opengwas_jwt = get_opengwas_jwt(), bfile = NULL, plink_bin = NULL )
variants |
List of variants (rsids) |
with_alleles |
Whether to append the allele names to the SNP names. Default: |
pop |
Super-population to use as reference panel. Default = |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT.#' @param bfile If this is provided then will use the API. Default = |
bfile |
If this is provided then will use the API. Default = |
plink_bin |
If |
The data used for generating the LD matrix includes only bi-allelic SNPs with MAF > 0.01, so it's quite possible that a variant you want to include will be absent. If it is absent, it will be automatically excluded from the results.
You can check if your variants are present in the LD reference panel using
ld_reflookup()
This function does put load on the OpenGWAS servers, which makes life more
difficult for other users, and has been limited to analyse only up to 500
variants at a time. We have implemented a method and made available the LD
reference panels to perform the operation locally, see ld_matrix()
and
related vignettes for details.
Matrix of LD r values
Get LD matrix using local plink binary and reference dataset
ld_matrix_local(variants, bfile, plink_bin, with_alleles = TRUE)
ld_matrix_local(variants, bfile, plink_bin, with_alleles = TRUE)
variants |
List of variants (rsids) |
bfile |
Path to bed/bim/fam ld reference panel |
plink_bin |
Specify path to plink binary. Default = |
with_alleles |
Whether to append the allele names to the SNP names.
Default: |
data frame
Provide a list of rsids that you may want to perform LD operations on to
check if they are present in the LD reference panel. If they are not then
some functions e.g. ld_clump
will exclude them from the analysis,
so you may want to consider how to handle those variants in your data.
ld_reflookup(rsid, pop = "EUR", opengwas_jwt = get_opengwas_jwt())
ld_reflookup(rsid, pop = "EUR", opengwas_jwt = get_opengwas_jwt())
rsid |
Array of rsids to check |
pop |
Super-population to use as reference panel. Default = |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT.#' @param bfile If this is provided then will use the API. Default = |
Array of rsids that are present in the LD reference panel
Convert current IDs to legacy IDs
legacy_ids(x)
legacy_ids(x)
x |
Vector of ids |
vector of back compatible ids
Details of how access token logs are used
logging_info()
logging_info()
No return value, called for side effects
This is faster than doing it manually through associations
phewas(variants, pval = 1e-05, batch = c(), opengwas_jwt = get_opengwas_jwt())
phewas(variants, pval = 1e-05, batch = c(), opengwas_jwt = get_opengwas_jwt())
variants |
Array of variants e.g. |
pval |
p-value threshold. Default = |
batch |
Vector of batch IDs to search across. If |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Dataframe
Print API status
## S3 method for class 'ApiStatus' print(x, ...)
## S3 method for class 'ApiStatus' print(x, ...)
x |
Output from |
... |
Unused, for extensibility |
Print out of API status
Print GWAS information
## S3 method for class 'GwasInfo' print(x, ...)
## S3 method for class 'GwasInfo' print(x, ...)
x |
Output from |
... |
Unused, for extensibility |
Print out of GWAS information
Toggle API address between development and release
select_api(where = "public", silent = FALSE)
select_api(where = "public", silent = FALSE)
where |
Which API to use. Choice between |
silent |
Silent? Default = FALSE |
No return value, called for side effects
This function sets the reset time for the OpenGWAS allowance based on the retry-after header returned by the API response. It also displays a warning message indicating the time at which the allowance will reset.
set_reset(r)
set_reset(r)
r |
The API response object |
None
By default performs clumping on the server side.
tophits( id, pval = 5e-08, clump = 1, r2 = 0.001, kb = 10000, pop = "EUR", force_server = FALSE, opengwas_jwt = get_opengwas_jwt() )
tophits( id, pval = 5e-08, clump = 1, r2 = 0.001, kb = 10000, pop = "EUR", force_server = FALSE, opengwas_jwt = get_opengwas_jwt() )
id |
Array of GWAS studies to query. See |
pval |
use this p-value threshold. Default = |
clump |
whether to clump ( |
r2 |
use this clumping r2 threshold. Default is very strict, |
kb |
use this clumping kb window. Default is very strict, |
pop |
Super-population to use as reference panel. Default = |
force_server |
Logical. By default will return preclumped hits.
p-value threshold 5e-8, with r2 threshold 0.001 and kb threshold 10000,
using only SNPs with MAF > 0.01 in the European samples in 1000 genomes.
If force_server = |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Dataframe
Get user details
user(opengwas_jwt = get_opengwas_jwt())
user(opengwas_jwt = get_opengwas_jwt())
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
user information
For a list of chromosome and positions, finds all variants within a given radius
variants_chrpos(chrpos, radius = 0, opengwas_jwt = get_opengwas_jwt())
variants_chrpos(chrpos, radius = 0, opengwas_jwt = get_opengwas_jwt())
chrpos |
list of |
radius |
Radius around each chrpos, default = |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
Data frame
Provide a gene identified, either Ensembl or Entrez
variants_gene(gene, radius = 0, opengwas_jwt = get_opengwas_jwt())
variants_gene(gene, radius = 0, opengwas_jwt = get_opengwas_jwt())
gene |
Vector of genes, either Ensembl or Entrez,
e.g. |
radius |
Radius around the gene region to include. Default = |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
data frame with the following columns
Obtain information about rsid
variants_rsid(rsid, opengwas_jwt = get_opengwas_jwt())
variants_rsid(rsid, opengwas_jwt = get_opengwas_jwt())
rsid |
Vector of rsids |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
data frame
Convert mixed array of rsid and chrpos to list of rsid
variants_to_rsid(variants, opengwas_jwt = get_opengwas_jwt())
variants_to_rsid(variants, opengwas_jwt = get_opengwas_jwt())
variants |
Array of variants e.g. |
opengwas_jwt |
Used to authenticate protected endpoints. Login to https://api.opengwas.io to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT. |
list of rsids