You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.Rmd
+54-2Lines changed: 54 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,62 @@ date: "`r Sys.Date()`"
6
6
documentclass: book
7
7
output:
8
8
bookdown::gitbook: default
9
-
bookdown::pdf_book: default
10
9
---
11
10
12
-
# Preamble
11
+
# Overview
12
+
13
+
This book is intended to introduce users to TERRA REF data as quickly as possible.
14
+
15
+
It introduces to the wide range of phenomics datasets generated by the TERRA Reference program. Not only does TERRA REF have a large number of data sets, but many of the databases can be accessed in a number of different ways. While this makes it more complicated to learn, the goal is to provide users with the flexibility to access data in the most useful way.
16
+
17
+
## User Accounts and permission to access TERRA REF data
18
+
19
+
TODO: link to relevant parts of docs.terraref.org
20
+
21
+
## Ways of Acessing Data
22
+
23
+
* Web Interfaces
24
+
* Files
25
+
* Programming APIs
26
+
* API Clients
27
+
28
+
## Other Resources
29
+
30
+
The TERRA REF website: terraref.org
31
+
The TERRA REF Technical Documentation: docs.terraref.org
32
+
33
+
## Contents
34
+
35
+
Scope ...
36
+
37
+
Audience ...
38
+
39
+
40
+
## Pre-requisites
41
+
42
+
While we assume that readers will have some familiarity with the nature of the problem - remote sensing of crop plants - for the most part, these tutorials assume that the user will bring their own scientific questions and a sense of curiosity and are eager to learn.
43
+
44
+
Some of the lessons only require a web browser; others will assume familarity with programming at the command line in (typically only one of) Python, R, and / or SQL. You should be willing to find help (see finding help, below).
45
+
46
+
## Technical Requirements
47
+
48
+
At a minimum, you should have:
49
+
50
+
* An internet connection
51
+
* Web Browser
52
+
* A TERRA REF Beta User account
53
+
* If you have not done so, please sign up at terraref.org/beta
54
+
* Access to the data that you are using
55
+
* The tutorials will state which databases you will need access to
56
+
* Software:
57
+
* Software requirements vary with the tutorials, and may be complex
Copy file name to clipboardExpand all lines: traits/02-betydb-api-access.Rmd
+21-17Lines changed: 21 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,27 @@
1
1
# Accessing Trait Data Via the BETYdb API
2
2
3
-
## Using URLs to construct Queries
4
-
5
-
The first step toward reproducible pipelines is to automate the process of searching the database and returning results. This is one of the key roles of an Application programming interface, or 'API'. You can learn to use the API in less than 20 minutes, starting now.
3
+
This will teach you how to query trait data using a browser as well as using the command line tool `curl`. This interface is the primary way in which you can access data from the command line.
6
4
7
-
###What is an API?
5
+
## What is an API?
8
6
9
7
An API is an 'Application Programming Interface'. An API is a way that you and your software can connect to and access data.
10
8
11
9
All of our databases have web interfaces for humans to browse as well as APIs that are constructed as URLs.
12
10
11
+
## Tutorial Contents
12
+
13
+
In this tutorial, we will describe three ways to access data using:
14
+
15
+
1. A URL typed into your browser
16
+
2. The command line, or terminal
17
+
3. The R jsonlite package
18
+
19
+
We also have interfaces using R 'traits' package or the Python 'terrautils' package that return data in a more familiar and ready to analyze tabular format; these will be described later. You can skip ahead to those chapters, but this chapter will provide some insight into the methods that underlie those libraries.
20
+
21
+
## Using URLs to construct Queries
22
+
23
+
The first step toward reproducible pipelines is to automate the process of searching the database and returning results. This is one of the key roles of an Application programming interface, or 'API'. You can learn to use the API in less than 20 minutes, starting now.
24
+
13
25
14
26
### Using Your API key to Connect
15
27
@@ -27,25 +39,19 @@ Here is how to find and save your API key:
27
39
28
40
For the public key, you can call this file `.betykey_public`.
29
41
30
-
### Ways to access API data
31
-
32
-
1. Through a URL query
33
-
2. Using the bash shell
34
-
3. Using the R jsonlite package
35
42
43
+
## Accessing data using a URL query
36
44
37
-
### Accessing data using a URL query
38
45
39
-
40
-
## Components of a URL query
46
+
### Components of a URL query
41
47
42
48
* base url: `terraref.ncsa.illinois.edu/bety`
43
49
* path to the api: `/api/v1`
44
50
* api endpoint: `/search` or `traits` or `sites`. For BETYdb, these are the names of database tables.
45
51
* Query parameters: `genus=Sorghum`
46
52
* Authentication: `key=9999999999999999999999999999999999999999` is the public key for the TERRA REF traits database.
47
53
48
-
## Constructing a URL query
54
+
###Constructing a URL query
49
55
50
56
First, lets construct a query by putting together a URL.
51
57
@@ -72,9 +78,7 @@ First, lets construct a query by putting together a URL.
72
78
73
79
What do you see? Do you think that this is all of the records? What happens if you add `&limit=none`?
74
80
75
-
76
-
77
-
#### Accessing data using the Shell
81
+
## Accessing data using the Command Line Terminal
78
82
79
83
Type the following command into a bash shell (the `-o` option names the output file):
Copy file name to clipboardExpand all lines: traits/03-access-r-traits.Rmd
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
1
# Accessing Trait Data in R
2
2
3
-
## Using the R traits package to query the database
3
+
The rOpenSci traits package makes it easier to query the TERRA REF trait database because 1) you can pass the query parameters in an R function, and the package takes care of putting the parameters into a valid URL and 2) because the package returns data in a tabular format that is ready to analyze.
4
4
5
-
The rOpenSci traits package makes it easier to query the TERRA REF trait database, or any database that uses BETYdb software.
5
+
## Using the R traits package to query the database
6
6
7
-
First, make sure we have the latest version from the terraref fork of the repository on github. (you can install using the standard `install.packages('traits')` but as of Jan 2018 this version times out on very large datasets).
7
+
## Setup
8
8
9
-
### Install the traits package
9
+
Install the traits package
10
10
11
-
This is for users working on their own computer - if you are using the TERRA REF Rstudio Docker container (including on workbench) you can skip this step.
11
+
The traits package is on CRAN, and can therefore be installed using the following command:
12
12
13
13
```{r install_traits, echo = FALSE, include = FALSE}
14
-
devtools::install_github('terraref/traits')
14
+
install.packages('traits')
15
15
```
16
16
17
-
Now, we can load the packages that we will need to get started.
17
+
Load other packages that we will need to get started.
18
18
19
19
```{r 00-setup, message = FALSE}
20
20
library(traits)
@@ -24,7 +24,7 @@ theme_set(theme_bw())
24
24
library(dplyr)
25
25
```
26
26
27
-
27
+
Create a file that contains your API key. If you have signed up for access to the TERRA REF database, your API key will have been sent to you in an email. The public key will provide access to all metadata; you will need a personal key _and_ permissions to access the trait data. If you receive empty (NULL) datasets, it is likely that you do not have permissions.
28
28
29
29
```{r writing-key}
30
30
# This should be done once with the key sent to you in your email
0 commit comments