Skip to content

Commit 66a0dd2

Browse files
committed
changed chunk options and path to .betykey
1 parent 084912b commit 66a0dd2

3 files changed

Lines changed: 28 additions & 25 deletions

File tree

traits/05-maricopa-field-scanner.Rmd

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Plot level data from the field scanner in Maricopa, AZ
22

33
```{r traits-05-mac-traits-setup, include=FALSE}
4-
knitr::opts_chunk$set(echo = FALSE, cache = TRUE)
4+
knitr::opts_chunk$set(echo = FALSE, cache = FALSE)
55
library(dplyr)
66
library(tidyr)
77
library(ggplot2)
@@ -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, echo = TRUE}
26+
```{r traits-05-query-mac-sites, echo = TRUE, message = FALSE}
2727
sites <- betydb_query(
2828
table = "sites",
2929
city = "Maricopa", sitename = "~Season 2 range", limit = "none")
@@ -34,9 +34,10 @@ A more robust (but complicated way) would be to query the experiments and experi
3434
### Plot Season 2 plots
3535

3636
```{r traits-05-map-mac-polygons, echo = TRUE}
37-
site_bounds <- (sites
38-
%>% rowwise()
39-
%>% do(boundaries = readWKT(text = .$geometry, id = .$id)))
37+
38+
site_bounds <- sites %>%
39+
rowwise() %>%
40+
do(boundaries = readWKT(text = .$geometry, id = .$id))
4041
4142
site_bounds <- do.call('rbind', site_bounds$boundaries)
4243
#names(site_bounds) <- sites$sitename
@@ -54,6 +55,7 @@ leaflet() %>%
5455
```
5556

5657
```{r}
58+
5759
## Cultivars
5860
5961
```

traits/06-agronomic-metadata.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ library(rgeos)
8181
library(leaflet)
8282
year <- lubridate::year
8383
84-
options(betydb_key = readLines('traits/.betykey', warn = FALSE),
84+
options(betydb_key = readLines('.betykey', warn = FALSE),
8585
betydb_url = "https://terraref.ncsa.illinois.edu/bety/",
8686
betydb_api_version = 'v1')
8787

traits/10-simulated-sorghum.Rmd

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# A Simulated Phenotype Dataset
22

3-
```{r warnings=FALSE, echo=FALSE}
3+
```{r include = FALSE}
44
library(traits)
5-
knitr::opts_chunk$set(echo = FALSE, cache = TRUE)
5+
knitr::opts_chunk$set(echo = FALSE, cache =FALSE)
66
library(ggplot2)
77
library(ggthemes)
88
library(GGally)
@@ -145,7 +145,7 @@ ggplot(sorghum_sla) +
145145

146146
## Your turn: query the list of available traits from the variables table
147147

148-
```{r query-traits}
148+
```{r query-traits, message = FALSE}
149149
150150
151151
trait_list <- c("Vcmax", "c2n_leaf", "cuticular_cond", "SLA", "quantum_efficiency", "leaf_respiration_rate_m2", "stomatal_slope.BB", "Jmax", "chi_leaf", "extinction_coefficient_diffuse")
@@ -164,7 +164,7 @@ knitr::kable(variables %>%
164164

165165
These traits are not time series, each of the ~500 genotypes is associated with a single value for each trait. This is different from the time series of LAI that we saw in the previous exercise or the biomass data that we will look at below.
166166

167-
```{r}
167+
```{r traits-sel, message = FALSE}
168168
169169
traits_list <- list()
170170
for(trait in trait_list){
@@ -202,7 +202,7 @@ knitr::kable(variables %>%
202202
select(name, description, units))
203203
```
204204

205-
```{r all_sorghum, cache=TRUE}
205+
```{r all_sorghum, cache = TRUE, results = 'hide'}
206206
207207
208208
site_id <- betydb_query(table = 'sites', sitename = "Central IL Plot D")$id
@@ -224,24 +224,24 @@ for(t in c('canopy_height', 'stem_biomass', 'LAI', 'NDVI')){
224224
225225
```
226226

227-
```
228227

229228
This is how you can query a time series of sorghum height data for the Northern IL site.
230229

231-
```{r query-sorghum-height}
232-
sorghum_height <- betydb_query(table = 'search',
233-
trait = 'canopy_height',
234-
year = 1022,
235-
site = "~Northern IL",
236-
limit = 'none')
237-
#save(sorghum_height, file = 'data/sorghum_height.RData')
230+
```{r query-sorghum-height, echo = TRUE}
231+
#sorghum_height <- betydb_query(table = 'search',
232+
# trait = 'canopy_height',
233+
# year = 1022,
234+
# site = "~Northern IL",
235+
# limit = 'none')
236+
237+
#save(sorghum_height, file = 'traits/sorghum_height.RData')
238238
```
239239

240240
However, with almost 200k rows it currently takes 40 minutes to query (this is a limitation of the API). For the purposes of this tutorial, we will use a cached copy of the dataset.
241241

242242

243-
```{r}
244-
#load('data/sorghum_height.RData')
243+
```{r 10-sim-sorg-plot, message = FALSE}
244+
load('traits/sorghum_height.RData')
245245
246246
s <- sorghum_height %>%
247247
mutate(day = lubridate::yday(raw_date),
@@ -267,7 +267,7 @@ Now lets look at a 'pairs' plot to see if there is any covariance among the trai
267267

268268
First, lets rearrange the data from 'long' to 'wide' format. We will also take this chance to rename the 'cultivar' field to 'genotype'.
269269

270-
```{r}
270+
```{r 10_traits_wide, echo = TRUE}
271271
272272
traits_wide <- traits %>%
273273
select(genotype = cultivar, trait, mean) %>%
@@ -277,7 +277,7 @@ traits_wide <- traits %>%
277277

278278
Now, lets create a variable called `max_height`
279279

280-
```{r max_height}
280+
```{r max_height, echo = TRUE}
281281
# create the variable max height
282282
max_height <- s %>%
283283
group_by(genotype) %>%
@@ -287,13 +287,14 @@ max_height <- s %>%
287287

288288
Now, join the traits data frame with the new max_height data frame trait data we will merge the two data frames on the `genotype` field.
289289

290-
```{r join_traits_height}
290+
```{r join_traits_height, echo = TRUE, warning = FALSE}
291+
291292
traits_height <- traits_wide %>% left_join(max_height, by = 'genotype')
292293
293294
```
294295
Which traits are related to height? We can discover this in a few way, for example, a pairs plot that shows correltations:
295296

296-
```{r trait_pairs, fig.height = 8, fig.width = 8}
297+
```{r trait_pairs, fig.height = 8, fig.width = 8, warning = FALSE}
297298
ggpairs(traits_height %>% select(-genotype),
298299
lower = list(continuous = 'density'),
299300
upper = list(continuous = 'cor'),

0 commit comments

Comments
 (0)