-
Notifications
You must be signed in to change notification settings - Fork 11
[WIP] first draft of a brapi tutorial #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dlebauer
wants to merge
1
commit into
master
Choose a base branch
from
brapi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
title: "Accessing TERRA REF data using the brapi R package" | ||
author: "Reinhard Simon" | ||
author: "David LeBauer" | ||
date: "`r Sys.Date()`" | ||
output: rmarkdown::html_vignette | ||
--- | ||
|
||
# Objective | ||
|
||
Here demonstrate the use of the brapi R package to query data from the TERRA REF traits database (terraref.org/bety) using the Breeder's API (BrAPI). | ||
|
||
What is BrAPI? | ||
|
||
Data are public and no login credentials are needed. | ||
|
||
```{r, message=TRUE, warning=TRUE} | ||
# devtools::install_github('dlebauer/brapi@') | ||
devtools::install_github('CIP-RIU/brapi') | ||
library(brapi) | ||
#terraref <- ba_db()$terraref | ||
|
||
terraref <- structure(list(secure = TRUE, protocol = "https://", db = "brapi.workbench.terraref.org", | ||
port = 80, apipath = NULL, multicrop = TRUE, crop = c("sorghum", | ||
"wheat"), user = "", password = "", token = "", granttype = "password", | ||
clientid = "rbrapi", bms = FALSE, version = "v1", crops = "", | ||
calls = ""), class = c("list", "ba_db", "ba", "ba_con")) | ||
|
||
terraref$db <- gsub('brapi', 'brapi-dev', terraref$db) | ||
|
||
#terraref$db <- 'localhost:5000' | ||
# show verbose server feedback | ||
print(ba_calls(terraref) | ||
ba_studies_details(terraref, '6000000034') | ||
print(z) | ||
``` | ||
|
||
## Listing available calls | ||
|
||
The BrAPI specification does not require all endpoints to be implemented, and TERRA REF provides a subset of endpoints focused on genotypes, experimental metadata, and phenotypes. The `ba_calls()` function lists the functionality supported by the server. | ||
|
||
```{r} | ||
ba_calls(terraref) | ||
``` | ||
|
||
## Function Arguments | ||
|
||
* `con`: Always the first argument, provides database connection information as a list. To query terraref, we will use `con = terraref`, which we returned above from `ba_db()$terraref` (try `print(ba_db())` to see some of the other crop databases that you can query). | ||
* `rclass`: the last argument is always the class of object returned. The default type is a 'tibble', althought you can also request `data.frame`, `json`, or `list`. | ||
* Other parameters are of class 'character'. Exceptions are: the con parameter is always a list; the parameters 'page' and 'pageSize' if applicable are integers. For details see individual functions. | ||
|
||
## Getting phenotypic data | ||
|
||
The brapi models trial data in a three layer hierarchy: a) breeding program which has b) trials that c) may consist of one or more studies at one or more locations. A study at one location is also often referred to as a fieldbook. | ||
|
||
### Which breeding programs are there? | ||
|
||
```{r} | ||
ba_crops(terraref) | ||
``` | ||
|
||
|
||
### Which studies are there? | ||
|
||
```{r} | ||
ba_studies_search(terraref, programDbId = "140") | ||
``` | ||
|
||
### Get a study (or fieldbook) | ||
|
||
```{r, message=FALSE, warning=FALSE} | ||
# Currently not working!!! | ||
#dt = ba_studies_table(terraref, | ||
# studyDbId = "fixme") | ||
``` | ||
|
||
```{r, echo=FALSE} | ||
#library(DT) | ||
#datatable( | ||
# dt, | ||
# options=list(pageLength = 5, scrollX = TRUE) | ||
# ) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waiting on this to be added to the package