-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME.Rmd
More file actions
258 lines (187 loc) · 7.63 KB
/
README.Rmd
File metadata and controls
258 lines (187 loc) · 7.63 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
---
output: github_document
---
<p align="center">
<a href="https://github.com/frahik/GFR">
<img src="Logo.png" alt="Genomic Functional Regression Logo"/>
</a>
<h3 align="center">
Genomic Functional Regression analysis in R | Development version `r packageVersion('GFR')`
</h4>
<p align="center">
<a href="https://www.gnu.org/licenses/lgpl-3.0">
<img src="https://img.shields.io/badge/License-LGPL%20v3-blue.svg" alt="LGPL, Version 3.0">
</a> <a href="http://www.repostatus.org/#wip">
<img src="http://www.repostatus.org/badges/latest/wip.svg" alt="Status of the Repo: Initial development is in progress, but there has not yet been a stable, usable release suitable for the public">
</a> <a href="">
<img src="http://cranlogs.r-pkg.org/badges/GFR" alt="Dowloads from the CRAN">
</a> <a href="https://cran.r-project.org/package=GFR">
<img src="http://www.r-pkg.org/badges/version-ago/GFR" alt="CRAN">
</a>
</p>
<h4 align="center">
[Last README update: `r format(Sys.Date())`]
</h4>
</p>
----------
# Table of contents
- [NEWS](#news)
- [Instructions](#instructions)
- [Installation](#install)
- [Demostration examples](#demo)
- [Web version](#shinyapp)
- [Available data](#data)
- [Fitting a model](#fit-model)
- [Predictive model](#predictive-model)
- [Example #1 of how generate automatically a linear predictor](#auto-ETA)
- [Example #2 of how generate automatically a linear predictor](#auto-ETA2)
- [Example of how generate manually a linear predictor](#HM-ETA)
- [How to cite this package](#cite)
- [Contributions](#contributions)
- [Authors](#authors)
<h2 id="news">
News of this version (`r packageVersion('GFR')`)
</h2>
Revision 13
- The BFR function now can obtain the PCC (Percentage of Correct Classification) to the Ordinal or binary data (`BFR(..., response_type = 'ordinal')`).
- `forceClean` parameter from `cleanDat()` has changed to `noConfirm`.
Revision 12
- The package includes a better BFR shiny app (use `runBFRInterface()` ).
Revision 10
- The package now inclues a shiny app.
Past revisions
- Rename from BGFRA -> BFR -> GFR
- Initial development is in progress, but there has not yet been a stable, usable release suitable for the public; this is a pre-release, be careful.
<h2 id="instructions">
Instructions for proper implementation
</h2>
<h3 id="install">
Installation
</h3>
To complete installation of dev version of GFR from GitHub, you have to install [Rtools Software](https://cran.r-project.org/bin/windows/Rtools/) and a few packages first.
```{r installation, eval = FALSE}
install.packages('devtools')
devtools::install_github('frahik/GFR')
```
<h3 id="demo">
Demostration examples
</h3>
<h4 id="shinyapp">
Package Web version
</h4>
The package includes a shiny app to very easy use of the package, includes the most essencial parts, to use this,
```{r shinyapp, eval = FALSE}
library(GFR)
runInterface()
```
<h4 id="data">
Availabe data
</h4>
Three data sets are available inside the package, to use it use `data()` function,
```{r data}
rm(list = ls())
library(GFR)
data("Wheat_GFR")
head(Wheat_GFR) # Load from data Wheat_GFR
paste0('Dimension of the Bands matrix: ', dim(Wheat_Bands)) # Load from data Wheat_GFR
paste0('Number of wavelenths:', length(Wheat_Wavelengths)) # Load from data Wheat_GFR
data("WheatI_GFR")
head(WheatI_GFR) # Load from data WheatI_GFR
paste0('Dimension of the Bands matrix: ',dim(WheatI_Bands)) # Load from data WheatI_GFR
paste0('Number of wavelenths:',length(WheatI_Wavelengths)) # Load from data WheatI_GFR
data("Maize_GFR")
head(Maize_GFR) # Load from data Maize_GFR
paste0('Dimension of the Bands matrix: ',dim(Maize_Bands)) # Load from data Maize_GFR
paste0('Number of wavelenths:',length( Maize_Wavelengths)) # Load from data Maize_GFR
```
<h4 id="fit-model">
Fitting a model
</h4>
To more simple way to fit a model is with one environment and one trait data,
```{r fit_model}
data("Wheat_GFR")
data <- Wheat_GFR[which(Wheat_GFR$Env == 'Drought'), ]
fm <- BFR(data, nIter = 1000, burnIn = 300, verbose = F)
plot(fm)
```
<h4 id="predictive-model">
Predictive model with a K-Folds Cross-validation
</h4>
To do a predictive model with a cross-validation, only we need to provide a list object with the type and the number of crossvalidation to do, in the package is available two cross-validatin types, in the following code, we see the CV K-Folds,
```{r predictive_model}
data("Wheat_GFR")
data <- Wheat_GFR[which(Wheat_GFR$Env == 'Drought'), ]
Crossvalidation_list <- list(Type = 'KFold', nFolds = 3)
pm <- BFR(data, nIter = 1000, burnIn = 300, set_seed = 10, CrossValidation = Crossvalidation_list, verbose = F)
summary(pm)
boxplot(pm)
```
<h4 id="auto-ETA">
Generate automatically a linear predictor (Only Multi-Environment example)
</h4>
For more advanced predictions, we also provide a eta generator, for the estimations, this function automatically prepare the data and do a lot of validations, this is the recomended way to do a proper analysis,
```{r auto_ETA}
library(GFR)
data("Wheat_GFR")
CrossV <- list(Type = 'KFold', nFolds = 3)
ETA2 <- ETAGenerate(Wheat_GFR, datasetID = 'Line', priorType = 'BayesB', Bands = Wheat_Bands,
Wavelengths = Wheat_Wavelengths, method = 'Alternative2', basisType = 'Bspline.Basis', nBasis = 21)
pm2 <- BFR(ETA = ETA2, data, nIter = 1000, burnIn = 300, set_seed = 10, CrossValidation = CrossV, verbose = F)
summary(pm2)
plot(pm2)
```
<h4 id="auto-ETA2">
Generate automatically a linear predictor (Multi-Trait & Multi-Environment example)
</h4>
Also, you can add some special terms, but be carefull,
```{r auto_ETA2}
data("Maize_GFR")
CrossV <- list(Type = 'RandomPartition', NPartitions = 3, PTesting = .25)
ETA3 <- ETAGenerate(Maize_GFR, basisType = 'Bspline.Basis', Bands = Maize_Bands, Wavelengths = Maize_Wavelengths, priorType = 'BRR', method = 'Simple', nBasis = 21)
ETA3$Design
ETA3$Basis
ETA3$Prior
ETA3$Method
pm3 <- BFR(ETA = ETA3, data, nIter = 1000, burnIn = 300, set_seed = 10, CrossValidation = CrossV, verbose = F)
summary(pm3)
```
<h4 id="HM-ETA">
Handmade linear predictor
</h4>
If you are a expert and know what are you doing, you can generate the ETA manually,
```{r HM_ETA}
CrossV <- list(Type = 'KFold', nFolds = 3)
ETA4 <- list(Env = list(X = model.matrix(~0+as.factor(Wheat_GFR$Env)), model = 'FIXED'),
Line = list(X = model.matrix(~0+as.factor(Wheat_GFR$Line)), model = 'BRR'),
Bands = list(X = Bspline.Basis(Wheat_Bands, Wheat_Wavelengths, nBasis = 23), model = 'BayesA'))
pm4 <- BFR(data = Wheat_GFR, ETA = ETA4, nIter = 1000, burnIn = 300, CrossValidation = CrossV, set_seed = 10, verbose = F)
summary(pm4)
plot(pm4, select = 'MSEP')
boxplot(pm4, select = 'MSEP')
```
<h4 id="autoclean">
Clean the working directory
</h4>
If you don't need anymore the files that the `BFR()` function creates, you can clean the directory with the following function provided in the package,
```{r cleaner}
cleanDat(noConfirm = TRUE)
```
<h2 id="cite">
How to cite this package
</h2>
First option, by the article paper
(Comming soon)
Second option, by the manual package
(Comming soon)
<h2 id="contributions">
Contributions
</h2>
If you have any suggestions or feedback, I would love to hear about it. Feel free to report new issues in [this link](https://github.com/frahik/GFR/issues/new), also if you want to request a feature/report a bug, or make a pull request if you can contribute.
<h2 id="authors">
Authors
</h2>
- Francisco Javier Luna-Vázquez (Author, Maintainer)
- Osval Antonio Montesinos-López (Author)
- Abelardo Montesinos-López (Author)
- José Crossa (Author)
- Gustavo de los campos (Author)