Skip to content

Commit 76b631f

Browse files
committed
Merge branch 'traits_tutorials' of github.com:terraref/tutorials into traits_tutorials
2 parents 739a691 + 05155fb commit 76b631f

6 files changed

Lines changed: 41 additions & 29 deletions

_bookdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ language:
55
chapter_name: "Chapter "
66
rmd_files: ["index.Rmd", "traits/00-BETYdb-getting-started.Rmd", "traits/01-web-access.Rmd",
77
"traits/02-betydb-api-access.Rmd", "traits/03-access-r-traits.Rmd", "traits/04-danforth-indoor-phenotyping-facility.Rmd",
8-
"traits/05-maricopa-field-scanner.Rmd", "traits/06-agronomic-metadata.Rmd", "traits/07-betydb-sql-access.Rmd"]#, "10-simulated-sorghum.Rmd"
8+
"traits/06-agronomic-metadata.Rmd", "traits/07-betydb-sql-access.Rmd", "traits/10-simulated-sorghum.Rmd"]#, "10-simulated-sorghum.Rmd"
99

index.Rmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ output:
88
bookdown::gitbook: default
99
---
1010

11-
# Section 1: Traits {-}
1211

1312
# Overview
1413

traits/00-BETYdb-getting-started.Rmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# (PART\*) Secton 1: Traits {-}
2+
13
# Getting Started with BETYdb
24

35
## TERRA Ref Trait Database

traits/03-access-r-traits.Rmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Install the traits package
1010

1111
The traits package is on CRAN, and can therefore be installed using the following command:
1212

13-
```{r install_traits, echo = FALSE, include = FALSE}
14-
install.packages('traits')
13+
```{r install_traits, echo = TRUE, message = FALSE}
14+
install.packages('traits', repos = 'http://cran.rstudio.com/')
1515
```
1616

1717
Load other packages that we will need to get started.
1818

19-
```{r 00-setup, message = FALSE}
19+
```{r 00-setup, message = FALSE, echo = TRUE}
2020
library(traits)
2121
library(ggplot2)
2222
library(ggthemes)
@@ -26,14 +26,14 @@ library(dplyr)
2626

2727
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.
2828

29-
```{r writing-key}
29+
```{r writing-key, echo = TRUE}
3030
# This should be done once with the key sent to you in your email
3131
# writeLines('abcdefg_rest_of_key_sent_in_email',
3232
# con = '.betykey')
3333
3434
# Example with the public key:
3535
writeLines('9999999999999999999999999999999999999999',
36-
con = '.betykey_public')
36+
con = 'traits/.betykey_public')
3737
```
3838

3939
#### R - using the traits package
@@ -69,7 +69,7 @@ options(betydb_key = readLines('traits/.betykey', warn = FALSE),
6969

7070
Now the same query can be reduced to:
7171

72-
```{r query-species-reduce, echo = TRUE}
72+
```{r query-species-reduce, echo = TRUE, results = FALSE}
7373
sorghum_info <- betydb_query(table = 'species',
7474
genus = "Sorghum",
7575
limit = 'none')

traits/04-danforth-indoor-phenotyping-facility.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ options(betydb_key = readLines('traits/.betykey', warn = FALSE),
2929

3030
First we will use the generic search to query the output from the Lemnatec indoor phenotyping system at the Danforth Center in St. Louis, MO.
3131

32-
```{r query-danforth, results='hide'}
32+
```{r query-danforth, message = FALSE}
3333
danforth_sorghum <- traits::betydb_query(
3434
# sitename = 'Danforth Plant Science Center Bellweather Phenotyping Facility',
3535
trait = 'sv_area',

traits/05-maricopa-field-scanner.Rmd

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ options(betydb_key = readLines('.betykey', warn = FALSE),
2323

2424
First, query the plots for Season 2. The simple way to use this is based on the fact that the plot names at Maricopa contain the season.
2525

26-
```{r traits-05-query-mac-sites}
26+
```{r traits-05-query-mac-sites, echo = TRUE}
2727
sites <- betydb_query(
2828
table = "sites",
2929
city = "Maricopa", sitename = "~Season 2 range", limit = "none")
@@ -33,10 +33,10 @@ A more robust (but complicated way) would be to query the experiments and experi
3333

3434
### Plot Season 2 plots
3535

36-
```{r traits-05-map-mac-polygons}
36+
```{r traits-05-map-mac-polygons, echo = TRUE}
3737
site_bounds <- (sites
38-
%>% rowwise()
39-
%>% do(boundaries = readWKT(text = .$geometry, id = .$id)))
38+
%>% rowwise()
39+
%>% do(boundaries = readWKT(text = .$geometry, id = .$id)))
4040
4141
site_bounds <- do.call('rbind', site_bounds$boundaries)
4242
#names(site_bounds) <- sites$sitename
@@ -53,35 +53,46 @@ leaflet() %>%
5353
addPolygons(data=site_bounds, popup = sites$sitename)
5454
```
5555

56+
```{r}
5657
## Cultivars
5758
59+
```
5860

5961
```{r traits-05-mac-cultivars}
60-
cultivars <- betydb_query(
61-
table = "cultivars", limit = "none") %>%
62-
rename(cultivar_id = id)
63-
64-
traits <- traits <- betydb_search(
65-
Season = "~Season 4",
66-
include_unchecked = 'true',
67-
limit = "none") %>%
68-
rename(trait_id = id)
62+
#cultivars <- betydb_query(
63+
# table = "cultivars", limit = "none") %>%
64+
# rename(cultivar_id = id)
65+
66+
67+
# getting HTTP 504 - Gateway timeout
68+
# comment this chunk out
69+
#traits <- traits <- betydb_search(
70+
# Season = "~Season 4",
71+
# include_unchecked = 'true',
72+
# limit = "none") %>%
73+
# rename(trait_id = id)
6974
```
7075

71-
76+
```{r}
7277
## Time series of canopy cover, height, NDVI
7378
74-
First look up variables by name. Let's look for measurements related to canopy size:
79+
#First look up variables by name. Let's look for measurements related to canopy size:
80+
81+
```
7582

7683
```{r traits-05-height-cover-ndvi}
77-
variables <- betydb_query(
78-
table = "variables", name = "~^(NDVI|canopy_height|canopy_cover|)$")
84+
#variables <- betydb_query(
85+
# table = "variables", name = "~^(NDVI|canopy_height|canopy_cover|)$")
7986
80-
variables %>%
81-
select(id, name, units, n_records = `number of associated traits`)
87+
#variables %>%
88+
# select(id, name, units, n_records = `number of associated traits`)
8289
```
8390

84-
Exercise: Why are there two variables named canopy_height, and what database fields should you examine to decide which one you want?
91+
```{r}
92+
93+
#Exercise: Why are there two variables named canopy_height, and what database fields should you examine to decide which one you want?
94+
95+
```
8596

8697
```{r traits-05-get-variables-comment}
8798

0 commit comments

Comments
 (0)