Skip to content

Commit

Permalink
rm gwasglue2 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ritarasteiro committed Mar 15, 2024
1 parent 8762a25 commit 8d85723
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 144 deletions.
5 changes: 1 addition & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Authors@R: c(
person("Rita", "Rasteiro", , "rita.rasteiro@bristol.ac.uk", role = "aut",
comment = c(ORCID = "0000-0002-4217-3060"))
)
Description: R interface to the 'OpenGWAS' database API. Includes a wrapper
Description: Interface to the 'OpenGWAS' database API. Includes a wrapper
to make generic calls to the API, plus convenience functions for
specific queries.
License: MIT + file LICENSE
Expand All @@ -20,7 +20,6 @@ BugReports: https://github.com/MRCIEU/ieugwasr/issues
Depends:
R (>= 4.0)
Imports:
digest,
dplyr,
googleAuthR,
gwasglue2,
Expand All @@ -38,8 +37,6 @@ Suggests:
testthat
VignetteBuilder:
knitr
Remotes:
mrcieu/gwasglue2
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
87 changes: 0 additions & 87 deletions R/ld_scores.R

This file was deleted.

60 changes: 7 additions & 53 deletions R/query.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,42 +240,19 @@ batches <- function(access_token = check_access_token())
#' Used to authenticate level of access to data.
#' By default, checks if already authenticated through [`get_access_token`] and
#' if not then does not perform authentication
#' @param gwasglue Returns a gwasglue2 SummarySet object (if `gwasglue = TRUE`). Only one GWAS id can be queried at a time. See [gwasglue2::create_dataset()].Default = `FALSE`.
#'
#' @export
#' @return Dataframe. If `gwasglue = TRUE` then returns a gwasglue2 object.
associations <- function(variants, id, proxies=1, r2=0.8, align_alleles=1, palindromes=1, maf_threshold = 0.3, access_token=check_access_token(), gwasglue=FALSE){
associations <- function(variants, id, proxies=1, r2=0.8, align_alleles=1, palindromes=1, maf_threshold = 0.3, access_token=check_access_token()){

# Query specific variants from specific GWAS using associations_query internal function (old version)
out <- associations_query(variants=variants, id=id, proxies=proxies, r2=r2, align_alleles=align_alleles, palindromes=palindromes, maf_threshold=maf_threshold, access_token=access_token)

if(gwasglue)
{
# check if it is a tibble (trying to avoid loading the tibble package)
if(inherits(out ,"tbl_df")){
# output gwasglue2 SummarySet object
if(id %>% length() != 1){
stop("Only one GWAS ID can be queried at a time when using `gwasglue = TRUE`.")
} else {
# create gwasglue2 metadata
m <- gwasglue2::create_metadata(gwasinfo(id))
# create gwasglue2 SummarySet object
s <- out %>%
gwasglue2::create_summaryset(metadata=m, qc = TRUE) %>%
return()
}

} else {
return(out)
}
}
else{
return(out)
}

return(out)
}


# Query specific variants from specific GWAS - associations internal function to allow for gwasglue
# Query specific variants from specific GWAS - associations internal function to allow for future gwasglue2 integration
associations_query <- function(variants=variants, id=id, proxies=proxies, r2=r2, align_alleles=align_alleles, palindromes=palindromes, maf_threshold = maf_threshold, access_token=access_token)
{
id <- legacy_ids(id)
Expand Down Expand Up @@ -396,42 +373,19 @@ phewas <- function(variants, pval = 0.00001, batch=c(), access_token=check_acces
#' Used to authenticate level of access to data.
#' By default, checks if already authenticated through [`get_access_token`]
#' and if not then does not perform authentication.
#' @param gwasglue Returns a gwasglue2 SummarySet object (if `gwasglue = TRUE`). Only one GWAS id can be queried at a time. See [gwasglue2::create_dataset()].Default = `FALSE`.
#' @export
#' @return Dataframe. If `gwasglue = TRUE` then returns a gwasglue2 object.
tophits <- function(id, pval = 5e-8, clump = 1, r2 = 0.001, kb = 10000, pop="EUR", force_server = FALSE, access_token = check_access_token(), gwasglue = FALSE)
tophits <- function(id, pval = 5e-8, clump = 1, r2 = 0.001, kb = 10000, pop="EUR", force_server = FALSE, access_token = check_access_token())
{
# Query tophits from specific GWAS using tophits_query internal function (old version)
out <- tophits_query(id = id, pval = pval, clump = clump, r2 = r2, kb = kb, pop = pop, force_server = force_server, access_token = access_token)

if(isTRUE(gwasglue))
{
# check if it is a tibble (trying to avoid loading the tibble package)
if(inherits(out, "tbl_df")){
# output gwasglue2 SummarySet object
if(id %>% length() != 1){
stop("Only one GWAS ID can be queried at a time when using `gwasglue = TRUE`.")
} else {
# create gwasglue2 metadata
m <- gwasglue2::create_metadata(gwasinfo(id))
# create gwasglue2 SummarySet object
s <- out %>%
gwasglue2::create_summaryset(metadata=m, qc = TRUE) %>%
return()
}

} else {
return(out)
}
}
else{
return(out)
}
return(out)
}



# query top hits from GWAS dataset - tophits internal function to allow for gwasglue
# query top hits from GWAS dataset - tophits internal function to allow for future gwasglue2 integration
tophits_query <- function(id, pval=5e-8, clump = 1, r2 = 0.001, kb = 10000, pop="EUR",
force_server = FALSE, access_token=check_access_token())
{
Expand Down

0 comments on commit 8d85723

Please sign in to comment.