Skip to content

Commit

Permalink
info_pheno(): add limit(), allow use for dataset without specific trait
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroman committed Jun 10, 2019
1 parent 7af9473 commit d9cc032
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
- Remove `info_dataset()` and `info_datasets()`; for both can be just
use `list_datasets()`.

- Include `limit` argument for `info_pheno()`.

### Bug fixes

- `list_groups()` was messed up when a species was provided.
Expand Down
15 changes: 14 additions & 1 deletion R/get_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#'
#' @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 @@ -12,10 +13,22 @@
#'
#' @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, url=gnapi_url())
function(group, trait=NULL, limit=NULL, 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(length(trait) > 1) {
result <- lapply(trait, function(trt) info_pheno(group, trait=trt, url=url))
return(do.call("rbind_expand", result))
Expand Down
10 changes: 10 additions & 0 deletions docs/GNapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ <h3>Fetch individual phenotype info</h3>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">list_datasets</span>(<span class="st">&quot;bxd&quot;</span>, <span class="st">&quot;10001&quot;</span>)</code></pre></div>
</div>
</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"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">info_pheno</span>(<span class="st">&quot;HC_M2_0606_P&quot;</span>, <span class="dt">limit=</span><span class="dv">10</span>)</code></pre></div>
<p>Or you can use a group name, again possibly limiting the results to some number.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">info_pheno</span>(<span class="st">&quot;HXBBXH&quot;</span>, <span class="dt">limit=</span><span class="dv">10</span>)</code></pre></div>
<p>Or you can get the information for a single trait.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">info_pheno</span>(<span class="st">&quot;HC_M2_0606_P&quot;</span>, <span class="st">&quot;1436869_at&quot;</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>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">ph &lt;-<span class="st"> </span><span class="kw">get_pheno</span>(<span class="st">&quot;HC_M2_0606_P&quot;</span>, <span class="st">&quot;1436869_at&quot;</span>)</code></pre></div>
Expand Down
7 changes: 6 additions & 1 deletion man/info_pheno.Rd

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

25 changes: 25 additions & 0 deletions vignettes/GNapi.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,31 @@ list_datasets("bxd", "HC_M2_0606_P")
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.

```r
info_pheno("HC_M2_0606_P", limit=10)
```

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

```r
info_pheno("HXBBXH", limit=10)
```

Or you can get the information for a single trait.

```r
info_pheno("HC_M2_0606_P", "1436869_at")
```


## Fetch sample data for a single trait

```r
Expand Down

0 comments on commit d9cc032

Please sign in to comment.