From 1f71fe84c305c7e7c8ea519e698263ec7da934db Mon Sep 17 00:00:00 2001 From: Julia Gustavsen Date: Fri, 27 Oct 2023 15:51:27 +0200 Subject: [PATCH 1/7] Changed examples from dontrun to donttest --- R/allgensnp.R | 2 +- R/allphenotypes.R | 2 +- R/annotations.R | 2 +- R/download_users.R | 8 ++++---- R/fetch_genotypes.R | 2 +- R/genotypes.R | 2 +- R/ncbi_snp_api.R | 2 +- R/phenotypes.R | 2 +- R/phenotypes_byid.R | 2 +- R/users.R | 2 +- man/allgensnp.Rd | 2 +- man/allphenotypes.Rd | 2 +- man/annotations.Rd | 2 +- man/fetch_genotypes.Rd | 2 +- man/genotypes.Rd | 2 +- man/ncbi_snp_query.Rd | 2 +- man/phenotypes.Rd | 2 +- man/phenotypes_byid.Rd | 2 +- man/read_users.Rd | 8 ++++---- man/users.Rd | 2 +- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/R/allgensnp.R b/R/allgensnp.R index 4727ae7..bdd8245 100644 --- a/R/allgensnp.R +++ b/R/allgensnp.R @@ -6,7 +6,7 @@ #' @param usersubset Get a subset of users, integer numbers, e.g. 1-8 (default: none) #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of genotypes for all users at a certain SNP -#' @examples \dontrun{ +#' @examples \donttest{ #' x <- allgensnp(snp = "rs7412") #' head(x) #' } diff --git a/R/allphenotypes.R b/R/allphenotypes.R index e1bdc06..ce9fdeb 100644 --- a/R/allphenotypes.R +++ b/R/allphenotypes.R @@ -12,7 +12,7 @@ #' number_of_users are replicated in the data.frame. Default: `FALSE` #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of results, or list if `df=FALSE` -#' @examples \dontrun{ +#' @examples \donttest{ #' # Get all data #' allphenotypes(df = TRUE) #' diff --git a/R/annotations.R b/R/annotations.R index 04b5afa..c23c7e9 100644 --- a/R/annotations.R +++ b/R/annotations.R @@ -13,7 +13,7 @@ #' metadata for the response. #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of results -#' @examples \dontrun{ +#' @examples \donttest{ #' # Get all data #' ## get just the metadata #' annotations(snp = "rs7903146", output = "metadata") diff --git a/R/download_users.R b/R/download_users.R index 76a0823..cc338a9 100644 --- a/R/download_users.R +++ b/R/download_users.R @@ -65,10 +65,10 @@ get_write <- function(x, y, ...) { #' variables for the path to the file saved. Alternatively, you can supply #' the path. #' @return A data.frame. -#' @examples \dontrun{ -#' # dat <- read_users(name = "kevinmcc") -#' # head(dat) -#' # dat <- read_users(id = 285) +#' @examples \donttest{ +#' dat <- read_users(name = "kevinmcc") +#' head(dat) +#' dat <- read_users(id = 285) #' } read_users <- function(name = NULL, id = NULL, path = NULL, ...) { if (is.null(name) && is.null(id) && is.null(path)) { diff --git a/R/fetch_genotypes.R b/R/fetch_genotypes.R index c361cd8..f7f3983 100644 --- a/R/fetch_genotypes.R +++ b/R/fetch_genotypes.R @@ -28,7 +28,7 @@ #' Internally, we use [download.file()] to download each file, then #' [read.table()] to read the file to a data.frame. #' -#' @examples \dontrun{ +#' @examples \donttest{ #' # get a data.frame of the users data #' data <- users(df = TRUE) #' head(data[[1]]) # users with links to genome data diff --git a/R/genotypes.R b/R/genotypes.R index 5292684..34d4574 100644 --- a/R/genotypes.R +++ b/R/genotypes.R @@ -8,7 +8,7 @@ #' @param ... Curl options passed on to [crul::HttpClient]] #' @return List (or data.frame) of genotypes for specified user(s) at a #' certain SNP. -#' @examples \dontrun{ +#' @examples \donttest{ #' genotypes(snp = "rs9939609", userid = 1) #' genotypes("rs9939609", userid = "1,6,8", df = TRUE) #' genotypes("rs9939609", userid = "1-2", df = FALSE) diff --git a/R/ncbi_snp_api.R b/R/ncbi_snp_api.R index 15e91ec..3dff624 100644 --- a/R/ncbi_snp_api.R +++ b/R/ncbi_snp_api.R @@ -211,7 +211,7 @@ get_gene_names <- function(primary_info) { #' If users want to set curl options when querying for the SNPs they can do so by using #' httr::set_config/httr::with_config #' -#' @examples \dontrun{ +#' @examples \donttest{ #' ## an example with both merged SNPs, non-SNV SNPs, regular SNPs, #' ## SNPs not found, microsatellite #' SNPs <- c("rs332", "rs420358", "rs1837253", "rs1209415715", "rs111068718") diff --git a/R/phenotypes.R b/R/phenotypes.R index 59fa5f5..4a88240 100644 --- a/R/phenotypes.R +++ b/R/phenotypes.R @@ -7,7 +7,7 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of phenotypes for specified user(s). #' -#' @examples \dontrun{ +#' @examples \donttest{ #' phenotypes(userid = 1) #' phenotypes(userid = "1,6,8", df = TRUE) #' phenotypes(userid = "1-8", df = TRUE) diff --git a/R/phenotypes_byid.R b/R/phenotypes_byid.R index e2dc94d..802baba 100644 --- a/R/phenotypes_byid.R +++ b/R/phenotypes_byid.R @@ -9,7 +9,7 @@ #' @return List of description of phenotype, list of known variants, or #' data.frame of variants for each user with that phenotype. #' -#' @examples \dontrun{ +#' @examples \donttest{ #' phenotypes_byid(phenotypeid = 12, return_ = "desc") #' phenotypes_byid(phenotypeid = 12, return_ = "knownvars") #' phenotypes_byid(phenotypeid = 12, return_ = "users") diff --git a/R/users.R b/R/users.R index 1264e55..aeb62f3 100644 --- a/R/users.R +++ b/R/users.R @@ -5,7 +5,7 @@ #' @param df Return data.frame (`TRUE`) or not (`FALSE`). Default: `FALSE` #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of openSNP users, their ID numbers, and XX if available. -#' @examples \dontrun{ +#' @examples \donttest{ #' # just the list #' data <- users(df = FALSE) #' data diff --git a/man/allgensnp.Rd b/man/allgensnp.Rd index 6742025..00a0ab6 100644 --- a/man/allgensnp.Rd +++ b/man/allgensnp.Rd @@ -20,7 +20,7 @@ data.frame of genotypes for all users at a certain SNP Get openSNP genotype data for all users at a particular snp. } \examples{ -\dontrun{ +\donttest{ x <- allgensnp(snp = "rs7412") head(x) } diff --git a/man/allphenotypes.Rd b/man/allphenotypes.Rd index 55ddb53..e4809c2 100644 --- a/man/allphenotypes.Rd +++ b/man/allphenotypes.Rd @@ -23,7 +23,7 @@ the characteristic by id (parameter = "id") or name (parameter = "characteristic"). } \examples{ -\dontrun{ +\donttest{ # Get all data allphenotypes(df = TRUE) diff --git a/man/annotations.Rd b/man/annotations.Rd index 460d69f..bcdc3fc 100644 --- a/man/annotations.Rd +++ b/man/annotations.Rd @@ -29,7 +29,7 @@ the characteristic by id (parameter = "id") or name (parameter = "characteristic"). } \examples{ -\dontrun{ +\donttest{ # Get all data ## get just the metadata annotations(snp = "rs7903146", output = "metadata") diff --git a/man/fetch_genotypes.Rd b/man/fetch_genotypes.Rd index 0e5adf2..f979363 100644 --- a/man/fetch_genotypes.Rd +++ b/man/fetch_genotypes.Rd @@ -45,7 +45,7 @@ Internally, we use \code{\link[=download.file]{download.file()}} to download eac \code{\link[=read.table]{read.table()}} to read the file to a data.frame. } \examples{ -\dontrun{ +\donttest{ # get a data.frame of the users data data <- users(df = TRUE) head(data[[1]]) # users with links to genome data diff --git a/man/genotypes.Rd b/man/genotypes.Rd index ceacbe5..d376eba 100644 --- a/man/genotypes.Rd +++ b/man/genotypes.Rd @@ -23,7 +23,7 @@ certain SNP. Get openSNP genotype data for one or multiple users. } \examples{ -\dontrun{ +\donttest{ genotypes(snp = "rs9939609", userid = 1) genotypes("rs9939609", userid = "1,6,8", df = TRUE) genotypes("rs9939609", userid = "1-2", df = FALSE) diff --git a/man/ncbi_snp_query.Rd b/man/ncbi_snp_query.Rd index f09fb37..560ef22 100644 --- a/man/ncbi_snp_query.Rd +++ b/man/ncbi_snp_query.Rd @@ -62,7 +62,7 @@ If users want to set curl options when querying for the SNPs they can do so by u httr::set_config/httr::with_config } \examples{ -\dontrun{ +\donttest{ ## an example with both merged SNPs, non-SNV SNPs, regular SNPs, ## SNPs not found, microsatellite SNPs <- c("rs332", "rs420358", "rs1837253", "rs1209415715", "rs111068718") diff --git a/man/phenotypes.Rd b/man/phenotypes.Rd index 188719e..fbad1ae 100644 --- a/man/phenotypes.Rd +++ b/man/phenotypes.Rd @@ -20,7 +20,7 @@ List of phenotypes for specified user(s). Get openSNP phenotype data for one or multiple users. } \examples{ -\dontrun{ +\donttest{ phenotypes(userid = 1) phenotypes(userid = "1,6,8", df = TRUE) phenotypes(userid = "1-8", df = TRUE) diff --git a/man/phenotypes_byid.Rd b/man/phenotypes_byid.Rd index 26c8118..ad4d213 100644 --- a/man/phenotypes_byid.Rd +++ b/man/phenotypes_byid.Rd @@ -27,7 +27,7 @@ Get all openSNP known variations and all users sharing that phenotype for one phenotype(-ID). } \examples{ -\dontrun{ +\donttest{ phenotypes_byid(phenotypeid = 12, return_ = "desc") phenotypes_byid(phenotypeid = 12, return_ = "knownvars") phenotypes_byid(phenotypeid = 12, return_ = "users") diff --git a/man/read_users.Rd b/man/read_users.Rd index d6473be..2cd5052 100644 --- a/man/read_users.Rd +++ b/man/read_users.Rd @@ -30,9 +30,9 @@ variables for the path to the file saved. Alternatively, you can supply the path. } \examples{ -\dontrun{ -# dat <- read_users(name = "kevinmcc") -# head(dat) -# dat <- read_users(id = 285) +\donttest{ +dat <- read_users(name = "kevinmcc") +head(dat) +dat <- read_users(id = 285) } } diff --git a/man/users.Rd b/man/users.Rd index 65d309c..e9cddc8 100644 --- a/man/users.Rd +++ b/man/users.Rd @@ -18,7 +18,7 @@ List of openSNP users, their ID numbers, and XX if available. Get openSNP users. } \examples{ -\dontrun{ +\donttest{ # just the list data <- users(df = FALSE) data From 59d328f240e6eb345cae0542bab9b975b63f6251 Mon Sep 17 00:00:00 2001 From: Julia Gustavsen Date: Sun, 5 Nov 2023 06:27:52 +0100 Subject: [PATCH 2/7] adapted examples so that they are donttest instead of dontrun --- R/download_users.R | 3 ++- R/ncbi_snp_api.R | 1 - man/ncbi_snp_query.Rd | 1 - man/read_users.Rd | 3 ++- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/download_users.R b/R/download_users.R index 4c2676c..a7dede4 100644 --- a/R/download_users.R +++ b/R/download_users.R @@ -66,9 +66,10 @@ get_write <- function(x, y, ...) { #' the path. #' @return A data.frame with openSNP user files retrieved from local storage #' @examples \donttest{ +#' +#' download_users(name = "kevinmcc") #' dat <- read_users(name = "kevinmcc") #' head(dat) -#' dat <- read_users(id = 285) #' } read_users <- function(name = NULL, id = NULL, path = NULL, ...) { if (is.null(name) && is.null(id) && is.null(path)) { diff --git a/R/ncbi_snp_api.R b/R/ncbi_snp_api.R index 3dff624..695fc92 100644 --- a/R/ncbi_snp_api.R +++ b/R/ncbi_snp_api.R @@ -226,7 +226,6 @@ get_gene_names <- function(primary_info) { #' ncbi_snp_query(snps = "rs9970807") #' #' ncbi_snp_query("rs121909001") -#' ncbi_snp_query("rs121909001", verbose = TRUE) #' } ncbi_snp_query <- function(snps) { diff --git a/man/ncbi_snp_query.Rd b/man/ncbi_snp_query.Rd index 560ef22..bf01435 100644 --- a/man/ncbi_snp_query.Rd +++ b/man/ncbi_snp_query.Rd @@ -77,7 +77,6 @@ ncbi_snp_query("rs111068718") ncbi_snp_query(snps = "rs9970807") ncbi_snp_query("rs121909001") -ncbi_snp_query("rs121909001", verbose = TRUE) } } \references{ diff --git a/man/read_users.Rd b/man/read_users.Rd index 221c8b8..829f207 100644 --- a/man/read_users.Rd +++ b/man/read_users.Rd @@ -31,8 +31,9 @@ the path. } \examples{ \donttest{ + +download_users(name = "kevinmcc") dat <- read_users(name = "kevinmcc") head(dat) -dat <- read_users(id = 285) } } From 9c33aa393288495109b322f504f34cfcbb319c6f Mon Sep 17 00:00:00 2001 From: Julia Gustavsen Date: Sat, 11 Nov 2023 16:01:45 +0100 Subject: [PATCH 3/7] simplified some examples --- R/allphenotypes.R | 2 -- R/download_users.R | 6 +----- R/fetch_genotypes.R | 2 -- R/ncbi_snp_api.R | 2 +- R/phenotypes.R | 6 ------ R/users.R | 4 ---- man/allphenotypes.Rd | 2 -- man/download_users.Rd | 6 +----- man/fetch_genotypes.Rd | 2 -- man/ncbi_snp_query.Rd | 2 +- man/phenotypes.Rd | 6 ------ man/users.Rd | 4 ---- 12 files changed, 4 insertions(+), 40 deletions(-) diff --git a/R/allphenotypes.R b/R/allphenotypes.R index 67a138b..2f16b38 100644 --- a/R/allphenotypes.R +++ b/R/allphenotypes.R @@ -14,8 +14,6 @@ #' @return data.frame of openSNP phenotypes, variants and users per phenotype, or list if `df=FALSE` #' @examples \donttest{ #' # Get all data -#' allphenotypes(df = TRUE) -#' #' # Output a list, then call the characteristic of interest by 'id' or #' # 'characteristic' #' datalist <- allphenotypes() diff --git a/R/download_users.R b/R/download_users.R index a7dede4..8974baf 100644 --- a/R/download_users.R +++ b/R/download_users.R @@ -8,16 +8,12 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return File downloaded to directory you specify (or default), nothing #' returned in R. -#' @examples \dontrun{ +#' @examples \donttest{ #' # Download a single user file, by id #' download_users(id = 14) #' #' # Download a single user file, by user name #' download_users(name = "kevinmcc") -#' -#' # Download many user files -#' lapply(c(14, 22), function(x) download_users(id = x)) -#' read_users(id = 14, nrows = 5) #' } download_users <- function(name = NULL, id = NULL, dir = "~/", ...) { if (is.null(name) && is.null(id)) { diff --git a/R/fetch_genotypes.R b/R/fetch_genotypes.R index f7f3983..395c6f2 100644 --- a/R/fetch_genotypes.R +++ b/R/fetch_genotypes.R @@ -30,8 +30,6 @@ #' #' @examples \donttest{ #' # get a data.frame of the users data -#' data <- users(df = TRUE) -#' head(data[[1]]) # users with links to genome data #' mydata <- fetch_genotypes( #' url = data[[1]][1, "genotypes.download_url"], #' file = "~/myfile.txt" diff --git a/R/ncbi_snp_api.R b/R/ncbi_snp_api.R index 695fc92..8d379b9 100644 --- a/R/ncbi_snp_api.R +++ b/R/ncbi_snp_api.R @@ -218,7 +218,7 @@ get_gene_names <- function(primary_info) { #' ncbi_snp_query(SNPs) #' # ncbi_snp_query("123456") ##invalid: must prefix with 'rs' #' ncbi_snp_query("rs420358") -#' ncbi_snp_query("rs332") # warning that its merged into another, try that +#' ncbi_snp_query("rs332") # warning that its merged into another #' ncbi_snp_query("rs121909001") #' ncbi_snp_query("rs1837253") #' ncbi_snp_query("rs1209415715") diff --git a/R/phenotypes.R b/R/phenotypes.R index 8a66923..8181882 100644 --- a/R/phenotypes.R +++ b/R/phenotypes.R @@ -12,12 +12,6 @@ #' phenotypes(userid = "1,6,8", df = TRUE) #' phenotypes(userid = "1-8", df = TRUE) #' -#' # coerce to data.frame -#' library(plyr) -#' df <- ldply(phenotypes(userid = "1-8", df = TRUE)) -#' head(df) -#' tail(df) -#' #' # pass on curl options #' phenotypes(1, verbose = TRUE) #' } diff --git a/R/users.R b/R/users.R index 19ddaed..2664b91 100644 --- a/R/users.R +++ b/R/users.R @@ -6,10 +6,6 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of openSNP users, their ID numbers, and genome data if available. #' @examples \donttest{ -#' # just the list -#' data <- users(df = FALSE) -#' data -#' #' # get a data.frame of the users data #' data <- users(df = TRUE) #' data[[1]] # users with links to genome data diff --git a/man/allphenotypes.Rd b/man/allphenotypes.Rd index 2d43aed..d1da155 100644 --- a/man/allphenotypes.Rd +++ b/man/allphenotypes.Rd @@ -25,8 +25,6 @@ the characteristic by id (parameter = "id") or name (parameter = \examples{ \donttest{ # Get all data -allphenotypes(df = TRUE) - # Output a list, then call the characteristic of interest by 'id' or # 'characteristic' datalist <- allphenotypes() diff --git a/man/download_users.Rd b/man/download_users.Rd index 995cd80..17a9b90 100644 --- a/man/download_users.Rd +++ b/man/download_users.Rd @@ -23,16 +23,12 @@ returned in R. Download openSNP user files. } \examples{ -\dontrun{ +\donttest{ # Download a single user file, by id download_users(id = 14) # Download a single user file, by user name download_users(name = "kevinmcc") - -# Download many user files -lapply(c(14, 22), function(x) download_users(id = x)) -read_users(id = 14, nrows = 5) } } \seealso{ diff --git a/man/fetch_genotypes.Rd b/man/fetch_genotypes.Rd index f979363..f04d21d 100644 --- a/man/fetch_genotypes.Rd +++ b/man/fetch_genotypes.Rd @@ -47,8 +47,6 @@ Internally, we use \code{\link[=download.file]{download.file()}} to download eac \examples{ \donttest{ # get a data.frame of the users data -data <- users(df = TRUE) -head(data[[1]]) # users with links to genome data mydata <- fetch_genotypes( url = data[[1]][1, "genotypes.download_url"], file = "~/myfile.txt" diff --git a/man/ncbi_snp_query.Rd b/man/ncbi_snp_query.Rd index bf01435..62e2353 100644 --- a/man/ncbi_snp_query.Rd +++ b/man/ncbi_snp_query.Rd @@ -69,7 +69,7 @@ SNPs <- c("rs332", "rs420358", "rs1837253", "rs1209415715", "rs111068718") ncbi_snp_query(SNPs) # ncbi_snp_query("123456") ##invalid: must prefix with 'rs' ncbi_snp_query("rs420358") -ncbi_snp_query("rs332") # warning that its merged into another, try that +ncbi_snp_query("rs332") # warning that its merged into another ncbi_snp_query("rs121909001") ncbi_snp_query("rs1837253") ncbi_snp_query("rs1209415715") diff --git a/man/phenotypes.Rd b/man/phenotypes.Rd index 0c22640..d66b58b 100644 --- a/man/phenotypes.Rd +++ b/man/phenotypes.Rd @@ -25,12 +25,6 @@ phenotypes(userid = 1) phenotypes(userid = "1,6,8", df = TRUE) phenotypes(userid = "1-8", df = TRUE) -# coerce to data.frame -library(plyr) -df <- ldply(phenotypes(userid = "1-8", df = TRUE)) -head(df) -tail(df) - # pass on curl options phenotypes(1, verbose = TRUE) } diff --git a/man/users.Rd b/man/users.Rd index d6ba31e..b9dd29c 100644 --- a/man/users.Rd +++ b/man/users.Rd @@ -19,10 +19,6 @@ Get openSNP users. } \examples{ \donttest{ -# just the list -data <- users(df = FALSE) -data - # get a data.frame of the users data data <- users(df = TRUE) data[[1]] # users with links to genome data From df78622b84205b253141e3a412afc9dda98381a2 Mon Sep 17 00:00:00 2001 From: Julia Gustavsen Date: Fri, 17 Nov 2023 14:41:16 +0100 Subject: [PATCH 4/7] using instead exampleif to not run examples on CRAN. --- R/allgensnp.R | 3 +-- R/allphenotypes.R | 3 +-- R/annotations.R | 4 ++-- R/download_users.R | 8 ++++---- R/fetch_genotypes.R | 3 +-- R/genotypes.R | 3 +-- R/ncbi_snp_api.R | 3 +-- R/phenotypes.R | 3 +-- R/phenotypes_byid.R | 4 +--- R/users.R | 3 +-- R/utils.R | 8 ++++++++ man/allgensnp.Rd | 4 ++-- man/allphenotypes.Rd | 4 ++-- man/annotations.Rd | 4 ++-- man/download_users.Rd | 4 ++-- man/fetch_genotypes.Rd | 4 ++-- man/genotypes.Rd | 4 ++-- man/ncbi_snp_query.Rd | 4 ++-- man/phenotypes.Rd | 4 ++-- man/phenotypes_byid.Rd | 4 ++-- man/read_users.Rd | 4 ++-- man/users.Rd | 4 ++-- 22 files changed, 44 insertions(+), 45 deletions(-) diff --git a/R/allgensnp.R b/R/allgensnp.R index bdd8245..7a974b6 100644 --- a/R/allgensnp.R +++ b/R/allgensnp.R @@ -6,10 +6,9 @@ #' @param usersubset Get a subset of users, integer numbers, e.g. 1-8 (default: none) #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of genotypes for all users at a certain SNP -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' x <- allgensnp(snp = "rs7412") #' head(x) -#' } allgensnp <- function(snp = NA, usersubset = FALSE, ...) { ## add possibilty to get a subset of users diff --git a/R/allphenotypes.R b/R/allphenotypes.R index 2f16b38..1446b6f 100644 --- a/R/allphenotypes.R +++ b/R/allphenotypes.R @@ -12,7 +12,7 @@ #' number_of_users are replicated in the data.frame. Default: `FALSE` #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of openSNP phenotypes, variants and users per phenotype, or list if `df=FALSE` -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # Get all data #' # Output a list, then call the characteristic of interest by 'id' or #' # 'characteristic' @@ -20,7 +20,6 @@ #' names(datalist) # get list of all characteristics you can call #' datalist[["ADHD"]] # get data.frame for 'ADHD' #' datalist[c("mouth size", "SAT Writing")] # get data.frame for 'ADHD' -#' } allphenotypes <- function(df = FALSE, ...) { tryCatch( { diff --git a/R/annotations.R b/R/annotations.R index 3322bfa..4544695 100644 --- a/R/annotations.R +++ b/R/annotations.R @@ -13,7 +13,7 @@ #' metadata for the response. #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of openSNP phenotypes from specified source -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # Get all data #' ## get just the metadata #' annotations(snp = "rs7903146", output = "metadata") @@ -26,7 +26,7 @@ #' #' ## get all annotations #' annotations(snp = "rs7903146", output = "all") -#' } + annotations <- function(snp = NA, output = c("all", "plos", "mendeley", "snpedia", "metadata"), ...) { url <- paste0(osnp_base(), "snps/json/annotation/", snp, ".json") diff --git a/R/download_users.R b/R/download_users.R index 8974baf..6d0bff0 100644 --- a/R/download_users.R +++ b/R/download_users.R @@ -8,13 +8,13 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return File downloaded to directory you specify (or default), nothing #' returned in R. -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # Download a single user file, by id #' download_users(id = 14) #' #' # Download a single user file, by user name #' download_users(name = "kevinmcc") -#' } + download_users <- function(name = NULL, id = NULL, dir = "~/", ...) { if (is.null(name) && is.null(id)) { stop("You must specify one of name or id", call. = FALSE) @@ -61,12 +61,12 @@ get_write <- function(x, y, ...) { #' variables for the path to the file saved. Alternatively, you can supply #' the path. #' @return A data.frame with openSNP user files retrieved from local storage -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' #' download_users(name = "kevinmcc") #' dat <- read_users(name = "kevinmcc") #' head(dat) -#' } + read_users <- function(name = NULL, id = NULL, path = NULL, ...) { if (is.null(name) && is.null(id) && is.null(path)) { stop("You must specify one of name, id, or path", call. = FALSE) diff --git a/R/fetch_genotypes.R b/R/fetch_genotypes.R index 395c6f2..705386c 100644 --- a/R/fetch_genotypes.R +++ b/R/fetch_genotypes.R @@ -28,7 +28,7 @@ #' Internally, we use [download.file()] to download each file, then #' [read.table()] to read the file to a data.frame. #' -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # get a data.frame of the users data #' mydata <- fetch_genotypes( #' url = data[[1]][1, "genotypes.download_url"], @@ -40,7 +40,6 @@ #' #' # Or read in data later separately #' read.table("~/myfile.txt", nrows = 10) -#' } fetch_genotypes <- function(url, rows = 100, filepath = NULL, quiet = TRUE, ...) { if (is.null(filepath)) filepath <- tempfile(fileext = ".txt") diff --git a/R/genotypes.R b/R/genotypes.R index 34d4574..c3de7cf 100644 --- a/R/genotypes.R +++ b/R/genotypes.R @@ -8,11 +8,10 @@ #' @param ... Curl options passed on to [crul::HttpClient]] #' @return List (or data.frame) of genotypes for specified user(s) at a #' certain SNP. -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' genotypes(snp = "rs9939609", userid = 1) #' genotypes("rs9939609", userid = "1,6,8", df = TRUE) #' genotypes("rs9939609", userid = "1-2", df = FALSE) -#' } genotypes <- function(snp = NA, userid = NA, df = FALSE, ...) { url2 <- paste0(paste0(osnp_base(), "snps/json/"), snp, "/", userid, ".json") diff --git a/R/ncbi_snp_api.R b/R/ncbi_snp_api.R index 8d379b9..34bca9d 100644 --- a/R/ncbi_snp_api.R +++ b/R/ncbi_snp_api.R @@ -211,7 +211,7 @@ get_gene_names <- function(primary_info) { #' If users want to set curl options when querying for the SNPs they can do so by using #' httr::set_config/httr::with_config #' -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' ## an example with both merged SNPs, non-SNV SNPs, regular SNPs, #' ## SNPs not found, microsatellite #' SNPs <- c("rs332", "rs420358", "rs1837253", "rs1209415715", "rs111068718") @@ -226,7 +226,6 @@ get_gene_names <- function(primary_info) { #' ncbi_snp_query(snps = "rs9970807") #' #' ncbi_snp_query("rs121909001") -#' } ncbi_snp_query <- function(snps) { ## NCBI moved to https but not using http v.2. The setting of the version diff --git a/R/phenotypes.R b/R/phenotypes.R index 8181882..03c4e88 100644 --- a/R/phenotypes.R +++ b/R/phenotypes.R @@ -7,14 +7,13 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of phenotypes for specified user(s) from openSNP. #' -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' phenotypes(userid = 1) #' phenotypes(userid = "1,6,8", df = TRUE) #' phenotypes(userid = "1-8", df = TRUE) #' #' # pass on curl options #' phenotypes(1, verbose = TRUE) -#' } phenotypes <- function(userid = NA, df = FALSE, ...) { url2 <- paste0(paste0(osnp_base(), "phenotypes/json/"), userid, ".json") diff --git a/R/phenotypes_byid.R b/R/phenotypes_byid.R index bfef287..da0fc12 100644 --- a/R/phenotypes_byid.R +++ b/R/phenotypes_byid.R @@ -8,15 +8,13 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of description of phenotype, list of known variants, or #' data.frame of variants for each user with that phenotype retrieved from openSNP. -#' -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' phenotypes_byid(phenotypeid = 12, return_ = "desc") #' phenotypes_byid(phenotypeid = 12, return_ = "knownvars") #' phenotypes_byid(phenotypeid = 12, return_ = "users") #' #' # pass on curl options #' phenotypes_byid(phenotypeid = 12, return_ = "desc", verbose = TRUE) -#' } phenotypes_byid <- function(phenotypeid = NA, return_ = c("description", "knownvars", "users"), ...) { url2 <- paste0( diff --git a/R/users.R b/R/users.R index 2664b91..4dbe8b1 100644 --- a/R/users.R +++ b/R/users.R @@ -5,12 +5,11 @@ #' @param df Return data.frame (`TRUE`) or not (`FALSE`). Default: `FALSE` #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of openSNP users, their ID numbers, and genome data if available. -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # get a data.frame of the users data #' data <- users(df = TRUE) #' data[[1]] # users with links to genome data #' data[[2]] # users without links to genome data -#' } users <- function(df = FALSE, ...) { diff --git a/R/utils.R b/R/utils.R index 001c504..dbae421 100644 --- a/R/utils.R +++ b/R/utils.R @@ -114,3 +114,11 @@ release_bullets <- function() { "Bump dev version" ) } + +is_rcmd_check <- function () { + if (identical(Sys.getenv("NOT_CRAN"), "true")) { + FALSE + } else { + Sys.getenv("_R_CHECK_PACKAGE_NAME_", "") != "" + } +} diff --git a/man/allgensnp.Rd b/man/allgensnp.Rd index 00a0ab6..63ed0bd 100644 --- a/man/allgensnp.Rd +++ b/man/allgensnp.Rd @@ -20,10 +20,10 @@ data.frame of genotypes for all users at a certain SNP Get openSNP genotype data for all users at a particular snp. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} x <- allgensnp(snp = "rs7412") head(x) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/allphenotypes.Rd b/man/allphenotypes.Rd index d1da155..e87041e 100644 --- a/man/allphenotypes.Rd +++ b/man/allphenotypes.Rd @@ -23,7 +23,7 @@ the characteristic by id (parameter = "id") or name (parameter = "characteristic"). } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Get all data # Output a list, then call the characteristic of interest by 'id' or # 'characteristic' @@ -31,7 +31,7 @@ datalist <- allphenotypes() names(datalist) # get list of all characteristics you can call datalist[["ADHD"]] # get data.frame for 'ADHD' datalist[c("mouth size", "SAT Writing")] # get data.frame for 'ADHD' -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/annotations.Rd b/man/annotations.Rd index 0a82d3d..7c5057d 100644 --- a/man/annotations.Rd +++ b/man/annotations.Rd @@ -29,7 +29,7 @@ the characteristic by id (parameter = "id") or name (parameter = "characteristic"). } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Get all data ## get just the metadata annotations(snp = "rs7903146", output = "metadata") @@ -42,7 +42,7 @@ annotations(snp = "rs7903146", output = "snpedia") ## get all annotations annotations(snp = "rs7903146", output = "all") -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/download_users.Rd b/man/download_users.Rd index 17a9b90..6495fec 100644 --- a/man/download_users.Rd +++ b/man/download_users.Rd @@ -23,13 +23,13 @@ returned in R. Download openSNP user files. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Download a single user file, by id download_users(id = 14) # Download a single user file, by user name download_users(name = "kevinmcc") -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/fetch_genotypes.Rd b/man/fetch_genotypes.Rd index f04d21d..7118c4e 100644 --- a/man/fetch_genotypes.Rd +++ b/man/fetch_genotypes.Rd @@ -45,7 +45,7 @@ Internally, we use \code{\link[=download.file]{download.file()}} to download eac \code{\link[=read.table]{read.table()}} to read the file to a data.frame. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # get a data.frame of the users data mydata <- fetch_genotypes( url = data[[1]][1, "genotypes.download_url"], @@ -57,7 +57,7 @@ mydata # Or read in data later separately read.table("~/myfile.txt", nrows = 10) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/genotypes.Rd b/man/genotypes.Rd index d376eba..dda552d 100644 --- a/man/genotypes.Rd +++ b/man/genotypes.Rd @@ -23,11 +23,11 @@ certain SNP. Get openSNP genotype data for one or multiple users. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} genotypes(snp = "rs9939609", userid = 1) genotypes("rs9939609", userid = "1,6,8", df = TRUE) genotypes("rs9939609", userid = "1-2", df = FALSE) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/ncbi_snp_query.Rd b/man/ncbi_snp_query.Rd index 62e2353..b710b19 100644 --- a/man/ncbi_snp_query.Rd +++ b/man/ncbi_snp_query.Rd @@ -62,7 +62,7 @@ If users want to set curl options when querying for the SNPs they can do so by u httr::set_config/httr::with_config } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} ## an example with both merged SNPs, non-SNV SNPs, regular SNPs, ## SNPs not found, microsatellite SNPs <- c("rs332", "rs420358", "rs1837253", "rs1209415715", "rs111068718") @@ -77,7 +77,7 @@ ncbi_snp_query("rs111068718") ncbi_snp_query(snps = "rs9970807") ncbi_snp_query("rs121909001") -} +\dontshow{\}) # examplesIf} } \references{ \url{https://www.ncbi.nlm.nih.gov/projects/SNP/} diff --git a/man/phenotypes.Rd b/man/phenotypes.Rd index d66b58b..b1734ba 100644 --- a/man/phenotypes.Rd +++ b/man/phenotypes.Rd @@ -20,14 +20,14 @@ List of phenotypes for specified user(s) from openSNP. Get openSNP phenotype data for one or multiple users. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} phenotypes(userid = 1) phenotypes(userid = "1,6,8", df = TRUE) phenotypes(userid = "1-8", df = TRUE) # pass on curl options phenotypes(1, verbose = TRUE) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/phenotypes_byid.Rd b/man/phenotypes_byid.Rd index 817abb6..8952607 100644 --- a/man/phenotypes_byid.Rd +++ b/man/phenotypes_byid.Rd @@ -27,14 +27,14 @@ Get all openSNP known variations and all users sharing that phenotype for one phenotype(-ID). } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} phenotypes_byid(phenotypeid = 12, return_ = "desc") phenotypes_byid(phenotypeid = 12, return_ = "knownvars") phenotypes_byid(phenotypeid = 12, return_ = "users") # pass on curl options phenotypes_byid(phenotypeid = 12, return_ = "desc", verbose = TRUE) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/read_users.Rd b/man/read_users.Rd index 829f207..f6efa85 100644 --- a/man/read_users.Rd +++ b/man/read_users.Rd @@ -30,10 +30,10 @@ variables for the path to the file saved. Alternatively, you can supply the path. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} download_users(name = "kevinmcc") dat <- read_users(name = "kevinmcc") head(dat) -} +\dontshow{\}) # examplesIf} } diff --git a/man/users.Rd b/man/users.Rd index b9dd29c..203bef8 100644 --- a/man/users.Rd +++ b/man/users.Rd @@ -18,12 +18,12 @@ List of openSNP users, their ID numbers, and genome data if available. Get openSNP users. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # get a data.frame of the users data data <- users(df = TRUE) data[[1]] # users with links to genome data data[[2]] # users without links to genome data -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: From 0d6895158900411ed707052804674c987afcac4b Mon Sep 17 00:00:00 2001 From: Julia Gustavsen Date: Fri, 17 Nov 2023 14:59:36 +0100 Subject: [PATCH 5/7] Updated and now checking examples --- R/fetch_genotypes.R | 1 + man/fetch_genotypes.Rd | 1 + 2 files changed, 2 insertions(+) diff --git a/R/fetch_genotypes.R b/R/fetch_genotypes.R index 705386c..6486a60 100644 --- a/R/fetch_genotypes.R +++ b/R/fetch_genotypes.R @@ -30,6 +30,7 @@ #' #' @examplesIf !rsnps:::is_rcmd_check() #' # get a data.frame of the users data +#' data <- users(df = TRUE) #' mydata <- fetch_genotypes( #' url = data[[1]][1, "genotypes.download_url"], #' file = "~/myfile.txt" diff --git a/man/fetch_genotypes.Rd b/man/fetch_genotypes.Rd index 7118c4e..5f04b46 100644 --- a/man/fetch_genotypes.Rd +++ b/man/fetch_genotypes.Rd @@ -47,6 +47,7 @@ Internally, we use \code{\link[=download.file]{download.file()}} to download eac \examples{ \dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # get a data.frame of the users data +data <- users(df = TRUE) mydata <- fetch_genotypes( url = data[[1]][1, "genotypes.download_url"], file = "~/myfile.txt" From c6b93f56c54c51422a23c5835dd1f2e43d854a58 Mon Sep 17 00:00:00 2001 From: Julia Gustavsen Date: Fri, 17 Nov 2023 15:09:02 +0100 Subject: [PATCH 6/7] cleaning up example documentation --- R/allphenotypes.R | 1 - man/allphenotypes.Rd | 1 - 2 files changed, 2 deletions(-) diff --git a/R/allphenotypes.R b/R/allphenotypes.R index 1446b6f..58b1328 100644 --- a/R/allphenotypes.R +++ b/R/allphenotypes.R @@ -13,7 +13,6 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of openSNP phenotypes, variants and users per phenotype, or list if `df=FALSE` #' @examplesIf !rsnps:::is_rcmd_check() -#' # Get all data #' # Output a list, then call the characteristic of interest by 'id' or #' # 'characteristic' #' datalist <- allphenotypes() diff --git a/man/allphenotypes.Rd b/man/allphenotypes.Rd index e87041e..34f1532 100644 --- a/man/allphenotypes.Rd +++ b/man/allphenotypes.Rd @@ -24,7 +24,6 @@ the characteristic by id (parameter = "id") or name (parameter = } \examples{ \dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -# Get all data # Output a list, then call the characteristic of interest by 'id' or # 'characteristic' datalist <- allphenotypes() From c4d327accba6df7226c14d2c47ad97475d9c27ca Mon Sep 17 00:00:00 2001 From: Julia Gustavsen Date: Sun, 19 Nov 2023 21:02:00 +0100 Subject: [PATCH 7/7] example, remove extra pound symbol in allphenotypes. --- R/allphenotypes.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/allphenotypes.R b/R/allphenotypes.R index 58b1328..ac22a7b 100644 --- a/R/allphenotypes.R +++ b/R/allphenotypes.R @@ -14,7 +14,7 @@ #' @return data.frame of openSNP phenotypes, variants and users per phenotype, or list if `df=FALSE` #' @examplesIf !rsnps:::is_rcmd_check() #' # Output a list, then call the characteristic of interest by 'id' or -#' # 'characteristic' +#' 'characteristic' #' datalist <- allphenotypes() #' names(datalist) # get list of all characteristics you can call #' datalist[["ADHD"]] # get data.frame for 'ADHD'