||
引子:
本人于2019年主译出版的《动植物育种遗传数据分析》,原书主要使用ASReml进行分析。本博客将陆续演示使用AFEchidna包达到类似ASReml的结果。
第一章的代码如下:
// chapter one
library(AFEchidna)
get.es0.file(dat.file='pine_provenance.csv') # .es file
get.es0.file(es.file='pine_provenance.es',pedS=1) # .es0 file
# file.edit('pine_provenance.es0')
HT <- echidna(height ~ 1+Prov,
random = ~ Female*Block,
residual=~units,
es0.file = 'pine_provenance.es0' )
names(HT)
HT$Version
Var(HT)
# wald(HT)
waldT(HT)
HT$Converge
HT$LogLikelihood
# gets AIC and BIC for a model
IC(HT)
# fixed effects
coef(HT)$fixed
# random effects
bv<-coef(HT)$random
nrow(bv)
bv[1:10,]
tail(bv)
# Block bv
library(dplyr)
bv %>% filter(Term=='Block')
# Female bv
bv %>% filter(Term=='Female') %>% head
# Female:Block bv
bv %>% filter(Term=='Female:Block') %>% head
plot(HT)
## variance component and heritability
Var(HT)
## Linear Combinations of Variance Components
pin(HT)
pin(HT,mulp=c(Va~4*V3,
VP~V1+V3+V4,
H2i~4*V3/(V1+V3+V4)))
### TABULATE
library(dplyr)
pine_prov %>% group_by(Prov) %>% dplyr::select(height) %>%
summarise(Mean=mean(height,na.rm=T),
SD=sd(height,na.rm=T),
Min=min(height,na.rm=T),
Max=max(height,na.rm=T),
Count=n()
)
### prediction
#predict prov levels
HT1<-update(HT,predict="Prov")
HTprov_pred <- predict(HT1)
predict.prov <- HTprov_pred$pred
predict.prov
HTprov_pred$ased
# Not adjusted for prov effect
HT2<-update(HT,predict="Female")
HTprov_female <- predict(HT2)
predict.female <- HTprov_female$pred
head(predict.female$pred1)
HTprov_female$ased
# adjusted for prov effect
HT3<-update(HT,predict="Prov Female !present Prov Female")
HTprov_fem.prov <- predict(HT3)
#includes non-estimable combinations
all_fem.prov<-HTprov_fem.prov$pred$pred1
head(all_fem.prov[,1:5])
#tail(all_fem.prov[,1:5])
## batch analysis, similar to !cycle for win Version
tba<-update(HT,trait=~height+diameter+volume,
batch=TRUE)
Var(tba)
参考文献
1 . Zhang WH, Wei RY, Liu Y, Lin YZ. AFEchidna is a R package for genetic evaluation of plant and animal breeding datasets. BioRxiv. DOI: 10.1101/2021.06.24.449740.
2. 林元震 丁昌俊 主译,动植物育种遗传数据分析, 科学出版社,2019.9
博文首发链接:https://blog.csdn.net/yzhlinscau/article/details/124202572
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-27 13:01
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社