From 064ec10aea61c53c8be17e44112a3d8381151d21 Mon Sep 17 00:00:00 2001 From: Gibran Hemani Date: Sun, 21 Apr 2024 16:12:52 +0100 Subject: [PATCH] removing google oauth2 --- DESCRIPTION | 3 +-- NAMESPACE | 2 -- NEWS.md | 1 + R/afl2.r | 47 +++++++++-------------------------- R/api.R | 49 +++---------------------------------- R/ld_clump.R | 18 +++++--------- R/ld_matrix.R | 6 ++--- R/query.R | 50 +++++++++++++------------------------- R/variants.R | 20 +++++++++------ man/afl2_chrpos.Rd | 4 ++- man/afl2_list.Rd | 7 +++++- man/afl2_rsid.Rd | 4 ++- man/api_query.Rd | 4 --- man/associations.Rd | 4 --- man/batches.Rd | 5 +--- man/check_access_token.Rd | 5 ++-- man/editcheck.Rd | 9 +------ man/fill_n.Rd | 12 +++------ man/get_access_token.Rd | 14 ----------- man/gwasinfo.Rd | 9 +------ man/infer_ancestry.Rd | 4 ++- man/ld_clump.Rd | 4 --- man/ld_clump_api.Rd | 4 --- man/ld_matrix.Rd | 4 --- man/ld_reflookup.Rd | 10 +------- man/phewas.Rd | 11 +-------- man/revoke_access_token.Rd | 14 ----------- man/tophits.Rd | 4 --- man/variants_chrpos.Rd | 4 ++- man/variants_gene.Rd | 4 ++- man/variants_rsid.Rd | 4 ++- man/variants_to_rsid.Rd | 4 ++- vignettes/guide.Rmd | 5 ++-- 33 files changed, 95 insertions(+), 254 deletions(-) delete mode 100644 man/get_access_token.Rd delete mode 100644 man/revoke_access_token.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 100d61f..df01244 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ieugwasr Title: Interface to the 'OpenGWAS' Database API -Version: 0.2.2-9003 +Version: 1.0.0 Authors@R: c( person("Gibran", "Hemani", , "g.hemani@bristol.ac.uk", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-0920-1055")), @@ -25,7 +25,6 @@ Imports: jsonlite, magrittr, rlang, - googleAuthR, stats Suggests: knitr, diff --git a/NAMESPACE b/NAMESPACE index bab475c..77f5107 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,7 +14,6 @@ export(batches) export(check_access_token) export(editcheck) export(fill_n) -export(get_access_token) export(get_opengwas_jwt) export(get_query_content) export(gwasinfo) @@ -27,7 +26,6 @@ export(ld_reflookup) export(legacy_ids) export(logging_info) export(phewas) -export(revoke_access_token) export(select_api) export(tophits) export(user) diff --git a/NEWS.md b/NEWS.md index 1e2a6e7..10ed297 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # ieugwasr 1.0.0 * Introducing JWT authorisation for the API +* Phasing out Google Oauth2 authorisation * Added user() function to get user information * Fixing issue with anonymous functions and backwards compatibility * Bug in tophits when result is empty diff --git a/R/afl2.r b/R/afl2.r index 7de469c..b26fc13 100644 --- a/R/afl2.r +++ b/R/afl2.r @@ -7,14 +7,15 @@ #' #' @param variantlist Choose pre-defined list. reduced = ~20k SNPs that are #' common in all super populations (default). hapmap3 = ~1.3 million hm3 SNPs +#' @param 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. #' #' @export #' @return Data frame containing ancestry specific LD scores and allele frequencies for each variant -afl2_list <- function(variantlist=c("reduced", "hapmap3")[1]) +afl2_list <- function(variantlist=c("reduced", "hapmap3")[1], opengwas_jwt=get_opengwas_jwt()) { if(variantlist == "reduced") { - api_query("variants/afl2/snplist") %>% + api_query("variants/afl2/snplist", opengwas_jwt=opengwas_jwt) %>% get_query_content() %>% dplyr::as_tibble() %>% return() @@ -33,12 +34,13 @@ afl2_list <- function(variantlist=c("reduced", "hapmap3")[1]) #' #' @param rsid Vector of rsids #' @param reference Default=`"1000g"` +#' @param 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. #' #' @export #' @return Data frame containing ancestry specific LD scores and allele frequencies for each variant -afl2_rsid <- function(rsid, reference="1000g") +afl2_rsid <- function(rsid, reference="1000g", opengwas_jwt=get_opengwas_jwt()) { - out <- api_query("variants/afl2", list(rsid=rsid)) %>% get_query_content() + out <- api_query("variants/afl2", list(rsid=rsid), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(inherits(out, "response")) { return(out) @@ -54,12 +56,13 @@ afl2_rsid <- function(rsid, reference="1000g") #' @param chrpos list of `:` in build 37, e.g. `c("3:46414943", "3:122991235")`. #' Also allows ranges e.g `"7:105561135-105563135"` #' @param reference Default=`"1000g"` +#' @param 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. #' #' @export #' @return Data frame containing ancestry specific LD scores and allele frequencies for each variant -afl2_chrpos <- function(chrpos, reference="1000g") +afl2_chrpos <- function(chrpos, reference="1000g", opengwas_jwt=get_opengwas_jwt()) { - out <- api_query("variants/afl2", list(chrpos=chrpos)) %>% get_query_content() + out <- api_query("variants/afl2", list(chrpos=chrpos), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(inherits(out, "response")) { return(out) @@ -79,14 +82,15 @@ afl2_chrpos <- function(chrpos, reference="1000g") #' e.g. output from associations #' @param snpinfo Output from [`afl2_list`], [`afl2_rsid`] or [`afl2_chrpos`]. #' If `NULL` then [`afl2_list()`] is used by default +#' @param 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. #' #' @export #' @return 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 -infer_ancestry <- function(d, snpinfo=NULL) +infer_ancestry <- function(d, snpinfo=NULL, opengwas_jwt=get_opengwas_jwt()) { if(is.null(snpinfo)) { - snpinfo <- afl2_list() + snpinfo <- afl2_list(opengwas_jwt=opengwas_jwt) } snpinfo <- snpinfo %>% dplyr::inner_join(., d, by="rsid") @@ -100,30 +104,3 @@ infer_ancestry <- function(d, snpinfo=NULL) return(out) } -#' Look up sample sizes when meta data is missing from associations -#' -#' @param d Output from [`associations`] -#' -#' @export -#' @return Data frame which is an updated version of the input but with sample sizes inferred where missing -fill_n <- function(d) -{ - id <- d$id[1] - if(! "n" %in% names(d)) - { - d$n <- NA - } - d$n <- as.numeric(d$n) - if(any(is.na(d$n))) - { - info <- gwasinfo(id) - if(!is.na(info$sample_size)) - { - d$n <- info$sample_size - } else { - d$n <- info$ncase + info$ncontrol - } - } - return(d) -} - diff --git a/R/api.R b/R/api.R index 477b364..6197540 100644 --- a/R/api.R +++ b/R/api.R @@ -67,57 +67,14 @@ logging_info <- function() } -#' Get access token for OAuth2 access to MR Base +#' Check if authentication has been maded #' -#' -#' @export -#' @return access token string -get_access_token <- function() -{ - message("Using access token. For info on how this is used see logging_info()") - tf <- basename(tempfile()) - check <- suppressWarnings(file.create(tf)) - if(!check) - { - stop("You are currently in a directory which doesn't have write access.\n", - " In order to authenticate we need to store the credentials in a file called '.httr-oauth'.\n", - " Please setwd() to a different directory where you have write access.") - } else { - unlink(tf) - } - a <- googleAuthR::gar_auth(email=TRUE) - if(! a$validate()) - { - a$refresh() - } - return(a$credentials$access_token) -} - - -#' Check if authentication has been made -#' -#' If a call to [`get_access_token()`] has been made then it will have generated `mrbase.oauth`. -#' Pass the token if it is present, if not, return `NULL` and do not authenticate. +#' Deprectated. Use `get_opengwas_jwt()` instead. See https://mrcieu.github.io/ieugwasr/articles/guide.html#authentication for more information. #' #' @export #' @return NULL or access_token depending on current authentication state check_access_token <- function() { - if(file.exists("ieugwasr_oauth")) - { - return(get_access_token()) - } else { - return(NULL) - } + message("Deprectated. Use `get_opengwas_jwt()` instead. See https://mrcieu.github.io/ieugwasr/articles/guide.html#authentication for more information.") } - -#' Revoke access token for MR Base -#' -#' @export -#' @return No return value, called for side effects -revoke_access_token <- function() -{ - a <- googleAuthR::gar_auth("mrbase.oauth") - a$revoke() -} diff --git a/R/ld_clump.R b/R/ld_clump.R index 128755e..ef6ac83 100644 --- a/R/ld_clump.R +++ b/R/ld_clump.R @@ -27,8 +27,6 @@ #' Options are `"EUR"`, `"SAS"`, `"EAS"`, `"AFR"`, `"AMR"`. #' `'legacy'` also available - which is a previously used verison of the EUR #' panel with a slightly different set of markers -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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 = `NULL` #' @param plink_bin If `NULL` and `bfile` is not `NULL` then will detect @@ -38,7 +36,7 @@ #' @export #' @return Data frame ld_clump <- function(dat=NULL, clump_kb=10000, clump_r2=0.001, clump_p=0.99, - pop = "EUR", access_token=check_access_token(),opengwas_jwt=get_opengwas_jwt(), bfile=NULL, plink_bin=NULL) + pop = "EUR", opengwas_jwt=get_opengwas_jwt(), bfile=NULL, plink_bin=NULL) { stopifnot("rsid" %in% names(dat)) @@ -79,7 +77,7 @@ ld_clump <- function(dat=NULL, clump_kb=10000, clump_r2=0.001, clump_p=0.99, message("Clumping ", ids[i], ", ", nrow(x), " variants, using ", pop, " population reference") if(is.null(bfile)) { - res[[i]] <- ld_clump_api(x, clump_kb=clump_kb, clump_r2=clump_r2, clump_p=clump_p, pop=pop, access_token=access_token, opengwas_jwt=opengwas_jwt) + res[[i]] <- ld_clump_api(x, clump_kb=clump_kb, clump_r2=clump_r2, clump_p=clump_p, pop=pop, opengwas_jwt=opengwas_jwt) } else { res[[i]] <- ld_clump_local(x, clump_kb=clump_kb, clump_r2=clump_r2, clump_p=clump_p, bfile=bfile, plink_bin=plink_bin) } @@ -99,11 +97,9 @@ ld_clump <- function(dat=NULL, clump_kb=10000, clump_r2=0.001, clump_p=0.99, #' @param clump_p Clumping sig level for index variants. Default = `1` (i.e. no threshold) #' @param pop Super-population to use as reference panel. Default = `"EUR"`. #' Options are `"EUR"`, `"SAS"`, `"EAS"`, `"AFR"`, `"AMR"` -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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 = `NULL` #' @return Data frame of only independent variants -ld_clump_api <- function(dat, clump_kb=10000, clump_r2=0.1, clump_p, pop="EUR", access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) +ld_clump_api <- function(dat, clump_kb=10000, clump_r2=0.1, clump_p, pop="EUR", opengwas_jwt=get_opengwas_jwt()) { res <- api_query('ld/clump', query = list( @@ -114,7 +110,7 @@ ld_clump_api <- function(dat, clump_kb=10000, clump_r2=0.1, clump_p, pop="EUR", kb = clump_kb, pop = pop ), - access_token=access_token, opengwas_jwt=opengwas_jwt + opengwas_jwt=opengwas_jwt ) %>% get_query_content() y <- subset(dat, !dat[["rsid"]] %in% res) if(nrow(y) > 0) @@ -190,20 +186,18 @@ random_string <- function(n=1, len=6) #' @param rsid Array of rsids to check #' @param pop Super-population to use as reference panel. Default = `"EUR"`. #' Options are `"EUR"`, `"SAS"`, `"EAS"`, `"AFR"`, `"AMR"` -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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 = `NULL` #' #' @export #' @return Array of rsids that are present in the LD reference panel -ld_reflookup <- function(rsid, pop='EUR', access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) +ld_reflookup <- function(rsid, pop='EUR', opengwas_jwt=get_opengwas_jwt()) { res <- api_query('ld/reflookup', query = list( rsid = rsid, pop = pop ), - access_token=access_token, opengwas_jwt=opengwas_jwt + opengwas_jwt=opengwas_jwt ) %>% get_query_content() if(length(res) == 0) { diff --git a/R/ld_matrix.R b/R/ld_matrix.R index 7a69a46..e8625b1 100644 --- a/R/ld_matrix.R +++ b/R/ld_matrix.R @@ -26,8 +26,6 @@ #' Options are `"EUR"`, `"SAS"`, `"EAS"`, `"AFR"`, `"AMR"`. #' `'legacy'` also available - which is a previously used verison of the EUR #' panel with a slightly different set of markers -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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 = `NULL` #' @param bfile If this is provided then will use the API. Default = `NULL` #' @param plink_bin If `NULL` and bfile is not `NULL` then will detect packaged @@ -35,7 +33,7 @@ #' #' @export #' @return Matrix of LD r values -ld_matrix <- function(variants, with_alleles=TRUE, pop="EUR", access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt(), bfile=NULL, plink_bin=NULL) { +ld_matrix <- function(variants, with_alleles=TRUE, pop="EUR", opengwas_jwt=get_opengwas_jwt(), bfile=NULL, plink_bin=NULL) { if(length(variants) > 500 & is.null(bfile)) { stop("SNP list must be smaller than 500. Try running locally by providing local ld reference with bfile argument. See vignettes for a guide on how to do this.") @@ -52,7 +50,7 @@ ld_matrix <- function(variants, with_alleles=TRUE, pop="EUR", access_token=check return(ld_matrix_local(variants, bfile=bfile, plink_bin=plink_bin, with_alleles=with_alleles)) } - res <- api_query('ld/matrix', query = list(rsid=variants, pop=pop), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() + res <- api_query('ld/matrix', query = list(rsid=variants, pop=pop), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(all(is.na(res))) stop("None of the requested variants were found") variants2 <- res$snplist diff --git a/R/query.R b/R/query.R index 14aed0b..8dabb50 100644 --- a/R/query.R +++ b/R/query.R @@ -5,8 +5,6 @@ #' #' @param path Either a full query path (e.g. for get) or an endpoint (e.g. for post) queries #' @param query If post query, provide a list of arguments as the payload. `NULL` by default -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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 method `"GET"` (default) or `"POST"`, `"DELETE"` etc #' @param silent `TRUE`/`FALSE` to be passed to httr call. `TRUE` by default @@ -16,7 +14,7 @@ #' #' @export #' @return httr response object -api_query <- function(path, query=NULL, access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt(), +api_query <- function(path, query=NULL, opengwas_jwt=get_opengwas_jwt(), method="GET", silent=TRUE, encode="json", timeout=300) { ntry <- 0 @@ -24,14 +22,12 @@ api_query <- function(path, query=NULL, access_token=check_access_token(), openg if(opengwas_jwt == "") { headers <- httr::add_headers( # 'Content-Type'='application/json; charset=UTF-8', - 'X-Api-Token'=access_token, 'X-Api-Source'=ifelse(is.null(options()$mrbase.environment), 'R/TwoSampleMR', 'mr-base-shiny'), 'X-TEST-MODE-KEY'=Sys.getenv("OPENGWAS_X_TEST_MODE_KEY") ) } else { headers <- httr::add_headers( # 'Content-Type'='application/json; charset=UTF-8', - 'X-Api-Token'=access_token, 'X-Api-Source'=ifelse(is.null(options()$mrbase.environment), 'R/TwoSampleMR', 'mr-base-shiny'), 'X-TEST-MODE-KEY'=Sys.getenv("OPENGWAS_X_TEST_MODE_KEY"), 'Authorization'=paste("Bearer", opengwas_jwt=opengwas_jwt) @@ -170,21 +166,19 @@ print.ApiStatus <- function(x, ...) #' #' @param id List of MR-Base IDs to retrieve. If `NULL` (default) retrieves all #' available datasets -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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. #' #' @export #' @return Dataframe of details for all available studies -gwasinfo <- function(id=NULL, access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) +gwasinfo <- function(id=NULL, opengwas_jwt=get_opengwas_jwt()) { id <- legacy_ids(id) if(!is.null(id)) { stopifnot(is.vector(id)) - out <- api_query('gwasinfo', query = list(id=id), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() + out <- api_query('gwasinfo', query = list(id=id), opengwas_jwt=opengwas_jwt) %>% get_query_content() } else { - out <- api_query('gwasinfo', access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() + out <- api_query('gwasinfo', opengwas_jwt=opengwas_jwt) %>% get_query_content() } if(length(out) == 0) { @@ -219,15 +213,13 @@ batch_from_id <- function(id) #' Get list of data batches in IEU GWAS database #' -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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. #' #' @export #' @return data frame -batches <- function(access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) +batches <- function(opengwas_jwt=get_opengwas_jwt()) { - api_query('batches', access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() + api_query('batches', opengwas_jwt=opengwas_jwt) %>% get_query_content() } #' Query specific variants from specific GWAS @@ -248,13 +240,11 @@ batches <- function(access_token=check_access_token(), opengwas_jwt=get_opengwas #' `1` = yes (default), `0` = no #' @param palindromes Allow palindromic SNPs (if `proxies = 1`). `1` = yes (default), `0` = no #' @param maf_threshold MAF threshold to try to infer palindromic SNPs. Default = `0.3`. -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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. #' #' @export #' @return Dataframe -associations <- function(variants, id, proxies=1, r2=0.8, align_alleles=1, palindromes=1, maf_threshold = 0.3, access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) { +associations <- function(variants, id, proxies=1, r2=0.8, align_alleles=1, palindromes=1, maf_threshold = 0.3, opengwas_jwt=get_opengwas_jwt()) { id <- legacy_ids(id) out <- api_query("associations", query=list( variant=variants, @@ -264,7 +254,7 @@ associations <- function(variants, id, proxies=1, r2=0.8, align_alleles=1, palin align_alleles=align_alleles, palindromes=palindromes, maf_threshold=maf_threshold - ), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() + ), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(inherits(out, "response")) { @@ -278,14 +268,14 @@ associations <- function(variants, id, proxies=1, r2=0.8, align_alleles=1, palin return(out) } - #' Look up sample sizes when meta data is missing from associations #' #' @param d Output from [`associations`] +#' @param 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. #' #' @export #' @return Updated version of d -fill_n <- function(d) +fill_n <- function(d, opengwas_jwt=get_opengwas_jwt()) { id <- d$id[1] if(! "n" %in% names(d)) @@ -295,7 +285,7 @@ fill_n <- function(d) d$n <- as.numeric(d$n) if(any(is.na(d$n))) { - info <- gwasinfo(id) + info <- gwasinfo(id, opengwas_jwt=opengwas_jwt) if(!is.na(info$sample_size)) { d$n <- info$sample_size @@ -325,19 +315,17 @@ fix_n <- function(d) #' @param variants Array of variants e.g. `c("rs234", "7:105561135-105563135")` #' @param pval p-value threshold. Default = `0.00001` #' @param batch Vector of batch IDs to search across. If `c()` (default) then returns all batches -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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. #' #' @export #' @return Dataframe -phewas <- function(variants, pval = 0.00001, batch=c(), access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) +phewas <- function(variants, pval = 0.00001, batch=c(), opengwas_jwt=get_opengwas_jwt()) { out <- api_query("phewas", query=list( variant=variants, pval=pval, index_list=batch - ), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() + ), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(!inherits(out, "response")) { out <- out %>% dplyr::as_tibble() %>% fix_n() @@ -369,14 +357,12 @@ phewas <- function(variants, pval = 0.00001, batch=c(), access_token=check_acces #' If force_server = `TRUE` then will recompute using server side LD reference panel. #' @param pop Super-population to use as reference panel. Default = `"EUR"`. #' Options are `"EUR"`, `"SAS"`, `"EAS"`, `"AFR"`, `"AMR"` -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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. #' #' @export #' @return Dataframe tophits <- function(id, pval=5e-8, clump = 1, r2 = 0.001, kb = 10000, pop="EUR", - force_server = FALSE, access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) { + force_server = FALSE, opengwas_jwt=get_opengwas_jwt()) { id <- legacy_ids(id) if(clump == 1 & r2 == 0.001 & kb == 10000 & pval == 5e-8) { @@ -396,7 +382,7 @@ tophits <- function(id, pval=5e-8, clump = 1, r2 = 0.001, kb = 10000, pop="EUR", r2=r2, kb=kb, pop=pop - ), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() + ), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(inherits(out, "response")) { return(out) @@ -413,17 +399,15 @@ tophits <- function(id, pval=5e-8, clump = 1, r2 = 0.001, kb = 10000, pop="EUR", #' Check datasets that are in process of being uploaded #' #' @param id ID -#' @param access_token Google OAuth2 access token. -#' Used to authenticate level of access to data. By default, checks if already #' @param 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. #' #' @export #' @return Dataframe -editcheck <- function(id, access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) +editcheck <- function(id, opengwas_jwt=get_opengwas_jwt()) { api <- options()[["ieugwasr_api"]] select_api("private") - out <- api_query(paste0("edit/check/", id), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% + out <- api_query(paste0("edit/check/", id), opengwas_jwt=opengwas_jwt) %>% get_query_content() options(ieugwasr_api=api) return(out) diff --git a/R/variants.R b/R/variants.R index f3c41c2..9eaee18 100644 --- a/R/variants.R +++ b/R/variants.R @@ -5,16 +5,17 @@ #' @param gene Vector of genes, either Ensembl or Entrez, #' e.g. `c("ENSG00000123374", "ENSG00000160791")` or `1017` #' @param radius Radius around the gene region to include. Default = `0` +#' @param 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. #' #' @export #' @return data frame with the following columns -variants_gene <- function(gene, radius=0) +variants_gene <- function(gene, radius=0, opengwas_jwt=get_opengwas_jwt()) { l <- list() for(i in 1:length(gene)) { message("Looking up ", gene[i]) - o <- api_query(paste0('variants/gene/', gene[i], "?radius=", format(radius, scientific=FALSE))) %>% get_query_content() + o <- api_query(paste0('variants/gene/', gene[i], "?radius=", format(radius, scientific=FALSE)), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(! inherits(o, "response")) { l[[gene[i]]] <- o %>% dplyr::bind_rows() %>% format_variants() @@ -29,12 +30,13 @@ variants_gene <- function(gene, radius=0) #' #' #' @param rsid Vector of rsids +#' @param 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. #' #' @export #' @return data frame -variants_rsid <- function(rsid) +variants_rsid <- function(rsid, opengwas_jwt=get_opengwas_jwt()) { - o <- api_query("variants/rsid", list(rsid = rsid)) %>% get_query_content() + o <- api_query("variants/rsid", list(rsid = rsid), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(! inherits(o, "response")) { if(!is.data.frame(o) & is.list(o)) @@ -55,12 +57,13 @@ variants_rsid <- function(rsid) #' @param chrpos list of `:` in build 37, #' e.g. `c("3:46414943", "3:122991235")`. Also allows ranges e.g. `"7:105561135-105563135"` #' @param radius Radius around each chrpos, default = `0` +#' @param 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. #' #' @export #' @return Data frame -variants_chrpos <- function(chrpos, radius=0) +variants_chrpos <- function(chrpos, radius=0, opengwas_jwt=get_opengwas_jwt()) { - o <- api_query("variants/chrpos", list(chrpos = chrpos, radius=radius)) %>% get_query_content() + o <- api_query("variants/chrpos", list(chrpos = chrpos, radius=radius), opengwas_jwt=opengwas_jwt) %>% get_query_content() if(! inherits(o, "response")) { @@ -75,15 +78,16 @@ variants_chrpos <- function(chrpos, radius=0) #' Convert mixed array of rsid and chrpos to list of rsid #' #' @param variants Array of variants e.g. `c("rs234", "7:105561135-105563135")` +#' @param 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. #' #' @export #' @return list of rsids -variants_to_rsid <- function(variants) +variants_to_rsid <- function(variants, opengwas_jwt=get_opengwas_jwt()) { index <- grep(":", variants) if(length(index) > 0) { - o <- variants_chrpos(variants[index])$name + o <- variants_chrpos(variants[index], opengwas_jwt=opengwas_jwt)$name variants <- c(o, variants[-index]) %>% unique } return(variants) diff --git a/man/afl2_chrpos.Rd b/man/afl2_chrpos.Rd index 7f5532d..15bb7e7 100644 --- a/man/afl2_chrpos.Rd +++ b/man/afl2_chrpos.Rd @@ -4,13 +4,15 @@ \alias{afl2_chrpos} \title{Look up allele frequencies and LD scores for 1000 genomes populations by chrpos} \usage{ -afl2_chrpos(chrpos, reference = "1000g") +afl2_chrpos(chrpos, reference = "1000g", opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{chrpos}{list of \verb{:} in build 37, e.g. \code{c("3:46414943", "3:122991235")}. Also allows ranges e.g \code{"7:105561135-105563135"}} \item{reference}{Default=\code{"1000g"}} + +\item{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.} } \value{ Data frame containing ancestry specific LD scores and allele frequencies for each variant diff --git a/man/afl2_list.Rd b/man/afl2_list.Rd index 30ce140..b590f34 100644 --- a/man/afl2_list.Rd +++ b/man/afl2_list.Rd @@ -4,11 +4,16 @@ \alias{afl2_list} \title{Retrieve a allele frequency and LD scores for pre-defined lists of variants} \usage{ -afl2_list(variantlist = c("reduced", "hapmap3")[1]) +afl2_list( + variantlist = c("reduced", "hapmap3")[1], + opengwas_jwt = get_opengwas_jwt() +) } \arguments{ \item{variantlist}{Choose pre-defined list. reduced = ~20k SNPs that are common in all super populations (default). hapmap3 = ~1.3 million hm3 SNPs} + +\item{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.} } \value{ Data frame containing ancestry specific LD scores and allele frequencies for each variant diff --git a/man/afl2_rsid.Rd b/man/afl2_rsid.Rd index e64c267..f4cc7fe 100644 --- a/man/afl2_rsid.Rd +++ b/man/afl2_rsid.Rd @@ -4,12 +4,14 @@ \alias{afl2_rsid} \title{Look up allele frequencies and LD scores for 1000 genomes populations by rsid} \usage{ -afl2_rsid(rsid, reference = "1000g") +afl2_rsid(rsid, reference = "1000g", opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{rsid}{Vector of rsids} \item{reference}{Default=\code{"1000g"}} + +\item{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.} } \value{ Data frame containing ancestry specific LD scores and allele frequencies for each variant diff --git a/man/api_query.Rd b/man/api_query.Rd index f9cf9e9..4385eb1 100644 --- a/man/api_query.Rd +++ b/man/api_query.Rd @@ -7,7 +7,6 @@ api_query( path, query = NULL, - access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt(), method = "GET", silent = TRUE, @@ -20,9 +19,6 @@ api_query( \item{query}{If post query, provide a list of arguments as the payload. \code{NULL} by default} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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.} \item{method}{\code{"GET"} (default) or \code{"POST"}, \code{"DELETE"} etc} diff --git a/man/associations.Rd b/man/associations.Rd index 05d6a29..89d06ad 100644 --- a/man/associations.Rd +++ b/man/associations.Rd @@ -12,7 +12,6 @@ associations( align_alleles = 1, palindromes = 1, maf_threshold = 0.3, - access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt() ) } @@ -32,9 +31,6 @@ associations( \item{maf_threshold}{MAF threshold to try to infer palindromic SNPs. Default = \code{0.3}.} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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.} } \value{ diff --git a/man/batches.Rd b/man/batches.Rd index 598e07a..248fbc8 100644 --- a/man/batches.Rd +++ b/man/batches.Rd @@ -4,12 +4,9 @@ \alias{batches} \title{Get list of data batches in IEU GWAS database} \usage{ -batches(access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt()) +batches(opengwas_jwt = get_opengwas_jwt()) } \arguments{ -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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.} } \value{ diff --git a/man/check_access_token.Rd b/man/check_access_token.Rd index ce2ae85..cf21c89 100644 --- a/man/check_access_token.Rd +++ b/man/check_access_token.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/api.R \name{check_access_token} \alias{check_access_token} -\title{Check if authentication has been made} +\title{Check if authentication has been maded} \usage{ check_access_token() } @@ -10,6 +10,5 @@ check_access_token() NULL or access_token depending on current authentication state } \description{ -If a call to \code{\link[=get_access_token]{get_access_token()}} has been made then it will have generated \code{mrbase.oauth}. -Pass the token if it is present, if not, return \code{NULL} and do not authenticate. +Deprectated. Use \code{get_opengwas_jwt()} instead. See https://mrcieu.github.io/ieugwasr/articles/guide.html#authentication for more information. } diff --git a/man/editcheck.Rd b/man/editcheck.Rd index 5758b9a..fabdddc 100644 --- a/man/editcheck.Rd +++ b/man/editcheck.Rd @@ -4,18 +4,11 @@ \alias{editcheck} \title{Check datasets that are in process of being uploaded} \usage{ -editcheck( - id, - access_token = check_access_token(), - opengwas_jwt = get_opengwas_jwt() -) +editcheck(id, opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{id}{ID} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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.} } \value{ diff --git a/man/fill_n.Rd b/man/fill_n.Rd index 14f5fb3..6986d3e 100644 --- a/man/fill_n.Rd +++ b/man/fill_n.Rd @@ -1,23 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/afl2.r, R/query.R +% Please edit documentation in R/query.R \name{fill_n} \alias{fill_n} \title{Look up sample sizes when meta data is missing from associations} \usage{ -fill_n(d) - -fill_n(d) +fill_n(d, opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{d}{Output from \code{\link{associations}}} + +\item{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.} } \value{ -Data frame which is an updated version of the input but with sample sizes inferred where missing - Updated version of d } \description{ -Look up sample sizes when meta data is missing from associations - Look up sample sizes when meta data is missing from associations } diff --git a/man/get_access_token.Rd b/man/get_access_token.Rd deleted file mode 100644 index cde6f9e..0000000 --- a/man/get_access_token.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/api.R -\name{get_access_token} -\alias{get_access_token} -\title{Get access token for OAuth2 access to MR Base} -\usage{ -get_access_token() -} -\value{ -access token string -} -\description{ -Get access token for OAuth2 access to MR Base -} diff --git a/man/gwasinfo.Rd b/man/gwasinfo.Rd index f9b2a2d..4ba392f 100644 --- a/man/gwasinfo.Rd +++ b/man/gwasinfo.Rd @@ -4,19 +4,12 @@ \alias{gwasinfo} \title{Get list of studies with available GWAS summary statistics through API} \usage{ -gwasinfo( - id = NULL, - access_token = check_access_token(), - opengwas_jwt = get_opengwas_jwt() -) +gwasinfo(id = NULL, opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{id}{List of MR-Base IDs to retrieve. If \code{NULL} (default) retrieves all available datasets} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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.} } \value{ diff --git a/man/infer_ancestry.Rd b/man/infer_ancestry.Rd index 74a4194..6ef5afe 100644 --- a/man/infer_ancestry.Rd +++ b/man/infer_ancestry.Rd @@ -4,7 +4,7 @@ \alias{infer_ancestry} \title{Infer ancestry of GWAS dataset by matching against 1000 genomes allele frequencies} \usage{ -infer_ancestry(d, snpinfo = NULL) +infer_ancestry(d, snpinfo = NULL, opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{d}{Data frame containing at least \code{rsid} and \code{eaf} columns. @@ -12,6 +12,8 @@ e.g. output from associations} \item{snpinfo}{Output from \code{\link{afl2_list}}, \code{\link{afl2_rsid}} or \code{\link{afl2_chrpos}}. If \code{NULL} then \code{\link[=afl2_list]{afl2_list()}} is used by default} + +\item{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.} } \value{ 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 diff --git a/man/ld_clump.Rd b/man/ld_clump.Rd index bcb7ab0..ff12dd8 100644 --- a/man/ld_clump.Rd +++ b/man/ld_clump.Rd @@ -10,7 +10,6 @@ ld_clump( clump_r2 = 0.001, clump_p = 0.99, pop = "EUR", - access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt(), bfile = NULL, plink_bin = NULL @@ -31,9 +30,6 @@ Options are \code{"EUR"}, \code{"SAS"}, \code{"EAS"}, \code{"AFR"}, \code{"AMR"} \code{'legacy'} also available - which is a previously used verison of the EUR panel with a slightly different set of markers} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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.#'} \item{bfile}{If this is provided then will use the API. Default = \code{NULL}} diff --git a/man/ld_clump_api.Rd b/man/ld_clump_api.Rd index b1068c0..974375a 100644 --- a/man/ld_clump_api.Rd +++ b/man/ld_clump_api.Rd @@ -10,7 +10,6 @@ ld_clump_api( clump_r2 = 0.1, clump_p, pop = "EUR", - access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt() ) } @@ -27,9 +26,6 @@ If \code{id} is present then clumping will be done per unique id.} \item{pop}{Super-population to use as reference panel. Default = \code{"EUR"}. Options are \code{"EUR"}, \code{"SAS"}, \code{"EAS"}, \code{"AFR"}, \code{"AMR"}} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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 = \code{NULL}} } \value{ diff --git a/man/ld_matrix.Rd b/man/ld_matrix.Rd index 12a391c..954a48c 100644 --- a/man/ld_matrix.Rd +++ b/man/ld_matrix.Rd @@ -8,7 +8,6 @@ ld_matrix( variants, with_alleles = TRUE, pop = "EUR", - access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt(), bfile = NULL, plink_bin = NULL @@ -24,9 +23,6 @@ Options are \code{"EUR"}, \code{"SAS"}, \code{"EAS"}, \code{"AFR"}, \code{"AMR"} \code{'legacy'} also available - which is a previously used verison of the EUR panel with a slightly different set of markers} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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 = \code{NULL}} \item{bfile}{If this is provided then will use the API. Default = \code{NULL}} diff --git a/man/ld_reflookup.Rd b/man/ld_reflookup.Rd index d55ff1c..255b1a9 100644 --- a/man/ld_reflookup.Rd +++ b/man/ld_reflookup.Rd @@ -4,12 +4,7 @@ \alias{ld_reflookup} \title{Check which rsids are present in a remote LD reference panel} \usage{ -ld_reflookup( - rsid, - pop = "EUR", - access_token = check_access_token(), - opengwas_jwt = get_opengwas_jwt() -) +ld_reflookup(rsid, pop = "EUR", opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{rsid}{Array of rsids to check} @@ -17,9 +12,6 @@ ld_reflookup( \item{pop}{Super-population to use as reference panel. Default = \code{"EUR"}. Options are \code{"EUR"}, \code{"SAS"}, \code{"EAS"}, \code{"AFR"}, \code{"AMR"}} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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 = \code{NULL}} } \value{ diff --git a/man/phewas.Rd b/man/phewas.Rd index 9e8aab5..80b02fe 100644 --- a/man/phewas.Rd +++ b/man/phewas.Rd @@ -4,13 +4,7 @@ \alias{phewas} \title{Perform fast phewas of a specific variants against all available GWAS datasets} \usage{ -phewas( - variants, - pval = 1e-05, - batch = c(), - access_token = check_access_token(), - opengwas_jwt = get_opengwas_jwt() -) +phewas(variants, pval = 1e-05, batch = c(), opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{variants}{Array of variants e.g. \code{c("rs234", "7:105561135-105563135")}} @@ -19,9 +13,6 @@ phewas( \item{batch}{Vector of batch IDs to search across. If \code{c()} (default) then returns all batches} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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.} } \value{ diff --git a/man/revoke_access_token.Rd b/man/revoke_access_token.Rd deleted file mode 100644 index 941a122..0000000 --- a/man/revoke_access_token.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/api.R -\name{revoke_access_token} -\alias{revoke_access_token} -\title{Revoke access token for MR Base} -\usage{ -revoke_access_token() -} -\value{ -No return value, called for side effects -} -\description{ -Revoke access token for MR Base -} diff --git a/man/tophits.Rd b/man/tophits.Rd index 3762ab0..6f794b4 100644 --- a/man/tophits.Rd +++ b/man/tophits.Rd @@ -12,7 +12,6 @@ tophits( kb = 10000, pop = "EUR", force_server = FALSE, - access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt() ) } @@ -35,9 +34,6 @@ 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 = \code{TRUE} then will recompute using server side LD reference panel.} -\item{access_token}{Google OAuth2 access token. -Used to authenticate level of access to data. By default, checks if already} - \item{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.} } \value{ diff --git a/man/variants_chrpos.Rd b/man/variants_chrpos.Rd index 72bf121..8d74bd4 100644 --- a/man/variants_chrpos.Rd +++ b/man/variants_chrpos.Rd @@ -4,13 +4,15 @@ \alias{variants_chrpos} \title{Obtain information about chr pos and surrounding region} \usage{ -variants_chrpos(chrpos, radius = 0) +variants_chrpos(chrpos, radius = 0, opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{chrpos}{list of \verb{:} in build 37, e.g. \code{c("3:46414943", "3:122991235")}. Also allows ranges e.g. \code{"7:105561135-105563135"}} \item{radius}{Radius around each chrpos, default = \code{0}} + +\item{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.} } \value{ Data frame diff --git a/man/variants_gene.Rd b/man/variants_gene.Rd index b85f782..9fcd7ca 100644 --- a/man/variants_gene.Rd +++ b/man/variants_gene.Rd @@ -4,13 +4,15 @@ \alias{variants_gene} \title{Obtain variants around a gene} \usage{ -variants_gene(gene, radius = 0) +variants_gene(gene, radius = 0, opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{gene}{Vector of genes, either Ensembl or Entrez, e.g. \code{c("ENSG00000123374", "ENSG00000160791")} or \code{1017}} \item{radius}{Radius around the gene region to include. Default = \code{0}} + +\item{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.} } \value{ data frame with the following columns diff --git a/man/variants_rsid.Rd b/man/variants_rsid.Rd index f01bf75..9a50949 100644 --- a/man/variants_rsid.Rd +++ b/man/variants_rsid.Rd @@ -4,10 +4,12 @@ \alias{variants_rsid} \title{Obtain information about rsid} \usage{ -variants_rsid(rsid) +variants_rsid(rsid, opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{rsid}{Vector of rsids} + +\item{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.} } \value{ data frame diff --git a/man/variants_to_rsid.Rd b/man/variants_to_rsid.Rd index 7d838b0..645d1d9 100644 --- a/man/variants_to_rsid.Rd +++ b/man/variants_to_rsid.Rd @@ -4,10 +4,12 @@ \alias{variants_to_rsid} \title{Convert mixed array of rsid and chrpos to list of rsid} \usage{ -variants_to_rsid(variants) +variants_to_rsid(variants, opengwas_jwt = get_opengwas_jwt()) } \arguments{ \item{variants}{Array of variants e.g. \code{c("rs234", "7:105561135-105563135")}} + +\item{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.} } \value{ list of rsids diff --git a/vignettes/guide.Rmd b/vignettes/guide.Rmd index 13aae7d..2120e50 100644 --- a/vignettes/guide.Rmd +++ b/vignettes/guide.Rmd @@ -20,10 +20,11 @@ knitr::opts_chunk$set( The [OpenGWAS database](https://gwas.mrcieu.ac.uk/) comprises over 50,000 curated, QC'd and harmonised complete GWAS summary datasets and can be queried using an API. See [here](https://api.opengwas.io/api/) for documentation on the API itself. This R package is a wrapper to make generic calls to the API, plus convenience functions for specific queries. - ## Authentication -User authentication is required to perform most OpenGWAS queries. To authenticate, you need to generate a token from the OpenGWAS website. The token behaves like a password, and it will be used to authorise the requests you make to the OpenGWAS API. Here are the steps to generate the token and then have `ieugwasr` automatically use it for your queries: +From 1st May 2024, most queries to the OpenGWAS API will require user authentication. For more information on why this is necessary, see this [blog post](https://blog.opengwas.io/posts/user-auth-spring-2024/). + +To authenticate, you need to generate a token from the OpenGWAS website. The token behaves like a password, and it will be used to authorise the requests you make to the OpenGWAS API. Here are the steps to generate the token and then have `ieugwasr` automatically use it for your queries: 1. Login to https://api.opengwas.io/profile 2. Generate a new token