# generate simulated data
set.seed(6000)
geno.test <- matrix(sample(c(1, -1), 200, replace = TRUE), 10, 20)
t1 <- 5*geno.test[,3]+3*geno.test[,7]-geno.test[,11]+rnorm(10,30,10)
t2 <- 3*geno.test[,3]+geno.test[,12]-2*geno.test[,18]+rnorm(10,10,5)
t3 <- NULL
t4 <- NULL
t5 <- NULL
marker.test <- cbind(rep(1:2, each=10), rep(seq(0, 90, 10), 2))
fit <- GBLUP.fit(t1, t2, t3, t4, t5, geno = geno.test)
fitvalue <- fit$fitted.value
geno.candidate <- matrix(sample(c(1,-1), 300, replace = TRUE), 15, 20)
# run and output
result <- simu.GDO(fitvalue, geno.t = geno.test, marker = marker.test,
geno.c = geno.candidate, nprog = 5, nsele = 10, ngen = 5, nrep = 5, cri = 250)
result$suggested.subset
# other method: use mmer to obtain the fitted value
if (FALSE) {
set.seed(6000)
geno.test <- matrix(sample(c(1, -1), 200, replace = TRUE), 10, 20)
t1 <- 5*geno.test[,3]+3*geno.test[,7]-geno.test[,11]+rnorm(10,30,10)
t2 <- 3*geno.test[,3]+geno.test[,12]-2*geno.test[,18]+rnorm(10,10,5)
phe <- cbind(t1, t2)
nt <- ncol(phe)
marker.test <- cbind(rep(1:2, each=10), rep(seq(0, 90, 10), 2))
rownames(geno.test) <- 1:nrow(geno.test)
id <- rownames(geno.test)
K0 <- geno.test%*%t(geno.test)/ncol(geno.test)
dat <- data.frame(id, phe)
fit0 <- sommer::mmer(cbind(t1, t2)~1,
random = ~sommer::vsr(id, Gu = K0, Gtc = sommer::unsm(nt)),
rcov = ~sommer::vsr(units, Gtc = sommer::unsm(nt)),
data = dat,
tolParInv = 0.1)
u0 <- fit0$U$`u:id`
fit <- matrix(unlist(u0), ncol = nt)
colnames(fit) <- names(u0)
fit <- fit+matrix(fit0$fitted[1,], nrow(fit), nt, byrow = TRUE)
fitvalue <- fit[order(as.numeric(names((u0[[1]])))),]
}
Run the code above in your browser using DataLab