require(SFSI)
data(wheatHTP)
index = which(Y$trial %in% 1:6) # Use only a subset of data
Y = Y[index,]
M = scale(M[index,])/sqrt(ncol(M)) # Subset and scale markers
G = tcrossprod(M) # Genomic relationship matrix
y = as.vector(scale(Y[,"E1"])) # Scale response variable
# Training and testing sets
tst = which(Y$trial == 2)
trn = which(Y$trial != 2)
yNA <- y
yNA[tst] <- NA
fm1 = fitBLUP(yNA, K=G)
plot(y[tst],fm1$u[tst]) # Predicted vs observed values in testing set
cor(y[tst],fm1$u[tst]) # Prediction accuracy in testing set
cor(y[trn],fm1$u[trn]) # Prediction accuracy in training set
fm1$theta # Residual/Genetic variances ratio
fm1$h2 # Heritability
# \donttest{
if(requireNamespace("float")){
# Using a 'float' type variable
G2 = float::fl(G)
fm2 = fitBLUP(yNA, K=G2)
max(abs(fm1$u-fm2$u)) # Check for discrepances
}
# }
Run the code above in your browser using DataLab