yzhlinscau的个人博客分享 http://blog.sciencenet.cn/u/yzhlinscau

博文

《动植物育种遗传数据分析》之AFEchidna篇--第1章

已有 2916 次阅读 2022-4-15 20:17 |个人分类:Echidna|系统分类:科研笔记

引子:

 本人于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 




https://blog.sciencenet.cn/blog-1114360-1334076.html

上一篇:AFEchidna包的使用秘籍
下一篇:《动植物育种遗传数据分析》之AFEchidna篇--第5章
收藏 IP: 116.21.68.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-11-22 05:44

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部