Description Usage Arguments Details Value Author(s) References Examples
batchS
This function carries out batch analysis for
single trait for mixed models in R.
1 2 |
data |
aim dataset |
type |
Index to specify which package for analysis. |
FMod |
Fixed mode,should be 'y~1+fixed.factors'. |
RMod |
Randomed mode, should be '~random.factors'. |
EMod |
Error mode for asreml, details see example. |
geneticM |
Randomed terms for tree model in breedR, details see example. |
SpM |
Spatial error terms in breedR, details see example. |
pformula |
formula for h2 (or corr). |
Mixed models batch analysis for single trait.
the result is returned directly.
Yuanzhen Lin <yzhlinscau@163.com>
AAFMM website:https://github.com/yzhlinscau/AAFMM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | library(AAFMM)
library(tidyr)
library(plyr)
library(dplyr)
#### running examples for batchS()
## 00 data
data(butron.maize,package='agridat')
#str(butron.maize)
set.seed(2018)
butron.maize$x<-rnorm(245,mean=10,sd=4)
df<-tidyr::gather(butron.maize,key=Trait,y,c(-1:-4))
#str(df)
## 01 nlme package
library(nlme) # V3.1-131
Fixed.Mod1<- y ~ 1+env
Ran.Mod1<- ~1|male/female
nlme.rs<-plyr::ddply(df,'Trait',
function(dat) batchS(data=dat,type='nlme',
FMod=Fixed.Mod1,
RMod=Ran.Mod1))
## 02 lme4 package
library(lme4) # V1.1-17
Fixed.Mod2<- y ~ 1+env+(1|male)+(1|female)
lme4.rs<-plyr::ddply(df,'Trait',
function(dat) batchS(data=dat,type='lme4',
FMod=Fixed.Mod2))
## Not run:
## 03 breedR package
library(breedR) # V0.12-1
Fixed.Mod3<- y ~ 1+env
Ran.Mod3<- ~ male+female
breedR.rs<-plyr::ddply(df,'Trait',
function(dat) batchS(data=dat,type='breedR',
FMod=Fixed.Mod3,
RMod=Ran.Mod3))
## 04 asreml package
library(asreml) #V3.0
Fixed.Mod4<- y ~ 1+env
Ran.Mod4<- ~male+female
asreml.rs<-plyr::ddply(df,'Trait',
function(dat) batchS(data=dat,type='asreml',
FMod=Fixed.Mod4,
RMod=Ran.Mod4))
#### special for breedR
library(breedR)
data(douglas)
S3<-subset(douglas,site=='s3')
#summary(S3);str(S3)
S3a<-dplyr::filter(S3,is.na(dad)) # hs
S3a<-transform(S3a,Mum=factor(mum))
S3a<-droplevels(S3a)
names(S3a)[7:8]<-c('x1','y1')
df<-tidyr::gather(S3a,key=Trait,y,c(-1:-8,-12,-14:-16))
#str(df)
# for parent model
fixed = y ~ 1+orig
random1=~Mum+block
pformula1=h2~4*V1/(V1+V3)
mm<-plyr::ddply(df,'Trait',
function(dat) batchS(data=dat,type='breedR',
FMod=fixed,RMod=random1,
pformula=pformula1)
)
#result
mm
# for tree model
random2=~block
genetic=list(model = 'add_animal',
pedigree = S3a[,1:3],
id = 'self')
pformula2=h2~V2/(V2+V3)
mm1<-plyr::ddply(df,'Trait',
function(dat) batchS(data=dat,type='breedR',
FMod=fixed,RMod=random2,
geneticM=genetic,
pformula=pformula2)
)
#result
mm1
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.