-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatchS.Rd
156 lines (117 loc) · 3.73 KB
/
batchS.Rd
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/batchS.R
\name{batchS}
\alias{batchS}
\title{Run batch analysis for single trait in R.}
\usage{
batchS(data,type,FMod,RMod=NULL,EMod=NULL,
geneticM=NULL,SpM=NULL,pformula=NULL)
}
\arguments{
\item{data}{aim dataset}
\item{type}{Index to specify which package for analysis.}
\item{FMod}{Fixed mode,should be 'y~1+fixed.factors'.}
\item{RMod}{Randomed mode, should be '~random.factors'.}
\item{EMod}{Error mode for asreml, details see example.}
\item{geneticM}{Randomed terms for tree model in breedR, details see example.}
\item{SpM}{Spatial error terms in breedR, details see example.}
\item{pformula}{formula for h2 (or corr).}
}
\value{
the result is returned directly.
}
\description{
\code{batchS} This function carries out batch analysis for
single trait for mixed models in R.
}
\details{
Mixed models batch analysis for single trait.
}
\examples{
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))
\dontrun{
## 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
}
}
\references{
AAFMM website:https://github.com/yzhlinscau/AAFMM
}
\author{
Yuanzhen Lin <yzhlinscau@163.com>
}