From 09ac616b71d6dcc9d14f16f285264df5a1d24888 Mon Sep 17 00:00:00 2001 From: Gibran Hemani Date: Mon, 8 Apr 2024 19:30:22 +0100 Subject: [PATCH] reinstating google oauth temporarily --- DESCRIPTION | 3 ++- NAMESPACE | 3 +++ R/api.R | 56 +++++++++++++++++++++++++++++++++++++++++++++ R/ld_clump.R | 18 ++++++++++----- R/ld_matrix.R | 6 +++-- R/query.R | 44 +++++++++++++++++++++++------------ man/api_query.Rd | 4 ++++ man/associations.Rd | 4 ++++ man/batches.Rd | 5 +++- man/editcheck.Rd | 9 +++++++- man/gwasinfo.Rd | 9 +++++++- 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/tophits.Rd | 4 ++++ 17 files changed, 169 insertions(+), 29 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 87fa40c..42d3b83 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ieugwasr Title: Interface to the 'OpenGWAS' Database API -Version: 0.2.2-9000 +Version: 0.2.2-9001 Authors@R: c( person("Gibran", "Hemani", , "g.hemani@bristol.ac.uk", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-0920-1055")), @@ -25,6 +25,7 @@ Imports: jsonlite, magrittr, rlang, + googleAuthR, stats Suggests: knitr, diff --git a/NAMESPACE b/NAMESPACE index 94db6f3..bab475c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,8 +11,10 @@ export(api_status) export(associations) export(batch_from_id) 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) @@ -25,6 +27,7 @@ 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/R/api.R b/R/api.R index cdffa3a..2aee11a 100644 --- a/R/api.R +++ b/R/api.R @@ -62,3 +62,59 @@ logging_info <- function() "c) to monitor inappropriate or unfair usage.\n", "We do NOT log the queries that are being performed, and we do NOT share your email address with anybody else.") } + + +#' Get access token for OAuth2 access to MR Base +#' +#' +#' @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. +#' +#' @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) + } +} + + +#' 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 ef6ac83..128755e 100644 --- a/R/ld_clump.R +++ b/R/ld_clump.R @@ -27,6 +27,8 @@ #' 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 @@ -36,7 +38,7 @@ #' @export #' @return Data frame ld_clump <- function(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) + pop = "EUR", access_token=check_access_token(),opengwas_jwt=get_opengwas_jwt(), bfile=NULL, plink_bin=NULL) { stopifnot("rsid" %in% names(dat)) @@ -77,7 +79,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, opengwas_jwt=opengwas_jwt) + 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) } 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) } @@ -97,9 +99,11 @@ 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", opengwas_jwt=get_opengwas_jwt()) +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()) { res <- api_query('ld/clump', query = list( @@ -110,7 +114,7 @@ ld_clump_api <- function(dat, clump_kb=10000, clump_r2=0.1, clump_p, pop="EUR", kb = clump_kb, pop = pop ), - opengwas_jwt=opengwas_jwt + access_token=access_token, opengwas_jwt=opengwas_jwt ) %>% get_query_content() y <- subset(dat, !dat[["rsid"]] %in% res) if(nrow(y) > 0) @@ -186,18 +190,20 @@ 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', opengwas_jwt=get_opengwas_jwt()) +ld_reflookup <- function(rsid, pop='EUR', access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) { res <- api_query('ld/reflookup', query = list( rsid = rsid, pop = pop ), - opengwas_jwt=opengwas_jwt + access_token=access_token, opengwas_jwt=opengwas_jwt ) %>% get_query_content() if(length(res) == 0) { diff --git a/R/ld_matrix.R b/R/ld_matrix.R index e8625b1..7a69a46 100644 --- a/R/ld_matrix.R +++ b/R/ld_matrix.R @@ -26,6 +26,8 @@ #' 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 @@ -33,7 +35,7 @@ #' #' @export #' @return Matrix of LD r values -ld_matrix <- function(variants, with_alleles=TRUE, pop="EUR", opengwas_jwt=get_opengwas_jwt(), bfile=NULL, plink_bin=NULL) { +ld_matrix <- function(variants, with_alleles=TRUE, pop="EUR", access_token=check_access_token(), 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.") @@ -50,7 +52,7 @@ ld_matrix <- function(variants, with_alleles=TRUE, pop="EUR", opengwas_jwt=get_o 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), opengwas_jwt=opengwas_jwt) %>% get_query_content() + res <- api_query('ld/matrix', query = list(rsid=variants, pop=pop), access_token=access_token, 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 d6d9d6f..6b08d2c 100644 --- a/R/query.R +++ b/R/query.R @@ -5,6 +5,8 @@ #' #' @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 @@ -14,13 +16,14 @@ #' #' @export #' @return httr response object -api_query <- function(path, query=NULL, opengwas_jwt=get_opengwas_jwt(), +api_query <- function(path, query=NULL, access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt(), method="GET", silent=TRUE, encode="json", timeout=300) { ntry <- 0 ntries <- 5 headers <- httr::add_headers( # 'Content-Type'='application/json; charset=UTF-8', + 'X-Api-Token'=access_token, 'Authorization'=paste("Bearer", opengwas_jwt=opengwas_jwt), '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") @@ -157,19 +160,21 @@ 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, opengwas_jwt=get_opengwas_jwt()) +gwasinfo <- function(id=NULL, access_token=check_access_token(), 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), opengwas_jwt=opengwas_jwt) %>% get_query_content() + out <- api_query('gwasinfo', query = list(id=id), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() } else { - out <- api_query('gwasinfo', opengwas_jwt=opengwas_jwt) %>% get_query_content() + out <- api_query('gwasinfo', access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() } if(length(out) == 0) { @@ -204,14 +209,15 @@ 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(opengwas_jwt=get_opengwas_jwt()) +batches <- function(access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) { - api_query('batches', opengwas_jwt=opengwas_jwt) %>% get_query_content() + api_query('batches', access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() } #' Query specific variants from specific GWAS @@ -232,11 +238,13 @@ batches <- function(opengwas_jwt=get_opengwas_jwt()) #' `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, opengwas_jwt=get_opengwas_jwt()) { +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()) { id <- legacy_ids(id) out <- api_query("associations", query=list( variant=variants, @@ -246,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 - ), opengwas_jwt=opengwas_jwt) %>% get_query_content() + ), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() if(inherits(out, "response")) { @@ -307,17 +315,19 @@ 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(), opengwas_jwt=get_opengwas_jwt()) +phewas <- function(variants, pval = 0.00001, batch=c(), access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) { out <- api_query("phewas", query=list( variant=variants, pval=pval, index_list=batch - ), opengwas_jwt=opengwas_jwt) %>% get_query_content() + ), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() if(!inherits(out, "response")) { out <- out %>% dplyr::as_tibble() %>% fix_n() @@ -349,12 +359,14 @@ phewas <- function(variants, pval = 0.00001, batch=c(), opengwas_jwt=get_opengwa #' 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, opengwas_jwt=get_opengwas_jwt()) { + force_server = FALSE, access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) { id <- legacy_ids(id) if(clump == 1 & r2 == 0.001 & kb == 10000 & pval == 5e-8) { @@ -374,7 +386,7 @@ tophits <- function(id, pval=5e-8, clump = 1, r2 = 0.001, kb = 10000, pop="EUR", r2=r2, kb=kb, pop=pop - ), opengwas_jwt=opengwas_jwt) %>% get_query_content() + ), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() if(inherits(out, "response")) { return(out) @@ -391,15 +403,17 @@ 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, opengwas_jwt=get_opengwas_jwt()) +editcheck <- function(id, access_token=check_access_token(), opengwas_jwt=get_opengwas_jwt()) { api <- options()[["ieugwasr_api"]] select_api("private") - out <- api_query(paste0("edit/check/", id), opengwas_jwt=opengwas_jwt) %>% + out <- api_query(paste0("edit/check/", id), access_token=access_token, opengwas_jwt=opengwas_jwt) %>% get_query_content() options(ieugwasr_api=api) return(out) diff --git a/man/api_query.Rd b/man/api_query.Rd index 4385eb1..f9cf9e9 100644 --- a/man/api_query.Rd +++ b/man/api_query.Rd @@ -7,6 +7,7 @@ api_query( path, query = NULL, + access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt(), method = "GET", silent = TRUE, @@ -19,6 +20,9 @@ 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 89d06ad..05d6a29 100644 --- a/man/associations.Rd +++ b/man/associations.Rd @@ -12,6 +12,7 @@ associations( align_alleles = 1, palindromes = 1, maf_threshold = 0.3, + access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt() ) } @@ -31,6 +32,9 @@ 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 248fbc8..598e07a 100644 --- a/man/batches.Rd +++ b/man/batches.Rd @@ -4,9 +4,12 @@ \alias{batches} \title{Get list of data batches in IEU GWAS database} \usage{ -batches(opengwas_jwt = get_opengwas_jwt()) +batches(access_token = check_access_token(), 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/editcheck.Rd b/man/editcheck.Rd index fabdddc..5758b9a 100644 --- a/man/editcheck.Rd +++ b/man/editcheck.Rd @@ -4,11 +4,18 @@ \alias{editcheck} \title{Check datasets that are in process of being uploaded} \usage{ -editcheck(id, opengwas_jwt = get_opengwas_jwt()) +editcheck( + id, + access_token = check_access_token(), + 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/gwasinfo.Rd b/man/gwasinfo.Rd index 4ba392f..f9b2a2d 100644 --- a/man/gwasinfo.Rd +++ b/man/gwasinfo.Rd @@ -4,12 +4,19 @@ \alias{gwasinfo} \title{Get list of studies with available GWAS summary statistics through API} \usage{ -gwasinfo(id = NULL, opengwas_jwt = get_opengwas_jwt()) +gwasinfo( + id = NULL, + access_token = check_access_token(), + 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/ld_clump.Rd b/man/ld_clump.Rd index ff12dd8..bcb7ab0 100644 --- a/man/ld_clump.Rd +++ b/man/ld_clump.Rd @@ -10,6 +10,7 @@ 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 @@ -30,6 +31,9 @@ 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 974375a..b1068c0 100644 --- a/man/ld_clump_api.Rd +++ b/man/ld_clump_api.Rd @@ -10,6 +10,7 @@ ld_clump_api( clump_r2 = 0.1, clump_p, pop = "EUR", + access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt() ) } @@ -26,6 +27,9 @@ 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 954a48c..12a391c 100644 --- a/man/ld_matrix.Rd +++ b/man/ld_matrix.Rd @@ -8,6 +8,7 @@ ld_matrix( variants, with_alleles = TRUE, pop = "EUR", + access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt(), bfile = NULL, plink_bin = NULL @@ -23,6 +24,9 @@ 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 255b1a9..d55ff1c 100644 --- a/man/ld_reflookup.Rd +++ b/man/ld_reflookup.Rd @@ -4,7 +4,12 @@ \alias{ld_reflookup} \title{Check which rsids are present in a remote LD reference panel} \usage{ -ld_reflookup(rsid, pop = "EUR", opengwas_jwt = get_opengwas_jwt()) +ld_reflookup( + rsid, + pop = "EUR", + access_token = check_access_token(), + opengwas_jwt = get_opengwas_jwt() +) } \arguments{ \item{rsid}{Array of rsids to check} @@ -12,6 +17,9 @@ ld_reflookup(rsid, pop = "EUR", opengwas_jwt = get_opengwas_jwt()) \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 80b02fe..9e8aab5 100644 --- a/man/phewas.Rd +++ b/man/phewas.Rd @@ -4,7 +4,13 @@ \alias{phewas} \title{Perform fast phewas of a specific variants against all available GWAS datasets} \usage{ -phewas(variants, pval = 1e-05, batch = c(), opengwas_jwt = get_opengwas_jwt()) +phewas( + variants, + pval = 1e-05, + batch = c(), + access_token = check_access_token(), + opengwas_jwt = get_opengwas_jwt() +) } \arguments{ \item{variants}{Array of variants e.g. \code{c("rs234", "7:105561135-105563135")}} @@ -13,6 +19,9 @@ phewas(variants, pval = 1e-05, batch = c(), opengwas_jwt = get_opengwas_jwt()) \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/tophits.Rd b/man/tophits.Rd index 6f794b4..3762ab0 100644 --- a/man/tophits.Rd +++ b/man/tophits.Rd @@ -12,6 +12,7 @@ tophits( kb = 10000, pop = "EUR", force_server = FALSE, + access_token = check_access_token(), opengwas_jwt = get_opengwas_jwt() ) } @@ -34,6 +35,9 @@ 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{