Skip to content

Commit

Permalink
Update IEU GWAS API
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Murphy committed Dec 17, 2024
1 parent 12077de commit 5937277
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 573 deletions.
11 changes: 4 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: MungeSumstats
Type: Package
Title: Standardise summary statistics from GWAS
Version: 1.15.2
Version: 1.15.3
Authors@R:
c(person(given = "Alan",
family = "Murphy",
Expand All @@ -28,23 +28,20 @@ URL: https://github.com/neurogenomics/MungeSumstats
BugReports: https://github.com/neurogenomics/MungeSumstats/issues
License: Artistic-2.0
Depends: R(>= 4.1)
Imports:
magrittr,
Imports:
data.table,
utils,
R.utils,
dplyr,
stats,
GenomicRanges,
IRanges,
GenomeInfoDb,
IRanges,
ieugwasr(>= 1.0.1),
BSgenome,
Biostrings,
stringr,
VariantAnnotation,
googleAuthR,
httr,
jsonlite,
methods,
parallel,
rtracklayer(>= 1.59.1),
Expand Down
12 changes: 1 addition & 11 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,7 @@ importFrom(dplyr,arrange)
importFrom(dplyr,desc)
importFrom(dplyr,mutate)
importFrom(dplyr,rowwise)
importFrom(dplyr,tibble)
importFrom(googleAuthR,gar_auth)
importFrom(httr,DELETE)
importFrom(httr,GET)
importFrom(httr,POST)
importFrom(httr,add_headers)
importFrom(httr,content)
importFrom(httr,status_code)
importFrom(httr,timeout)
importFrom(jsonlite,fromJSON)
importFrom(magrittr,"%>%")
importFrom(ieugwasr,gwasinfo)
importFrom(methods,is)
importFrom(methods,show)
importFrom(methods,slotNames)
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## CHANGES IN VERSION 1.15.3

### Bug fix
*Updated retrieval of IEU OpenGWAS to new approach requiring login. Also updated
to use the [IEU OpwnGWAS R package](https://github.com/MRCIEU/ieugwasr) as a
dependency.

## CHANGES IN VERSION 1.15.2

### New features
*[FAQ Website](https://github.com/Al-Murphy/MungeSumstats/wiki/FAQ) updated.

## CHANGES IN VERSION 1.15.1

### New features
Expand Down
22 changes: 10 additions & 12 deletions R/find_sumstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,22 @@
#' (e.g. \code{200000}).
#' @param include_NAs Include datasets with missing metadata for size criteria
#' (i.e. \code{min_sample_size}, \code{min_ncase}, or \code{min_ncontrol}).
#' @inheritParams check_access_token
#' @inheritParams gwasinfo
#' @inheritParams format_sumstats
#'
#' @export
#' @importFrom dplyr %>% arrange desc mutate rowwise
#' @importFrom data.table setorderv
#' @importFrom ieugwasr gwasinfo
#' @examples
#' # Only run the examples if user has internet access:
#' if(try(is.character(getURL("www.google.com")))==TRUE){
#' # Only run the examples if user has internet access
#' # and if access token has been added
#' if(try(is.character(getURL("www.google.com")))==TRUE && ieugwasr::get_opengwas_jwt()!=""){
#' ### By ID
#' metagwas <- find_sumstats(ids = c(
#' "ieu-b-4760",
#' "prot-a-1725",
#' "prot-a-664"
#' ))
#' ### By ID amd sample size
#' ### By ID and sample size
#' metagwas <- find_sumstats(
#' ids = c("ieu-b-4760", "prot-a-1725", "prot-a-664"),
#' min_sample_size = 5000
Expand All @@ -80,17 +79,16 @@ find_sumstats <- function(ids = NULL,
min_ncase = NULL,
min_ncontrol = NULL,
min_nsnp = NULL,
include_NAs = FALSE,
access_token = check_access_token()) {
include_NAs = FALSE
) {

## Set up fake empty variables to avoid confusing BiocCheck
sample_size <- ncase <- ncontrol <- nsnp <- N <- NULL;

message("Collecting metadata from Open GWAS.")
if (!is.null(ids)) {
metagwas <- gwasinfo(
id = ids,
access_token = access_token
metagwas <- ieugwasr::gwasinfo(
id = ids
)
## gwasinfo() doesn't always return all columns for some reason
missing_cols <- c("ncase", "ncontrol")
Expand All @@ -101,7 +99,7 @@ find_sumstats <- function(ids = NULL,
}
}
} else {
metagwas <- gwasinfo()
metagwas <- ieugwasr::gwasinfo()
}
message("Filtering metadata by substring criteria.")
if (!is.null(traits)) {
Expand Down
Loading

0 comments on commit 5937277

Please sign in to comment.