-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
293 lines (233 loc) · 7.6 KB
/
README.Rmd
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
---
output: github_document
---
<p align="center">
<a href="https://github.com/frahik/IBCF.MTME">
<img src="Logo.png" alt="IBCF.MTME Logo"/>
</a>
<h4 align="center">
**I**tem **B**ased **C**ollaborative **F**ilterign For **M**ulti-**T**rait and **M**ulti-**E**nvironment Data in R - Development version `r packageVersion('IBCF.MTME')`.
</h4>
<h4 align="center">
[Last README update: `r format(Sys.Date())`]
</h4>
<p align="center">
<a href="https://www.tidyverse.org/lifecycle/#maturing">
<img src="https://img.shields.io/badge/lifecycle-maturing-blue.svg" alt="Maturing"> </a>
<a href="https://travis-ci.org/frahik/IBCF.MTME">
<img src="https://travis-ci.org/frahik/IBCF.MTME.svg?branch=master" alt="Travis build status"> </a>
<a href="https://ci.appveyor.com/project/frahik/ibcf-mtme">
<img src="https://ci.appveyor.com/api/projects/status/xvfx0ch4vbyko1fs?svg=true" alt="Appveyor build status"> </a>
<a href='https://coveralls.io/github/frahik/IBCF.MTME?branch=master'>
<img src='https://coveralls.io/repos/github/frahik/IBCF.MTME/badge.svg?branch=master' alt='Coverage Status' /> </a>
<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/#active">
<img src="http://www.repostatus.org/badges/latest/active.svg" alt="Status of the Repo: Active"> </a>
<a href="">
<img src="http://cranlogs.r-pkg.org/badges/IBCF.MTME" alt="Dowloads from the CRAN"> </a>
<a href="https://cran.r-project.org/package=IBCF.MTME">
<img src="http://www.r-pkg.org/badges/version-ago/IBCF.MTME" alt="CRAN"> </a>
</p>
</p>
# Table Of Contents
- [NEWS](#news)
- [Instructions](#instructions)
- [Installation](#install)
- [Load the package](#package)
- [Example of Cross-validation with IBCF.MTME and external data](#example1)
- [Load external data](#external-data)
- [Generate a data set in tidy data](#generate-tidydata)
- [Generate a Cross-validation](#generate-crossvalidation)
- [Fitting the predictive model](#fit-model)
- [Show some results](#results)
- [Example of Years prediction with IBCF.Years Function](#example2)
- [Loading your data](#external-data2)
- [Transforming the data from Tidy data to matrix form](#generate-matrixform)
- [Adjust the model](#adjust-model)
- [Show some results](#results)
- [Load available data from the package](#load-data)
- [How to cite this package](#cite)
- [Contributions](#contributions)
- [Authors](#authors)
<h2 id="news">
News of this version (`r packageVersion('IBCF.MTME')`)
</h2>
* Fixed important issue with the predictions output.
* Fixed compatibility with dplyr 0.8.
* Fixed barplot function.
See the last updates in [NEWS](NEWS.md).
<h2 id="instructions">
Instructions for proper implementation
</h2>
<p align="center">
<a href="https://github.com/frahik/IBCF.MTME">
<img src="IBCF_HowAnalyzeYourData.png" alt="IBCF.MTME Logo"/>
</a>
</p>
<h3 id="install">
Installation
</h3>
To complete installation of dev version of the package `IBCF.MTME` from GitHub, you must have previously installed the devtools package.
```{r installation, eval = FALSE}
install.packages('devtools')
devtools::install_github('frahik/IBCF.MTME')
```
If you want to use the stable version of `IBCF.MTME` package, install it from CRAN.
```{r, eval=FALSE}
install.packages('IBCF.MTME')
```
<h3 id="package">
Load the package
</h3>
```{r}
library(IBCF.MTME)
```
<h3 id="example1">
Example of Cross-validation with IBCF.MTME
</h3>
<h4 id="external-data">
Load available data from other package
</h4>
```{r CVModel}
library(BGLR)
data(wheat)
```
<h4 id="generate-tidydata">
Generate a new data set in tidy data form
</h4>
```{r}
pheno <- data.frame(ID = gl(n = 599, k = 1, length = 599*4),
Response = as.vector(wheat.Y),
Env = paste0('Env', gl(n = 4, k = 599)))
head(pheno)
```
<h4 id="generate-crossvalidation">
Generate 10 partitions to do cross-validation
</h4>
```{r}
CrossV <- CV.RandomPart(pheno, NPartitions = 10, PTesting = 0.25, Set_seed = 123)
```
<h4 id="fit-model">
Fitting the predictive model
</h4>
```{r}
pm <- IBCF(CrossV)
```
<h4 id="results">
Show some results
</h4>
All the predictive model printed output:
```{r}
pm
```
Predictions and observed data in tidy format
```{r}
head(pm$predictions_Summary, 6)
```
Predictions and observed data in matrix format
```{r}
head(pm$Data.Obs_Pred, 5)
```
Some plots
```{r}
par(mai = c(2, 1, 1, 1))
plot(pm, select = 'Pearson')
plot(pm, select = 'MAAPE')
```
<h3 id="example2">
Example of Years prediction with IBCF.Years Function
</h3>
```{r YearsData, echo = FALSE, warning = FALSE}
library(mvtnorm)
library(IBCF.MTME)
set.seed(2)
A <- matrix(0.65, ncol = 12, nrow = 12)
diag(A) <- 1
Sdv <- diag(c(0.9^0.5,0.8^0.5,0.9^0.5,0.8^0.5,0.86^0.5,0.7^0.5,0.9^0.5,0.8^0.5,0.9^0.5,0.7^0.5,0.7^0.5,0.85^0.5))
Sigma <- Sdv %*% A %*% Sdv
No.Lines <- 80
Z <- rmvnorm(No.Lines,mean = c(15, 15.5, 16, 15.5, 17, 16.5, 16.0, 17, 16.6, 18, 16.3, 18), sigma = Sigma)
Years <- c(rep(2014,20), rep(2015,20), rep(2016,20), rep(2017,20))
Gids <- c(1:No.Lines)
Data.Example <- data.frame(cbind(Years,Gids,Z))
colnames(Data.Example) <- c("Years","Gids","Trait1","Trait2","Trait3","Trait4","Trait5","Trait6","Trait7","Trait8","Trait9","Trait10","Trait11","Trait12")
Data.Example <- getTidyForm(Data.Example, onlyTrait = T)
save(Data.Example, file = 'DataExample.RData')
```
<h4 id="external-data2">
Loading your data
</h4>
```{r}
load('DataExample.RData')
head(Data.Example)
```
<h4 id="generate-matrixform">
Transforming the data from Tidy data to matrix form
</h4>
```{r}
Data.Example <- getMatrixForm(Data.Example, onlyTrait = TRUE)
head(Data.Example)
```
<h4 id="adjust-model">
Adjust the model
</h4>
```{r Years}
pm <- IBCF.Years(Data.Example, colYears = 1, Years.testing = c('2014', '2015', '2016'),
Traits.testing = c('Trait1', 'Trait2', 'Trait3', 'Trait4', "Trait5"))
```
<h4 id="results2">
Show some results
</h4>
```{r}
summary(pm)
par(mai = c(2, 1, 1, 1))
barplot(pm, las = 2)
barplot(pm, select = 'MAAPE', las = 2)
```
<h4 id="load-data">
Load available data from the package
</h4>
You can use the data sets in the package to test the functions
```{r loadData}
library(IBCF.MTME)
data('Wheat_IBCF')
head(Wheat_IBCF)
```
```{r loadYearData}
data('Year_IBCF')
head(Year_IBCF)
```
<h2 id="cite">
Citation
</h2>
First option, by the article paper
```
@article{IBCF2018,
author = {Montesinos-L{\'{o}}pez, Osval A. and Luna-V{\'{a}}zquez, Francisco Javier and Montesinos-L{\'{o}}pez, Abelardo and Juliana, Philomin and Singh, Ravi and Crossa, Jos{\'{e}}},
doi = {10.3835/plantgenome2018.02.0013},
issn = {1940-3372},
journal = {The Plant Genome},
number = {3},
pages = {16},
title = {{An R Package for Multitrait and Multienvironment Data with the Item-Based Collaborative Filtering Algorithm}},
url = {https://dl.sciencesocieties.org/publications/tpg/abstracts/0/0/180013},
volume = {11},
year = {2018}
}
```
Second option, by the manual package
```{r}
citation('IBCF.MTME')
```
<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/IBCF.MTME/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)