Fitting pedigree based mixed models in BUGS software - talk

27
Fitting pedigree based mixed models in BUGS software Gregor Gorjanc University of Ljubljana, Biotechnical Faculty, Department of Animal Science, Slovenia 5th SGD, Otočec, Slovenia 20th September 2009

description

Gorjanc, G. 2009. Fitting pedigree based mixed models in BUGS software - presented at 5th SGD - Otočec, Slovenia, 20th September

Transcript of Fitting pedigree based mixed models in BUGS software - talk

Page 1: Fitting pedigree based mixed models in BUGS software - talk

Fitting pedigree based mixed models inBUGS software

Gregor Gorjanc

University of Ljubljana, Biotechnical Faculty, Department of Animal Science,Slovenia

5th SGD, Otočec, Slovenia20th September 2009

Page 2: Fitting pedigree based mixed models in BUGS software - talk

IntroductionI Pedigree based mixed model = animal model

y = Xb + Za + e

y|b, a, σ2e ∼ N(Xb + Za, Iσ2e

)a|A, σ2a ∼ N

(0,Aσ2a

)parameters: b, a, σ2a , σ2e derived quantities: h2 = σ2a/(σ2a+σ2e)

I Simplistic, powerful, & robust modelI Frequently used in:

I animal and plant breeding - research & INDUSTRYI evolutionary biology - researchI human genetics - research

Page 3: Fitting pedigree based mixed models in BUGS software - talk

IntroductionI Pedigree based mixed model = animal model

y = Xb + Za + e

y|b, a, σ2e ∼ N(Xb + Za, Iσ2e

)a|A, σ2a ∼ N

(0,Aσ2a

)parameters: b, a, σ2a , σ2e derived quantities: h2 = σ2a/(σ2a+σ2e)

I Simplistic, powerful, & robust modelI Frequently used in:

I animal and plant breeding - research & INDUSTRYI evolutionary biology - researchI human genetics - research

Page 4: Fitting pedigree based mixed models in BUGS software - talk

Bayesian approachI Recent rise of Bayesian approach to infer parameters

p(b, a, σ2a , σ2e |y

)=

p(y|b, a, σ2e

)p (b) p

(a,Aσ2a

)p

(σ2a

)p

