-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path03_interacao.qmd
More file actions
212 lines (152 loc) · 4.06 KB
/
Copy path03_interacao.qmd
File metadata and controls
212 lines (152 loc) · 4.06 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
---
title: "03: Adaptabilidade e estabilidade de genótipos experimentais de linhaça cultivados em ambientes contrastantes de Santa Catarina"
---
```{r global_options, include = FALSE}
knitr::opts_chunk$set(cache = FALSE,
comment = "##",
collapse = TRUE,
warning = FALSE,
message = FALSE)
```
# Pacotes
```{r warning=FALSE, message=FALSE}
library(rio)
library(tidyverse)
library(metan)
library(ggridges)
library(ggthemes)
library(patchwork)
df <- import_list("data/progresso.xlsx")
g2022 <- df$`2022` |> select(GEN, RGPLA) |> rename(A2022 = RGPLA)
g2023 <- df$`2023` |> select(GEN, RGPLA) |> rename(A2023 = RGPLA)
g2024 <- df$`2024` |> select(GEN, RGPLA) |> rename(A2024 = RGPLA)
dfge <-
reduce(list(g2024, g2023, g2022), left_join) |>
remove_rows_na()
df_ggplot <-
dfge |>
pivot_longer(-GEN, names_to = "AMB", values_to = "RGPLA")
```
# Exploração
```{r}
p0 <- ge_plot(df_ggplot, AMB, GEN, RGPLA)
```
# Interação genótipo ambiente
$$
y_{ij} = m + g_i + a_j + (ga)_{ij}
$$
$$
\hat{g_i} = \bar{g_i} - m \\
\hat{a_j} = \bar{a_j} - m
$$
$$
\hat{(ga)_{ij}} = y_{ij} - m - \hat{g_i} - \hat{a_j} \\
\hat{(ga)_{ij}} = y_{ij} - \bar{g_i} - \bar{a_j} + m
$$
```{r}
gemat <-
dfge |>
column_to_rownames("GEN") |>
as.matrix()
m <- mean(gemat)
geef <- matrix(NA, nrow = nrow(gemat), ncol = ncol(gemat))
rownames(geef) <- rownames(gemat)
colnames(geef) <- colnames(gemat)
for(j in 1:ncol(geef)){
for(i in 1:nrow(geef)){
mg1 <- mean(gemat[i, ])
ma1 <- mean(gemat[, j])
# Calcular efeitos
efg1 <- mg1 - m
efa1 <- ma1 - m
geef[i, j] <- gemat[i, j] - m - efg1 - efa1
}
}
heatmap(geef)
geef |>
as.data.frame() |>
rownames_to_column("GEN") |>
pivot_longer(-GEN) |>
ge_plot(name, GEN, value)
```
# Análise AMMI
$$
y_{ij} = m + g_i + a_j + \sum_{i=1}^{k}{\lambda_k\tau_{ik}\omega_{jk}}
$$
```{r}
# Decomposição por valor singular
s <- svd(geef)
d <- s$d[1:2]
u <- s$u[, 1:2]
v <- s$v[, 1:2]
# retorna a matriz dos efeitos da interação
u %*% diag(d) %*% t(v)
# escores dos genótipos
escoregen <-
u %*% sqrt(diag(d)) |>
as.data.frame() |>
mutate(code = rownames(geef),
tipo = "gen") |>
rename(IPCA1 = V1, IPCA2 = V2)
# escores dos ambientes
escoreamb <- v %*% sqrt(diag(d)) |>
as.data.frame() |>
mutate(code = colnames(geef),
tipo = "amb") |>
rename(IPCA1 = V1, IPCA2 = V2)
dfplot <- bind_rows(escoregen, escoreamb)
library(ggrepel)
p1 <-
ggplot(dfplot, aes(IPCA1, IPCA2, color = tipo)) +
geom_vline(xintercept = 0) +
geom_hline(yintercept = 0) +
geom_text_repel(aes(label = code)) +
geom_point() +
theme_minimal() +
geom_segment(aes(x = 0, y = 0,
xend = IPCA1,
yend = IPCA2),
data = dfplot |> filter(tipo == "amb"),
arrow = arrow(length = unit(0.1, "inches")))
p0 + p1
```
# Adaptabilidade
## Método WAAS
OLIVOTO, T. et al. Mean Performance and Stability in Multi‐Environment Trials I: Combining Features of AMMI and BLUP Techniques. Agronomy Journal, v. 111, n. 6, p. 2949–2960, 2019.
```{r}
explicacao <- d^2 / sum(d^2)
dfplot
## WAAS G1
(0.296928317 * 0.7554673) + (0.12003188 * 0.2445327)
# computar as médias dos genótipos e ambientes
mg <-
df_ggplot |>
group_by(GEN) |>
summarise(RGPLA = mean(RGPLA)) |>
rename(code = GEN)
ma <-
df_ggplot |>
group_by(AMB) |>
summarise(RGPLA = mean(RGPLA)) |>
rename(code = AMB)
waas <-
dfplot |>
rowwise() |>
mutate(WAAS = weighted.mean(abs(c_across(IPCA1:IPCA2)), w = explicacao)) |>
left_join(bind_rows(mg, ma))
# média versus estabilidade
ggplot(waas, aes(RGPLA, WAAS, color = tipo)) +
geom_point() +
geom_hline(aes(yintercept = mean(WAAS))) +
geom_vline(aes(xintercept = mean(RGPLA))) +
geom_text_repel(aes(label = code))
```
# Estabilidade
## Método Wricke
WRICKE, G. Zur Berechnung der Ökovalenz bei Sommerweizen und Hafer. Zeitschrift für Pflanzenzüchtung, v.52, p.127-138, 1965.
```{r}
```
# Section info
```{r}
sessionInfo()
```