Skip to content

Commit fe9151e

Browse files
committed
updated simulated sorghum and danforth tutorials
1 parent 76324af commit fe9151e

5 files changed

Lines changed: 83 additions & 27 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Tutorials
23

34
## An introduction to the use of TERRA REF data and software

traits/00-BETYdb-getting-started.Rmd

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ date: "`r Sys.Date()`"
55
output: html_document
66
---
77

8-
```{r setup}
9-
library(traits)
10-
knitr::opts_chunk$set(echo = FALSE, cache = TRUE)
11-
library(ggplot2)
12-
library(ggthemes)
13-
library(GGally)
14-
theme_set(theme_bw())
15-
library(dplyr)
16-
```
17-
18-
198
## TERRA Ref Trait Database
209

2110
The TERRA Ref program uses the BETYdb database and web application software to store plant and plot level trait data.
@@ -104,21 +93,72 @@ First, lets construct a query by putting together a URL.
10493
10594
What do you see? Do you think that this is all of the records? What happens if you add `&limit=none`?
10695

107-
### Using the R traits package to query the database
96+
## Using the R traits package to query the database
10897

10998
The rOpenSci traits package makes it easier to query the TERRA REF trait database, or any database that uses BETYdb software.
11099

100+
First, make sure we have the latest version
101+
102+
```{r install_traits, echo=FALSE}
103+
if(packageVersion("traits") == '0.2.0'){
104+
devtools::install_github('ropensci/traits')
105+
}
106+
```
107+
108+
109+
```{r setup}
110+
library(traits)
111+
knitr::opts_chunk$set(echo = FALSE, cache = TRUE)
112+
library(ggplot2)
113+
library(ggthemes)
114+
theme_set(theme_bw())
115+
library(dplyr)
116+
```
117+
118+
119+
120+
```{r writing-key}
121+
# This should be done once with the key sent to you in your email
122+
# writeLines('abcdefg_rest_of_key_sent_in_email',
123+
# con = '~/.betykey')
124+
125+
# Example with the public key:
126+
writeLines('9999999999999999999999999999999999999999',
127+
con = '~/.betykey_public')
128+
```
111129
```{r traits}
130+
terraref_test_url <- "https://terraref.ncsa.illinois.edu/bety-test/"
131+
132+
betykey <- readLines('~/.betykey_public', warn = FALSE)
112133
113-
terraref_betyurl <- "https://terraref.ncsa.illinois.edu/bety/"
114-
betykey <- readLines('~/.betykey', warn = FALSE)
115134
```
116135

117-
```{r}
118-
sorghum_all <- betydb_search(query = 'Sorghum',
119-
betyurl = terraref_betyurl,
120-
key = betykey)
136+
```{r simulated-LAI}
137+
sorghum_lai <- betydb_query(table = 'search',
138+
trait = "LAI",
139+
api_version = 'beta',
140+
limit = 5000,
141+
betyurl = terraref_test_url,
142+
key = betykey)
143+
144+
#traits <- betydb_query(table = "traits",
145+
# api_version = 'beta',
146+
# limit = 5000,
147+
# betyurl = terraref_test_url,
148+
# key = betykey)
149+
150+
121151
122152
```
123153

154+
```{r}
155+
156+
ggplot(data = sorghum_lai) +
157+
geom_smooth(aes(x = lubridate::yday(lubridate::ymd_hms(raw_date)), y = mean, color = as.factor(lubridate::year(lubridate::ymd_hms(raw_date)))), span = 0.5) +
158+
# scale_x_datetime(date_breaks = '6 months', date_labels = "%b %Y") +
159+
ylim(c(0,6)) +
160+
ylab("Day of Year") + xlab("Leaf Area Index") +
161+
labs(color='Year')
162+
163+
```
124164

traits/01-simulated-sorghum.Rmd

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
---
1+
<!---
22
title: "Can high throughput phenotyping produce data like this?"
33
author: "David LeBauer"
4-
date: "February 1, 2015"
4+
date: "`r Sys.Date()`"
55
output: html_document
66
---
7+
-->
8+
9+
# A Simulated Phenotype Dataset
710

8-
```{r setup}
11+
```{r}
912
library(traits)
1013
knitr::opts_chunk$set(echo = FALSE, cache = TRUE)
1114
library(ggplot2)
1215
library(ggthemes)
13-
library(GGally)
1416
theme_set(theme_bw())
1517
library(dplyr)
1618
```
@@ -143,10 +145,11 @@ terraref_test_url <- "https://terraref.ncsa.illinois.edu/bety-test/"
143145
144146
public_key <- "9999999999999999999999999999999999999999"
145147
146-
traits <- c("Vcmax", "c2n_leaf", "cuticular_cond", "SLA", "quantum_efficiency", "leaf_respiration_rate_m2", "stomatal_slope.BB", "Jmax", "chi_leaf", "extinction_coefficient_diffuse")
147148
148-
149-
SLA <- (betydb_search(query = "SLA", betyurl = terraref_test_url, key = public_key, api_version = "beta")
149+
SLA <- (betydb_search(query = "SLA",
150+
betyurl = terraref_test_url,
151+
key = public_key,
152+
api_version = "beta")
150153
%>% filter(scientificname == 'Sorghum bicolor'))
151154
152155
```
@@ -165,7 +168,12 @@ ggplot(SLA) +
165168
```{r query-traits}
166169
167170
168-
traits <- betydb_search("SLA Vcmax", betyurl = terraref_test_url, key = public_key)
171+
trait_list <- c("Vcmax", "c2n_leaf", "cuticular_cond", "SLA", "quantum_efficiency", "leaf_respiration_rate_m2", "stomatal_slope.BB", "Jmax", "chi_leaf", "extinction_coefficient_diffuse")
172+
173+
trait_data <- betydb_search(paste(trait_list, collapse = " "),
174+
betyurl = terraref_test_url,
175+
key = public_key,
176+
limit = 'none')
169177
170178
```
171179

@@ -179,7 +187,7 @@ traits <- betydb_search("SLA Vcmax", betyurl = terraref_test_url, key = public_
179187
```
180188

181189

182-
```{r}
190+
```{r eval=FALSE}
183191
library(data.table)
184192
library(dplyr)
185193

traits/02-danforth-phenotyping-facility.Rmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ library(dplyr)
1212
library(ggplot2)
1313
library(ggthemes)
1414
theme_set(theme_bw())
15+
16+
if(packageVersion("traits") == '0.2.0'){
17+
devtools::install_github('ropensci/traits')
18+
}
19+
1520
library(traits)
1621
```
1722

tutorials.Rproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Encoding: UTF-8
1111

1212
RnwWeave: Sweave
1313
LaTeX: pdfLaTeX
14+
15+
BuildType: Website

0 commit comments

Comments
 (0)