(σ2e

a´σ2

a

´σ2

ep (y|b, a, σ2e ) p (b) p (a,Aσ2a) p (σ2a) p (σ2e ) dbdadσ2adσ2e

p (b|y) =

ˆa

ˆσ2

a

ˆσ2

e

p(b, a, σ2a , σ2e |y

)dadσ2adσ2e

p (a|y) = . . .

. . .

I Computationally extremely demanding!!!

I Solution - Markov chain Monte Carlo (McMC) methods- sample from full conditional distributions - “easy”p (bi |y,b−i , a, σ2a , σ2e )p (ai |y,b, a−i , σ

2a , σ

2e )

. . .

Page 5: Fitting pedigree based mixed models in BUGS software - talk

Bayesian approachI Recent rise of Bayesian approach to infer parameters

p(b, a, σ2a , σ2e |y

)=

p(y|b, a, σ2e

)p (b) p

(a,Aσ2a

)p

(σ2a

)p

(σ2e

a´σ2

a

´σ2

ep (y|b, a, σ2e ) p (b) p (a,Aσ2a) p (σ2a) p (σ2e ) dbdadσ2adσ2e

p (b|y) =

ˆa

ˆσ2

a

ˆσ2

e

p(b, a, σ2a , σ2e |y

)dadσ2adσ2e

p (a|y) = . . .

. . .

I Computationally extremely demanding!!!

I Solution - Markov chain Monte Carlo (McMC) methods- sample from full conditional distributions - “easy”p (bi |y,b−i , a, σ2a , σ2e )p (ai |y,b, a−i , σ

2a , σ

2e )

. . .

Page 6: Fitting pedigree based mixed models in BUGS software - talk

Available software

Animal breeding andgenetics community

I DMUI GIBBSF90I MCMCglmm R packageI MTGSAMI SIR-BAYESI TMI VCEI . . .

General purpose statisticalprograms

I BUGSI Classic BUGSI WinBUGSI OpenBUGS

µµµµ ττττ

Y6

Y5

Y1

Y2

Y3 Y

4

θθθθ

Page 7: Fitting pedigree based mixed models in BUGS software - talk

Available software

Animal breeding andgenetics community

I DMUI GIBBSF90I MCMCglmm R packageI MTGSAMI SIR-BAYESI TMI VCEI . . .

General purpose statisticalprograms

I BUGSI Classic BUGSI WinBUGSI OpenBUGS

µµµµ ττττ

Y6

Y5

Y1

Y2

Y3 Y

4

θθθθ

Page 8: Fitting pedigree based mixed models in BUGS software - talk

Aim

Fit animal model in BUGS in a general manner

I Previous workI Damgaard (2007) Technical note: How to use Winbugs

to draw inferences in animal models. J. Anim. Sci.,85(6): 1363-1368.http://jas.fass.org/cgi/reprint/85/6/1363.pdf

I Waldmann (2009) Easy and flexible Bayesian inferenceof quantitative genetic parameters. Evolution, 63(6):1640-1643. http://www3.interscience.wiley.com/journal/121675188/abstract

Page 9: Fitting pedigree based mixed models in BUGS software - talk

How?

Describe animal model as a graphical model usingDirected Acyclic Graph (DAG)

µµµµ ττττ

Y6

Y5

Y1

Y2

Y3 Y

4

θθθθ

Page 10: Fitting pedigree based mixed models in BUGS software - talk

DAG for the “alien” example

Figure by Jouke

Page 11: Fitting pedigree based mixed models in BUGS software - talk

DAG for the “alien” exampleσ2

a σ2e

a1 a2

a398 a4

a5 a6

a7 a8

a9109

Figure by Jouke

Page 12: Fitting pedigree based mixed models in BUGS software - talk

DAG for the “alien” exampleσ2

a σ2e

a1 a2105

a398 a4 101

a5 106 a6 93

a7 a8

a9109

Figure by Jouke

Page 13: Fitting pedigree based mixed models in BUGS software - talk

DAG for the “alien” exampleσ2

a σ2e

b1 b2

a1 a2105

a398 a4 101

a5 106 a6 93

a7 a8

a9109

Figure by Jouke

Page 14: Fitting pedigree based mixed models in BUGS software - talk

DAG for the “alien” exampleσ2

a σ2e

b1 b2

a1 a2105

a398 a4 101

a5 106 a6 93

a7 a8

a9109

Figure by Jouke

Page 15: Fitting pedigree based mixed models in BUGS software - talk

DAG using plate notation

y|b, a, σ2e ∼ N(Xb + Za, Iσ2e

)a|A, σ2a ∼ N

(0,Aσ2a

)

A = TWTT

= (I− 1/2P)−1W(I− 1/2PT )−1

A−1 = (T−1)T W−1T−1= (I− 1/2P)T W−1(I− 1/2P)

σ2a

af(k) am(k)

ak

k = 1 : nI

Wk,k

1/2 1/2

bj

j = 1 : nB

µi

σ2e

yi

i = 1 : nY

Zi,k

Xi,j

Page 16: Fitting pedigree based mixed models in BUGS software - talk

DAG description with BUGS model language

## Additive genetic values

for(k in 1:nI) {

a[id[k]] ∼ dnorm(pa[id[k]], Xtau2a[id[k]])

pa[id[k]] <- 0.5 * (a[fid[k]] + a[mid[k]])

Xtau2a[id[k]] <- winv[id[k]] * tau2a

}

a[nU] <- 0 # NULL (zero) holder

## Phenotypes

for(i in 1:nY) {

y[i] ∼ dnorm(mu[i], tau2e)

mu[i] <- b[x[i]] + a[idy[i]]

}

Page 17: Fitting pedigree based mixed models in BUGS software - talk

DAG description with BUGS model language cont.

## Variance priors

tau2e ∼ dgamma(0.001, 0.001)

tau2a ∼ dgamma(0.001, 0.001)

sigma2e <- 1 / tau2e

sigma2a <- 1 / tau2a

## Location priors

for(j in 1:nB) { b[j] ∼ dnorm(0, 1.0E-6) }

Page 18: Fitting pedigree based mixed models in BUGS software - talk

Data

list(## Constants

nI=9, nU=10, nY=6, nB=2,

## Pedigree

id=c( 1, 2, 3, 4, 5, 6, 7, 8, 9),

fid=c(10, 10, 2, 2, 4, 2, 5, 1, 7),

mid=c(10, 10, 1, 10, 3, 3, 6, 10, 8),

winv=c( 1, 1, 2, 1.3, 2, 2, 2.5, 1, 2.3),

## Phenotypes & model variables

y=c(105, 98, 101, 106, 93, 109),

idy=c( 2, 3, 4, 5, 6, 9),

x=c( 1, 1, 2, 2, 2, 1)

)

Page 19: Fitting pedigree based mixed models in BUGS software - talk

Initial values

I Not strictly needed, but its good to provide them to avoidextreme initial valueslist(## Means

b=c(1, -1),

a=c(0, -0.8, 1, 0.6, 1.2, 5, 0, -1, 2, NA),

## Variances

tau2a=1,

tau2e=1

)

Page 20: Fitting pedigree based mixed models in BUGS software - talk

How-to use BUGS?

I Check “Welcome to WinBUGS - the movie” to see thepoint&click work-flowhttp://www.mrc-bsu.cam.ac.uk/bugs/winbugs/

winbugsthemovie.html

I There are also “automatic” interfaces from:I R & S-PLUS (packages R2WinBUGS & BRugs)I SASI MATLABI Excel

Page 21: Fitting pedigree based mixed models in BUGS software - talk

Heritability for the "alien” example - prior effect1

Non-informative priortau2e ∼ dgamma(1, 1)tau2a ∼ dgamma(1, 1)

0.0 0.2 0.4 0.6 0.8 1.0

Informative priortau2e ∼ dgamma(5, 120)tau2a ∼ dgamma(15, 240)

0.0 0.2 0.4 0.6 0.8 1.0

1For mathematical details see Sorensen & Gianola (2002) - Example2.21 (p. 109-111)

Page 22: Fitting pedigree based mixed models in BUGS software - talk

Heritability for the "alien” example - prior effect1

Non-informative priortau2e ∼ dgamma(1, 1)tau2a ∼ dgamma(1, 1)

0.0 0.2 0.4 0.6 0.8 1.0

Informative priortau2e ∼ dgamma(5, 120)tau2a ∼ dgamma(15, 240)

0.0 0.2 0.4 0.6 0.8 1.0

1For mathematical details see Sorensen & Gianola (2002) - Example2.21 (p. 109-111)

Page 23: Fitting pedigree based mixed models in BUGS software - talk

Heritability for the "alien” example - prior effect1

Non-informative priortau2e ∼ dgamma(1, 1)tau2a ∼ dgamma(1, 1)

0.0 0.2 0.4 0.6 0.8 1.0

Informative priortau2e ∼ dgamma(5, 120)tau2a ∼ dgamma(15, 240)

0.0 0.2 0.4 0.6 0.8 1.01For mathematical details see Sorensen & Gianola (2002) - Example

2.21 (p. 109-111)

Page 24: Fitting pedigree based mixed models in BUGS software - talk

Conclusions

I Graphical model formulation enabled fitting animal modelin BUGS in a general manner - this provides an easy wayto use Bayesian approach to fit animal models

I Several animal model extensions are already developed!I environmental effectsI genetic groupsI reduced animal modelI maternal modelI multiple trait modelI repeatability and random regression modelI uncertain parentageI non-Gaussian traits

Page 25: Fitting pedigree based mixed models in BUGS software - talk

Conclusions

I Graphical model formulation enabled fitting animal modelin BUGS in a general manner - this provides an easy wayto use Bayesian approach to fit animal models

I Several animal model extensions are already developed!I environmental effectsI genetic groupsI reduced animal modelI maternal modelI multiple trait modelI repeatability and random regression modelI uncertain parentageI non-Gaussian traits

Page 26: Fitting pedigree based mixed models in BUGS software - talk

Any questions?

Figure by Jouke

Page 27: Fitting pedigree based mixed models in BUGS software - talk

AbstractPedigree based mixed model (commonly called animal model) is an important class ofstatistical models for inference of quantitative genetic parameters in various fields suchas animal and plant breeding, evolutionary biology and human genetics. In last yearsBayesian statistics has been introduced to a set of standard statistical procedures of aquantitative geneticists’ toolbox, due to the ever increasing complexity of fittedmodels. While several specific programs can be used to fit animal model usingBayesian approach, none of them provide and easy to use and flexible environment forthe development and testing of models. It is common to use favourite programminglanguage to develop the needed programs, but this requires a considerable amount ofprogramming and statistical skills. A viable alternative is to use general purposestatistical packages. BUGS (Bayesian Using Gibbs Sampling) is a popular and fairlyflexible program for the Bayesian analysis of complex statistical models using MarkovChain Monte Carlo methods. Recently two reports of fitting animal model in BUGSwere given, but both failed to provide a generic procedure that can be usedindependently of the collected data. Here, a generic description of animal model ispresented using the concept of graphical models. This description was translated toBUGS language and fitted to a small example. Comparison with other programsrevealed the validity of a new procedure. Tests with other data sets showed thatBUGS can be used to efficiently fit animal model for medium sized data sets. Usingthese results quantitative geneticists can now easily use Bayesian approach to fitanimal model in BUGS.