Skip to content

Commit

Permalink
Changes to fix warnings/ notes to satisfy CRAN checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ainefairbrother committed May 17, 2023
1 parent 3e878f4 commit e64bc67
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ ensemblQueryR.Rproj
/R/legacyCode.R
.rprof.log
rprof.log
CRAN-SUBMISSION
4 changes: 2 additions & 2 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 0.1.0
Date: 2023-05-17 11:53:59 UTC
SHA: 450efffe2986841750eb647321d214b58eaa0097
Date: 2023-05-17 12:47:17 UTC
SHA: 3e878f448b3431965ebf07207a4d2eb828af1c3f
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Title: Simple, Fast and Efficient Querying of the Ensembl API
Version: 0.1.0
Author: Aine Fairbrother-Browne
Maintainer: The package maintainer <[email protected]>
Description: Simple, Fast and Efficient Querying of the Ensembl API
Description: Simple, Fast and Efficient Querying of the Ensembl API.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand All @@ -14,7 +14,9 @@ Imports:
httr,
jsonlite,
magrittr,
parallel,
purrr,
tibble,
tidyr,
vroom,
xml2
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ export(ensemblQueryLDwithSNPwindowDataframe)
export(pingEnsembl)
import(dplyr)
import(httr)
import(jsonlite)
import(parallel)
import(purrr)
import(tidyr)
import(vroom)
import(xml2)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)
importFrom(magrittr,"%>%")
10 changes: 6 additions & 4 deletions R/ensemblQueryLDpairEndpoint.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @import httr
#' @import xml2
#' @import jsonlite
#' @importFrom jsonlite fromJSON toJSON
#' @import dplyr
#' @import tidyr
#' @import vroom
Expand Down Expand Up @@ -55,7 +55,7 @@ ensemblQueryLDwithSNPpair = function(rsid1, rsid2, pop="1000GENOMES:phase_3:EUR"
server <- "https://rest.ensembl.org"
ext <- paste0("/ld/human/pairwise/",rsid1,"/",rsid2,"?population_name=",pop)

r <- httr::GET(url=paste(server, ext, sep = ""), content_type("application/json"))
r <- httr::GET(url=paste(server, ext, sep = ""), httr::content_type("application/json"))

# stop_for_status(r)

Expand Down Expand Up @@ -125,8 +125,10 @@ ensemblQueryLDwithSNPpair = function(rsid1, rsid2, pop="1000GENOMES:phase_3:EUR"
#'
#' @examples
#'ensemblQueryLDwithSNPpairDataframe(
#' in.table=data.frame(rsid1=rep("rs6792369", 10), rsid2=rep("rs1042779", 10)),
#' pop="1000GENOMES:phase_3:EUR")
#' in.table=data.frame(rsid1=rep("rs6792369", 10),
#' rsid2=rep("rs1042779", 10)),
#' pop="1000GENOMES:phase_3:EUR"
#')
#'
ensemblQueryLDwithSNPpairDataframe = function(in.table, pop="1000GENOMES:phase_3:EUR", cores=1){ #keep.original.table.row.n=FALSE

Expand Down
4 changes: 2 additions & 2 deletions R/ensemblQueryLDregionEndpoint.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @import httr
#' @import xml2
#' @import jsonlite
#' @importFrom jsonlite fromJSON toJSON
#' @import dplyr
#' @import tidyr
#' @import vroom
Expand Down Expand Up @@ -57,7 +57,7 @@ ensemblQueryLDwithSNPregion = function(chr, start, end, pop="1000GENOMES:phase_3
server <- "https://rest.ensembl.org"
ext <- paste0("/ld/human/region/",chr,":",start,"..",end,"/",pop,"?")

r <- httr::GET(url=paste(server, ext, sep = ""), content_type("application/json"))
r <- httr::GET(url=paste(server, ext, sep = ""), httr::content_type("application/json"))

# stop_for_status(r)

Expand Down
11 changes: 7 additions & 4 deletions R/ensemblQueryLDwindowEndpoint.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' @import httr
#' @import xml2
#' @import jsonlite
#' @importFrom jsonlite fromJSON toJSON
#' @import dplyr
#' @import tidyr
#' @import vroom
Expand All @@ -20,7 +20,8 @@
#' @export
#'
#' @examples
#' ensemblQueryLDwithSNPwindow(rsid="rs3851179", r2=0.8, d.prime=0.8, window.size=500, pop="1000GENOMES:phase_3:EUR")
#' ensemblQueryLDwithSNPwindow(rsid="rs3851179", r2=0.8, d.prime=0.8,
#' window.size=500, pop="1000GENOMES:phase_3:EUR")
#'
ensemblQueryLDwithSNPwindow = function(rsid, r2=0.8, d.prime=0.8, window.size=500, pop="1000GENOMES:phase_3:EUR"){

Expand Down Expand Up @@ -56,7 +57,7 @@ ensemblQueryLDwithSNPwindow = function(rsid, r2=0.8, d.prime=0.8, window.size=50
server <- "https://rest.ensembl.org"
ext <- paste0("/ld/human/",rsid,"/",pop,"?d_prime=",d.prime,";window_size=",window.size,";r2=",r2)

r <- httr::GET(url=paste(server, ext, sep = ""), content_type("application/json"))
r <- httr::GET(url=paste(server, ext, sep = ""), httr::content_type("application/json"))

#-------------------- check output and write out ---------------------------

Expand Down Expand Up @@ -130,7 +131,9 @@ ensemblQueryLDwithSNPwindow = function(rsid, r2=0.8, d.prime=0.8, window.size=50
#' @export
#'
#' @examples
#' in.table = data.frame(rsid = rep(c("rs7153434","rs1963154","rs12672022","rs3852802","rs12324408","rs56346870"), 10))
#' in.table = data.frame(rsid = rep(c("rs7153434","rs1963154","rs12672022",
#' "rs3852802","rs12324408","rs56346870"), 10))
#'
#' ensemblQueryLDwithSNPwindowDataframe(in.table=in.table,
#' r2=0.8,
#' d.prime=0.8,
Expand Down
9 changes: 9 additions & 0 deletions R/ensemblQueryR-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
#' @importFrom jsonlite fromJSON
#' @importFrom jsonlite toJSON
#' @importFrom magrittr %>%
## usethis namespace: end
NULL
35 changes: 2 additions & 33 deletions R/helperFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @import httr
#' @import xml2
#' @import jsonlite
#' @importFrom jsonlite fromJSON toJSON
#' @importFrom magrittr %>%
#'
#' @export
Expand Down Expand Up @@ -33,7 +33,7 @@ ensemblQueryGetPops = function(){
#'
#' @import httr
#' @import xml2
#' @import jsonlite
#' @importFrom jsonlite fromJSON toJSON
#'
#' @export
#'
Expand All @@ -53,34 +53,3 @@ pingEnsembl = function(){

return(response)
}

# estimateQueriesPerHour = function(cores, n.queries){
#
# # based on a single-core run of 54000 queries (max ensembl API query rate per hour) to ensemblQueryLDwithSNPpairDataframe,
# # the time taken to run 54000 queries was estimated to be 1.937771.
# # Based on this, this function takes the cores and number of queries input by the user and will output the predicted queries per hour that your run will likely spawn
# # this assumes a linear effect of additional cores
# cores=20
# n.queries=1000
# api.limit.hourly = 54000
# time_to_run_54000_in_hours = (116.266269091765/60)
# per_hour_query_rate = 54000/time_to_run_54000_in_hours
# per_minute_query_rate = per_hour_query_rate/60
# per_second_query_rate = per_minute_query_rate/60
# time_for_one_query_seconds = (time_to_run_54000_in_hours/54000)*60*60
#
#
#
# if(time_for_user_queries < 15){
# print(paste(
# "Warning: your query of size",n.queries,"using",cores,"cores may exceed the Ensembl REST API hourly query limit. Consider using fewer cores or splitting your query into smaller chunks."
# ))
# }
#
#
# predicted_requests_per_hour = n.queries/(time_to_run_54000_in_hours/cores)
#
#
#
# }

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ The goal of ensemblQueryR is to seemlessly integrate querying of Ensembl databas

## Installation

You can install the development version of ensemblQueryR like so:
You can install ensemblQueryR as below.

``` r
# load remotes package
library(remotes)

# to install the development version
remotes::install_github("ainefairbrother/ensemblQueryR")

# to install the stable CRAN release
install.packages("ensemblQueryR")
```

Or from

## Setup

To check that the Ensembl server is up and running, the server can be pinged.
Expand Down
10 changes: 5 additions & 5 deletions benchmarking/ensemblQueryR_vs_LDlinkR.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# load libs
devtools::load_all("/home/abrowne/projects/ensemblQueryR/")
library(LDlinkR)
library(magrittr)
library(peakRAM)
# # load libs
# devtools::load_all("/home/abrowne/projects/ensemblQueryR/")
# library(LDlinkR)
# library(magrittr)
# library(peakRAM)

# -- 1. Run benchmarking for 100,1000,10000 queries --------------------------------------------

Expand Down
6 changes: 4 additions & 2 deletions man/ensemblQueryLDwithSNPpairDataframe.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/ensemblQueryLDwithSNPwindow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/ensemblQueryLDwithSNPwindowDataframe.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/ensemblQueryR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e64bc67

Please sign in to comment.