AFEchidna包示例24之数据子集的分析

50 篇文章 4 订阅

例如,对于多点试验数据,在计算B型相关时,一般是计算两两地点间。Echidna没有像asreml那么方便,因此AFEchidna与没法像asreml那样通过at()或者subset()轻松获取。但可以自行编程来实现。

在最新版的AFEchidna包里,subF功能已整合到主函数echidna()里,使用方法更为便捷:

// new method for subF
mm2<-echidna(fixed=logsy~site,
            random=~variety+site:variety,
            residual=~sat(site):units,
            met=T,subF=T,dat.file="mssy.asd",
            subV.org='site',mulN=2,res.no=3,
            es0.file="mssy.es0")

mm2 %>% b2s %>% lapply(., Var)
tt<- mm2 %>% b2s %>% lapply(., function(x)  pin(x,mulp=c(rb~V2/(V2+V3)),Rres=T))

mm2a <- update.esR22(mm2,subF=T,mulN=3)

简单示例如下:

// subset function for MET
subF <- function(fixed=NULL, random=NULL, residual=NULL,es0.file,
                 subV.org, subV.nL,subV.new,mulN=2,res.n0=NULL) {
                 
  cat('Starting analysis.\n')
  cc<-1:subV.nL
  bb <- utils::combn(cc,mulN)
  if(is.null(res.n0)) bbn <- ncol(bb) 
  else bbn <-res.n0
  
  res<-vector("list", bbn)
  
  res<-lapply(1:bbn, function(x){
    #cc<-paste0('Site-',bb[1,x],':',bb[2,x])
    subsetcc<-paste0('!subset ',subV.new, subV.org,' ',bb[1,x],' ',bb[2,x])
    mm <- echidna(fixed=fixed,
                  random=random,
                  residual=residual,
                  qualifier = subsetcc,
                  trace=F,
                  es0.file = es0.file)
    })
  
  names(res)<- lapply(1:bbn, function(x) paste0('Site-',bb[1,x],':',bb[2,x]))
  cat('works done.\n')
  res
}

运行示例如下:

> res11<-subF(fixed=logsy~Siten,
+              random=~Variety+Siten:Variety,
+              es0.file = 'mssy.es0',
+              subV.org='Site', subV.nL=6,subV.new='Siten',
+              res.n0=4 )
Starting analysis.
works done.
> names(res11)
[1] "Site-1:2" "Site-1:3" "Site-1:4" "Site-1:5"
> res11 %>% lapply(., Var)
$`Site-1:2`
           Term    Sigma        SE   Z.ratio
1      Residual 0.508760 0.0324580 15.674410
2       Variety 0.043144 0.0212530  2.030019
3 Siten:Variety 0.050876 0.0032458 15.674410

$`Site-1:3`
           Term    Sigma       SE   Z.ratio
1      Residual 0.508280 0.032430 15.673142
2       Variety 0.041909 0.020936  2.001767
3 Siten:Variety 0.050828 0.003243 15.673142

$`Site-1:4`
           Term     Sigma         SE   Z.ratio
1      Residual 0.5081100 0.03241100 15.677085
2       Variety 0.0421970 0.02096300  2.012928
3 Siten:Variety 0.0035568 0.00022688 15.677010

$`Site-1:5`
           Term    Sigma        SE   Z.ratio
1      Residual 0.508830 0.0324630 15.674152
2       Variety 0.042790 0.0211650  2.021734
3 Siten:Variety 0.050883 0.0032463 15.674152

> tt<-res11 %>% lapply(., function(x)  pin(x,mulp=c(rb~V2/(V2+V3)),Rres=T))
> tt
$`Site-1:2`
  Term Estimate    SE
1   rb    0.459 0.126

$`Site-1:3`
  Term Estimate    SE
1   rb    0.452 0.127

$`Site-1:4`
  Term Estimate     SE
1   rb    0.922 0.0366

$`Site-1:5`
  Term Estimate    SE
1   rb    0.457 0.126

参考文献:
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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值