From 42e930d845fb98ca7c7218e53a913b8815b61780 Mon Sep 17 00:00:00 2001 From: GregFa <36859310+GregFa@users.noreply.github.com> Date: Sun, 25 Sep 2022 23:01:06 -0500 Subject: [PATCH 1/6] Added ".geno" format to group name in the query. Adding .geno to the group name fixes the get_geno() issue. --- R/get_data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/get_data.R b/R/get_data.R index af16dda..a96e1ba 100644 --- a/R/get_data.R +++ b/R/get_data.R @@ -76,7 +76,7 @@ get_geno <- { stopifnot(length(group) == 1) - result <- query_gn(paste0("genotypes/", group), url=url, output="text") + result <- query_gn(paste0("genotypes/", group, ".geno"), url=url, output="text") # replace @ with # result <- gsub("@", "#", result, fixed=TRUE) From d863b888a90ba60a3c0ac62432a86b7739f71773 Mon Sep 17 00:00:00 2001 From: GregFa <36859310+GregFa@users.noreply.github.com> Date: Sun, 25 Sep 2022 23:37:43 -0500 Subject: [PATCH 2/6] Add format argument in get_geno() Added format argument, default = "geno" --- R/get_data.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/get_data.R b/R/get_data.R index a96e1ba..5c75f41 100644 --- a/R/get_data.R +++ b/R/get_data.R @@ -61,6 +61,7 @@ get_pheno <- #' #' @param group Name of group #' @param url The URL for the GeneNetwork API +#' @param format The group's genotypes format #' #' @return A data frame #' @@ -72,11 +73,11 @@ get_pheno <- #' @examples #' g <- get_geno("QSM") get_geno <- - function(group, url=gnapi_url()) + function(group, url=gnapi_url(), format = "geno") { stopifnot(length(group) == 1) - result <- query_gn(paste0("genotypes/", group, ".geno"), url=url, output="text") + result <- query_gn(paste0("genotypes/", group, ".", format), url=url, output="text") # replace @ with # result <- gsub("@", "#", result, fixed=TRUE) From 77d88dbd069c80fb11b85e504eb1d5a98c2a49c2 Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Mon, 26 Sep 2022 10:58:31 -0500 Subject: [PATCH 3/6] Update get_geno.Rd; bump version --- DESCRIPTION | 6 +++--- man/get_geno.Rd | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 995d9f7..298d451 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: GNapi -Version: 0.3-4 -Date: 2021-11-17 +Version: 0.3-5 +Date: 2022-09-26 Title: Connection to the GeneNetwork API Description: Tools for connecting to the GeneNetwork API. Author: Karl W Broman [aut, cre] () @@ -26,5 +26,5 @@ LazyData: true Encoding: UTF-8 ByteCompile: true VignetteBuilder: knitr -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 Roxygen: list(markdown=TRUE) diff --git a/man/get_geno.Rd b/man/get_geno.Rd index 2227019..9f1b2ce 100644 --- a/man/get_geno.Rd +++ b/man/get_geno.Rd @@ -4,12 +4,14 @@ \alias{get_geno} \title{Get genotype data} \usage{ -get_geno(group, url = gnapi_url()) +get_geno(group, url = gnapi_url(), format = "geno") } \arguments{ \item{group}{Name of group} \item{url}{The URL for the GeneNetwork API} + +\item{format}{The group's genotypes format} } \value{ A data frame From 05a2a1d267a1cee41be4b91c0962c5f7c92f7f7d Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Mon, 26 Sep 2022 11:20:33 -0500 Subject: [PATCH 4/6] Fix bug in info_pheno() - can no longer get list of traits within group --- DESCRIPTION | 2 +- R/get_info.R | 14 +++----------- docs/GNapi.html | 31 ++++++++++++++++++------------- man/info_pheno.Rd | 6 +----- vignettes/GNapi.Rmd | 15 ++++++--------- 5 files changed, 29 insertions(+), 39 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 298d451..fa31d9f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: GNapi -Version: 0.3-5 +Version: 0.3-6 Date: 2022-09-26 Title: Connection to the GeneNetwork API Description: Tools for connecting to the GeneNetwork API. diff --git a/R/get_info.R b/R/get_info.R index 7ff9532..efa3c93 100644 --- a/R/get_info.R +++ b/R/get_info.R @@ -4,7 +4,6 @@ #' #' @param group Name of a group of datasets #' @param trait Trait identifier (can be a vector) -#' @param limit Limit on number of traits to return (if `trait` is `NULL`) #' @param url The URL for the GeneNetwork API #' #' @return A data frame @@ -13,20 +12,13 @@ #' #' @examples #' info_pheno("BXD", "10002") -#' info_pheno("HC_M2_0606_P", limit=10) #' info_pheno("HC_M2_0606_P", "1436869_at") -#' info_pheno("HXBBXH", limit=10) info_pheno <- - function(group, trait=NULL, limit=NULL, url=gnapi_url()) + function(group, trait, url=gnapi_url()) { stopifnot(length(group)==1) - if(is.null(trait) || trait == "") { - query <- paste0("traits/", group) - if(!is.null(limit)) { - query <- paste0(query, "?limit_to=", limit) - } - result <- query_gn(query, url) - return(list2df(result)) + if(is.null(trait) || (length(trait)==1 && trait == "")) { + stop("trait must be provided; can be a vector") } if(length(trait) > 1) { diff --git a/docs/GNapi.html b/docs/GNapi.html index bc9760b..051afac 100644 --- a/docs/GNapi.html +++ b/docs/GNapi.html @@ -120,13 +120,20 @@ for (var i = 0; i < sheets.length; i++) { if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue; try { var rules = sheets[i].cssRules; } catch (e) { continue; } - for (var j = 0; j < rules.length; j++) { + var j = 0; + while (j < rules.length) { var rule = rules[j]; // check if there is a div.sourceCode rule - if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue; + if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") { + j++; + continue; + } var style = rule.style.cssText; // check if color or background-color is set - if (rule.style.color === '' && rule.style.backgroundColor === '') continue; + if (rule.style.color === '' && rule.style.backgroundColor === '') { + j++; + continue; + } // replace div.sourceCode by a pre.sourceCode rule sheets[i].deleteRule(j); sheets[i].insertRule('pre.sourceCode{' + style + '}', j); @@ -384,16 +391,14 @@

Fetch individual phenotype info

Fetch trait information

-

This is mostly information about QTL location (LRS score and -marker).

-

You can get all traits within a microarray dataset, possibly limiting -the results to some number.

-
info_pheno("HC_M2_0606_P", limit=10)
-

Or you can use a group name, again possibly limiting the results to -some number.

-
info_pheno("HXBBXH", limit=10)
-

Or you can get the information for a single trait.

-
info_pheno("HC_M2_0606_P", "1436869_at")
+

This is mostly information about QTL location (LRS score and marker). +You need to provide a group and a trait, such as a probeset on a +microarray:

+
info_pheno("HC_M2_0606_P", "1436869_at")
+

Or a traditional phenotype:

+
info_pheno("BXD", "10002")
+

You can provide a vector of trait identifiers:

+
info_pheno("BXD", c("10002", "10010", "10100"))

Fetch sample data for a single trait

diff --git a/man/info_pheno.Rd b/man/info_pheno.Rd index cfa457a..3599128 100644 --- a/man/info_pheno.Rd +++ b/man/info_pheno.Rd @@ -4,15 +4,13 @@ \alias{info_pheno} \title{Get summary information about a phenotype} \usage{ -info_pheno(group, trait = NULL, limit = NULL, url = gnapi_url()) +info_pheno(group, trait, url = gnapi_url()) } \arguments{ \item{group}{Name of a group of datasets} \item{trait}{Trait identifier (can be a vector)} -\item{limit}{Limit on number of traits to return (if \code{trait} is \code{NULL})} - \item{url}{The URL for the GeneNetwork API} } \value{ @@ -23,7 +21,5 @@ Get summary information about a phenotype } \examples{ info_pheno("BXD", "10002") -info_pheno("HC_M2_0606_P", limit=10) info_pheno("HC_M2_0606_P", "1436869_at") -info_pheno("HXBBXH", limit=10) } diff --git a/vignettes/GNapi.Rmd b/vignettes/GNapi.Rmd index 178ccb4..d1879d6 100644 --- a/vignettes/GNapi.Rmd +++ b/vignettes/GNapi.Rmd @@ -105,25 +105,22 @@ list_datasets("bxd", "10001") ## Fetch trait information This is mostly information about QTL location (LRS score and marker). - -You can get all traits within a microarray dataset, possibly limiting the results -to some number. +You need to provide a group and a trait, such as a probeset on a microarray: ```r -info_pheno("HC_M2_0606_P", limit=10) +info_pheno("HC_M2_0606_P", "1436869_at") ``` -Or you can use a group name, again possibly limiting the results to -some number. +Or a traditional phenotype: ```r -info_pheno("HXBBXH", limit=10) +info_pheno("BXD", "10002") ``` -Or you can get the information for a single trait. +You can provide a vector of trait identifiers: ```r -info_pheno("HC_M2_0606_P", "1436869_at") +info_pheno("BXD", c("10002", "10010", "10100")) ``` From 130b4a263def602c36c1ed1747cb408157ae6d6f Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Mon, 26 Sep 2022 11:23:14 -0500 Subject: [PATCH 5/6] list_groups(): no longer seems to take an individual group name --- R/get_lists.R | 16 ++-------------- man/list_groups.Rd | 6 +----- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/R/get_lists.R b/R/get_lists.R index 46b1001..241b2c4 100644 --- a/R/get_lists.R +++ b/R/get_lists.R @@ -33,7 +33,6 @@ list_species <- #' Get list of available groups #' #' @param species Optional species name, for just the groups for that species. -#' @param group Optional name for a specific group #' @param url URL for GeneNetwork API #' #' @return Data frame with columns `FullName`, `Id`, `Name`, and `TaxonomyId`. @@ -45,21 +44,10 @@ list_species <- #' @examples #' list_groups() #' list_groups("barley") -#' list_groups("rat", "HSNIH-Palmer") -#' list_groups(group="HSNIH-Palmer") list_groups <- - function(species=NULL, group=NULL, url=gnapi_url()) + function(species=NULL, url=gnapi_url()) { - if(!is.null(group) && group != "") { # note this uses group/ rather than groups/ - query <- "group/" - if(!is.null(species) && species != "") { - query <- paste0(query, "/", species) - } - result <- query_gn(paste0(query, "/", group), url=url) - if(is.null(result)) return(NULL) - return(as.data.frame(result)) - } - else if(!is.null(species) && species != "") { + if(!is.null(species) && species != "") { stopifnot(length(species)==1) result <- query_gn(paste0("groups/", species), url=url) } else { diff --git a/man/list_groups.Rd b/man/list_groups.Rd index b74b843..9bd5ac4 100644 --- a/man/list_groups.Rd +++ b/man/list_groups.Rd @@ -4,13 +4,11 @@ \alias{list_groups} \title{Get list of groups} \usage{ -list_groups(species = NULL, group = NULL, url = gnapi_url()) +list_groups(species = NULL, url = gnapi_url()) } \arguments{ \item{species}{Optional species name, for just the groups for that species.} -\item{group}{Optional name for a specific group} - \item{url}{URL for GeneNetwork API} } \value{ @@ -22,8 +20,6 @@ Get list of available groups \examples{ list_groups() list_groups("barley") -list_groups("rat", "HSNIH-Palmer") -list_groups(group="HSNIH-Palmer") } \seealso{ \code{\link[=list_species]{list_species()}}, \code{\link[=list_datasets]{list_datasets()}} From 074d7bff2a508c4a58abd1531b38600222634e10 Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Mon, 26 Sep 2022 11:31:12 -0500 Subject: [PATCH 6/6] run_gemma() seems broken; adding \dontrun{ } to example --- R/run_stuff.R | 2 +- man/run_gemma.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/run_stuff.R b/R/run_stuff.R index 25fff43..49b1088 100644 --- a/R/run_stuff.R +++ b/R/run_stuff.R @@ -14,7 +14,7 @@ #' @export #' #' @examples -#' out <- run_gemma("BXDPublish", "10015") +#' \dontrun{out <- run_gemma("BXDPublish", "10015")} run_gemma <- function(dataset, trait, use_loco=FALSE, maf=0.01, url=gnapi_url()) { diff --git a/man/run_gemma.Rd b/man/run_gemma.Rd index 0dee91e..2f1c7e3 100644 --- a/man/run_gemma.Rd +++ b/man/run_gemma.Rd @@ -24,5 +24,5 @@ A data frame Perform a genome scan using gemma } \examples{ -out <- run_gemma("BXDPublish", "10015") +\dontrun{out <- run_gemma("BXDPublish", "10015")} }