-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME.Rmd
More file actions
123 lines (98 loc) · 3.96 KB
/
Copy pathREADME.Rmd
File metadata and controls
123 lines (98 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "75%"
)
```
# statgenSTA
[](https://www.r-pkg.org/pkg/statgenSTA)
[](https://www.r-pkg.org/pkg/statgenSTA)
[](https://github.com/Biometris/statgenSTA/actions?workflow=R-CMD-check)
[](https://app.codecov.io/gh/Biometris/statgenSTA)
**statgenSTA** is an R package providing functions for phenotypic analysis of agricultural field trials using mixed models with and without spatial components.
Analysis can be done using one of the R packages **SpATS**, **lme4** or **asreml**. For the latter a license is required which can be obtained upon purchase from [VSNi](<https://vsni.co.uk/software/asreml-r/>).
statgenSTA has extensive options for summarizing and visualizing both the raw data and the fitted models. The example below shows a selection of what is possible. For a full overview of all options it is best to read the [**vignette**](https://biometris.github.io/statgenSTA/articles/statgenSTA.html)
## Installation
* Install from CRAN:
```{r, eval = FALSE}
install.packages("statgenSTA")
```
* Install latest development version from GitHub (requires [remotes](https://github.com/r-lib/remotes) package):
```{r, eval = FALSE}
remotes::install_github("Biometris/statgenSTA", ref = "develop", dependencies = TRUE)
```
## Examples
Example using the phenotypic data for a wheat trial in Chile. The same data is used in the vignette and described there in detail.
First get the data in the form required by the package, converting it to an object of class **T(rial)D(ata)**.
```{r createTD}
library(statgenSTA)
data(dropsRaw)
dropsTD <- createTD(data = dropsRaw,
genotype = "Variety_ID",
trial = "Experiment",
loc = "Site",
repId = "Replicate",
subBlock = "block",
rowCoord = "Row",
colCoord = "Column",
trLat = "Lat",
trLong = "Long")
```
Some plots to get a first idea of the contents of the data.
```{r layoutPlot}
## Plot the layout for Gai12W.
## Highlight genotypes A3 and 11430 in red and blue.
plot(dropsTD,
trials = "Gai12W",
highlight = c("A3", "11430"),
colHighlight = c("red", "blue"))
```
```{r mapPlot}
## Plot the locations of the trials on a map.
## Color the trials by water scenario.
plot(dropsTD,
plotType = "map",
colorTrialBy = "scenarioWater",
colTrial = c("red", "darkgreen"))
```
```{r boxPlot}
## Create a boxplot for grain yield.
plot(dropsTD,
plotType = "box",
traits = "grain.yield")
```
```{r scatterPlot}
## Create a scatter plot matrix for grain yield.
## Color trials by scenario and genotypes by family.
plot(dropsTD,
plotType = "scatter",
traits = "grain.yield",
colorTrialBy = "scenarioFull",
colorGenoBy = "geneticGroup")
```
Fit mixed models for one of the trials, Gai12W, and visualize the output.
```{r fitMod}
## Fit a single trial model using a model based on a resolvable row column design.
modDropsSp <- fitTD(TD = dropsTD,
trials = "Gai12W",
traits = "grain.yield",
design = "res.rowcol")
```
```{r basePlot}
## Spatial plot for the model with genotype fitted as fixed effect.
plot(modDropsSp,
plotType = "spatial")
```
```{r spatialPlot}
## Spatial plot for the model with genotype fitted as fixed effect.
## Display the spatial trend as a percentage.
plot(modDropsSp,
plotType = "spatial",
spaTrend = "percentage")
```