Skip to content

Commit

Permalink
Fix bug in info_pheno() - can no longer get list of traits within group
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroman committed Sep 26, 2022
1 parent 77d88db commit 05a2a1d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 39 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 3 additions & 11 deletions R/get_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
31 changes: 18 additions & 13 deletions docs/GNapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -384,16 +391,14 @@ <h3>Fetch individual phenotype info</h3>
</div>
<div id="fetch-trait-information" class="section level2">
<h2>Fetch trait information</h2>
<p>This is mostly information about QTL location (LRS score and
marker).</p>
<p>You can get all traits within a microarray dataset, possibly limiting
the results to some number.</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="fu">info_pheno</span>(<span class="st">&quot;HC_M2_0606_P&quot;</span>, <span class="at">limit=</span><span class="dv">10</span>)</span></code></pre></div>
<p>Or you can use a group name, again possibly limiting the results to
some number.</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="fu">info_pheno</span>(<span class="st">&quot;HXBBXH&quot;</span>, <span class="at">limit=</span><span class="dv">10</span>)</span></code></pre></div>
<p>Or you can get the information for a single trait.</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="fu">info_pheno</span>(<span class="st">&quot;HC_M2_0606_P&quot;</span>, <span class="st">&quot;1436869_at&quot;</span>)</span></code></pre></div>
<p>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:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="fu">info_pheno</span>(<span class="st">&quot;HC_M2_0606_P&quot;</span>, <span class="st">&quot;1436869_at&quot;</span>)</span></code></pre></div>
<p>Or a traditional phenotype:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="fu">info_pheno</span>(<span class="st">&quot;BXD&quot;</span>, <span class="st">&quot;10002&quot;</span>)</span></code></pre></div>
<p>You can provide a vector of trait identifiers:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="fu">info_pheno</span>(<span class="st">&quot;BXD&quot;</span>, <span class="fu">c</span>(<span class="st">&quot;10002&quot;</span>, <span class="st">&quot;10010&quot;</span>, <span class="st">&quot;10100&quot;</span>))</span></code></pre></div>
</div>
<div id="fetch-sample-data-for-a-single-trait" class="section level2">
<h2>Fetch sample data for a single trait</h2>
Expand Down
6 changes: 1 addition & 5 deletions man/info_pheno.Rd

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

15 changes: 6 additions & 9 deletions vignettes/GNapi.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
```


Expand Down

0 comments on commit 05a2a1d

Please sign in to comment.