||
Vanraden P M. Efficient methods to compute genomic predictions.[J]. Journal of Dairy Science, 2008, 91(11):4414-4423.
Forni S, Aguilar I, Misztal I. Different genomic relationship matrices for single-step analysis using phenotypic, pedigree and genomic information.[J]. Genetics, selection, evolution : GSE, 2011, 43(1):1.
http://articles.extension.org/pages/68019/genomic-relationships-and-gblup
$$
Z 表示标记矩阵的发生率(incidence)
表示测序个体考虑近交和选择后的MAF
Genotype <- data.frame(row.names = paste("Ind",1:3,sep=""), snp1=c("AA","AA","TT"), snp2=c("CG","CG","CC"), snp3=c("GG","GC","GG"), snp4=c("AT","AA","AA"))
Genotype
snp1 | snp2 | snp3 | snp4 | |
---|---|---|---|---|
Ind1 | AA | CG | GG | AT |
Ind2 | AA | CG | GC | AA |
Ind3 | TT | CC | GG | AA |
MAF <- data.frame(row.names = paste("Ind",1:3,sep=""), snp1=c(0,0,2), snp2=c(1,1,0), snp3=c(0,1,0), snp4=c(1,0,0))
MAF
snp1 | snp2 | snp3 | snp4 | |
---|---|---|---|---|
Ind1 | 0 | 1 | 0 | 1 |
Ind2 | 0 | 1 | 1 | 0 |
Ind3 | 2 | 0 | 0 | 0 |
M <- MAF -1 M
snp1 | snp2 | snp3 | snp4 | |
---|---|---|---|---|
Ind1 | -1 | 0 | -1 | 0 |
Ind2 | -1 | 0 | 0 | -1 |
Ind3 | 1 | -1 | -1 | -1 |
M <- as.matrix(M)
M%*%t(M)
Ind1 | Ind2 | Ind3 | |
---|---|---|---|
Ind1 | 2 | 1 | 0 |
Ind2 | 1 | 2 | 0 |
Ind3 | 0 | 0 | 4 |
MM’的对角线,表示个体纯合子的个数,比如个体1有两个纯合子,个体2有两个纯合子,个体3有4个纯合子
t(M)%*%M
snp1 | snp2 | snp3 | snp4 | |
---|---|---|---|---|
snp1 | 3 | -1 | 0 | 0 |
snp2 | -1 | 1 | 1 | 1 |
snp3 | 0 | 1 | 2 | 1 |
snp4 | 0 | 1 | 1 | 2 |
M’M的对角线表示每个位点纯合子的个体数,比如第一个位点,有3个个体是纯合的,第二个位点,有1个位点是纯合的。
比如,第一个位点,p为0.3333,第二个位点p为0.3333,第三个位点p为0.1667,第四个位点p为0.1667,则P矩阵为
p1 <- 0.3333; p2 <- 0.3333; p3 <- 0.1667p4 <- 0.1667; pp <- data.frame(snp1 = rep(p1,3),snp2 = rep(p2,3),snp3=rep(p3,3),snpp4=rep(p4,3),row.names = paste("Ind",1:3,sep="")) P <- (pp-0.5)*2P <- as.matrix(P) P
snp1 | snp2 | snp3 | snpp4 | |
---|---|---|---|---|
Ind1 | -0.3334 | -0.3334 | -0.6666 | -0.6666 |
Ind2 | -0.3334 | -0.3334 | -0.6666 | -0.6666 |
Ind3 | -0.3334 | -0.3334 | -0.6666 | -0.6666 |
Z <- M - P Z
snp1 | snp2 | snp3 | snp4 | |
---|---|---|---|---|
Ind1 | -0.6666 | 0.3334 | -0.3334 | 0.6666 |
Ind2 | -0.6666 | 0.3334 | 0.6666 | -0.3334 |
Ind3 | 1.3334 | -0.6666 | -0.3334 | -0.3334 |
tZZ <- Z%*%t(Z) tZZ
Ind1 | Ind2 | Ind3 | |
---|---|---|---|
Ind1 | 1.1110222 | 0.1110222 | -1.222178 |
Ind2 | 0.1110222 | 1.1110222 | -1.222178 |
Ind3 | -1.2221778 | -1.2221778 | 2.444622 |
fenmu <- 2*sum(p1*(1-p1) + p2*(1-p2) + p3*(1-p3) + p4*(1-p4)) fenmu
1.44448888
G <- tZZ/fenmu G
Ind1 | Ind2 | Ind3 | |
---|---|---|---|
Ind1 | 0.76914558 | 0.07685919 | -0.846097 |
Ind2 | 0.07685919 | 0.76914558 | -0.846097 |
Ind3 | -0.84609704 | -0.84609704 | 1.692379 |
sommer::A.mat(M)
Ind1 | Ind2 | Ind3 | |
---|---|---|---|
Ind1 | 0.76923077 | 0.07692308 | -0.8461538 |
Ind2 | 0.07692308 | 0.76923077 | -0.8461538 |
Ind3 | -0.84615385 | -0.84615385 | 1.6923077 |
G_matrix <- function(data){ M=data # 计算每个SNP minor allet的频率p值 p1=round((apply(M,2,sum)+nrow(M))/(nrow(M)*2),3) # 计算P矩阵 p=2*(p1-0.5) P=matrix(p,byrow=T,nrow=nrow(M),ncol=ncol(M)) # 就是那Z矩阵 Z=as.matrix(M-P) # 计算G矩阵公式的分母 c=p1*(1-p1) d=2*(sum(c)) # 计算G矩阵公式的分子 ZZt=Z%*%t(Z) # 计算G矩阵 G=(ZZt/d) return(G) }
G_matrix(M)
Ind1 | Ind2 | Ind3 | |
---|---|---|---|
Ind1 | 0.7683807 | 0.0762855 | -0.8455853 |
Ind2 | 0.0762855 | 0.7683807 | -0.8455853 |
Ind3 | -0.8455853 | -0.8455853 | 1.6930198 |
Genotype <- data.frame(row.names = paste("Ind",1:3,sep=""),snp1=c("AA","AA","TT"),snp2=c("CG","CG","CC"),snp3=c("GG","GC","GG"),snp4=c("AT","AA","AA")) Genotype MAF <- data.frame(row.names = paste("Ind",1:3,sep=""),snp1=c(0,0,2),snp2=c(1,1,0),snp3=c(0,1,0),snp4=c(1,0,0)) MAF M <- MAF -1 ; M M <- as.matrix(M) M%*%t(M) t(M)%*%M p1 <- 0.3333; p2 <- 0.3333; p3 <- 0.1667 p4 <- 0.1667; pp <- data.frame(snp1 = rep(p1,3),snp2 = rep(p2,3),snp3=rep(p3,3),snpp4=rep(p4,3),row.names = paste("Ind",1:3,sep="")) P <- (pp-0.5)*2 P <- as.matrix(P);P Z <- M - P; Z tZZ <- Z%*%t(Z); tZZ fenmu <- 2*sum(p1*(1-p1) + p2*(1-p2) + p3*(1-p3) + p4*(1-p4)); fenmu G <- tZZ/fenmu; G sommer::A.mat(M) G_matrix <- function(data){ M=data # 计算每个SNP minor allet的频率p值 p1=round((apply(M,2,sum)+nrow(M))/(nrow(M)*2),3) # 计算P矩阵 p=2*(p1-0.5) P=matrix(p,byrow=T,nrow=nrow(M),ncol=ncol(M)) # 就是那Z矩阵 Z=as.matrix(M-P) # 计算G矩阵公式的分母 c=p1*(1-p1) d=2*(sum(c)) # 计算G矩阵公式的分子 ZZt=Z%*%t(Z) # 计算G矩阵 G=(ZZt/d) return(G) } G_matrix(M)
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-21 16:52
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社