ASReml
和sommer
都可以进行GBLUP育种值预测,区别在于对加性关系矩阵G矩阵的使用及结果。ASReml
用的是G矩阵的逆,后者直接用的G矩阵。G矩阵的逆可以用MASS::ginv
得到。
数据
library(tidyverse)
library(magrittr)
library(synbreed)
library(SNPassoc)
# 准备数据
data("SNPs")
pheno <- SNPs %>% select(id, blood.pre, protein)
genos <- SNPs[,-c(1:5)] %>% `rownames<-`(pheno$id)
pheno$id <- factor(pheno$id)
G_synbreed <- create.gpData(geno = as.matrix(genos)) %>%
codeGeno(impute=T, impute.type="random", verbose = T) %>%
kin(ret = "realized")
- sommer
## GBLUP
library(sommer)
ans <- mmer(protein~1,
random=~vs(id,Gu=G_synbreed),
rcov=~units,
data=pheno) # kinship based
# iteration LogLik wall cpu(sec) restrained
# 1 -75.3611 10:8:52 0 0
# 2 -75.3501 18:8:52 0 0
# 3 -75.3411 18:8:52 0 0
# 4 -75.3359 18:8:52 0 0
# 5 -75.334 18:8:52 0 0
# 6 -75.3333 18:8:52 0 0
summary(ans)$varcomp
# VarComp VarCompSE Zratio Constraint
# u:id.protein-protein 73424530 74378049 0.9871801 Positive
# units.protein-protein 511457543 59093952 8.6549897 Positive
- ASReml
library(asreml)
rMinv <- ginv(G_synbreed)
Ginv <- data.frame(Row = rep(1:nrow(rMinv), nrow(rMinv)),
Column = rep(1:nrow(rMinv), each = nrow(rMinv)), coeff = as.numeric(rMinv),
lower = as.logical(lower.tri(rMinv, diag = TRUE)))
Ginv <- Ginv[Ginv$lower == TRUE, c("Row", "Column", "coeff")]
Ginv <- Ginv[order(Ginv$Row, Ginv$Column), ] %>% as.matrix()
# Preparing Ginverse(s)
attr(Ginv,"rowNames")<-attr(Ginv,"colNames")<-as.character(pheno$id)
attr(Ginv,"INVERSE")<-TRUE
head(Ginv)
## GBLUP
ans <- asreml(protein~1,
random=~vm(id,Ginv),
residual=~units,
data=pheno) # kinship based
# Model fitted using the gamma parameterization.
# LogLik Sigma2 DF wall cpu
# 1 -1384.835 9.70374e+07 157 18:15:07 0.0 (1 restrained)
# 2 -1211.343 1.21925e+08 157 18:15:07 0.0 (1 restrained)
# 3 -1027.900 1.31676e+08 157 18:15:07 0.0 (1 restrained)
# 4 -839.297 1.32575e+08 157 18:15:07 0.0 (1 restrained)
# 5 -650.220 1.32634e+08 157 18:15:07 0.0 (1 restrained)
# 6 -461.113 1.3264e+08 157 18:15:07 0.0
# 7 -461.113 1.3264e+08 157 18:15:07 0.0
# 8 -461.113 1.3264e+08 157 18:15:07 0.0
summary(ans)$varcomp
# component std.error z.ratio bound %ch
# vm(id, Ginv) 1.342225e+01 NA NA B 0
# units(R) 1.326402e+08 14970644 8.860023 P 0
差了很多啊!