####=========================================####
#### For CRAN time limitations most lines in the
#### examples are silenced with a single '#' mark,
#### remove them and run the examples
####=========================================####
data(CPdata)
CPpheno <- CPdata$pheno
CPgeno <- CPdata$geno
####=========================================####
#### convert markers to numeric format
####=========================================####
## fit a model including additive and dominance effects
y <- CPpheno$color
Za <- diag(length(y))
A <- A.mat(CPgeno) # additive relationship matrix
####=========================================####
#### identify major genes and create the bagging matrix
####=========================================####
ETA.A <- list(list(Z=Za,K=A))
#ans.GWAS <- mmer(y=y, Z=ETA.A, W=CPgeno)
#summary(ans.GWAS)
####=========================================####
#### run the bag function to design the matrix
#### for top GWAS hits
####=========================================####
#X1 <- bag(ans.GWAS);head(X1); dim(X1)
####=========================================####
#### compare prediction accuracies between
#### GBLUP and bag GBLUP
####=========================================####
set.seed(1234)
y.trn <- y # for prediction accuracy
ww <- sample(c(1:dim(Za)[1]),72) # delete data for one fifth of the population
y.trn[ww] <- NA
ETA.A <- list(list(Z=Za,K=A))
#ans.A <- mmer(y=y.trn, Z=ETA.A) # GBLUP
#ans.AF <- mmer(y=y.trn, X=X1, Z=ETA.A) # bagging-GBLUP
#cor(ans.A$fitted.y[ww], y[ww], use="pairwise.complete.obs") # GBLUP
#cor(ans.AF$fitted.y[ww], y[ww], use="pairwise.complete.obs") # bagging-GBLUP
#### 11 percent increase in prediction accuracy
Run the code above in your browser using DataLab