! ! QTL via weighted likelihood of three covariance matrices and mean structs ! #define nvar 1 #define startqpar 3 ! nvar*(nvar+1) +1 #define endqpar 3 ! nvar*(nvar+2) #ngroups 3 Calculate variance components and frequency matrices Calculation Begin Matrices; ! Parameters A Full 1 1 Free ! half deviation between homozygotes P Full 1 1 Free ! allele freq D Full 1 1 ! deviation of heterozygote from mean of homozygs E Lower nvar nvar Free ! random envt R Lower nvar nvar Free ! background residual sib resemblance ! Constants H Full 1 1 ! .5 I Unit 1 1 ! for 1-p N Full 1 1 Free Grand m mean J Full 3 5 ! IBD 2 coefficients K Full 9 5 ! IBD 1 coefficients L Full 9 5 ! IBD 0 coefficients S Full 1 1 ! 1/16 T Full 1 1 ! 2.0 U unit 3 1 End Matrices; ! Parameters Matrix A 1 ! Matrix D .5 (uncomment for VD) Matrix R 1 Matrix E 1 Matrix P .5 Matrix S .0625 Bound .0001 .9999 P 1 1 ! Constants Matrix H .5 Matrix T 2 Matrix J ! IBD 2 sixteenths of p^4 p^3q p^2q^2 pq^3 q^4 4 4 4 0 0 ! AA AA 0 4 16 4 0 ! Aa Aa 0 0 4 4 4 ! aa aa Matrix K ! IBD 1 sixteenths of p^4 p^3q p^2q^2 pq^3 q^4 8 4 0 0 0 0 4 8 0 0 0 0 0 0 0 0 4 8 0 0 0 4 16 4 0 0 0 8 4 0 0 0 0 0 0 0 0 8 4 0 0 0 0 4 8 Matrix L ! IBD 0 sixteenths of p^4 p^3q p^2q^2 pq^3 q^4 4 0 0 0 0 0 4 0 0 0 0 0 4 0 0 0 4 0 0 0 0 0 16 0 0 0 0 0 4 0 0 0 4 0 0 0 0 0 4 0 0 0 0 0 4 Begin Algebra; Q = I-P; B = P.P.P.P_P.P.P.Q_P.P.Q.Q_P.Q.Q.Q_Q.Q.Q.Q ; ! p^4 p^3q p^2q^2 pq^3 q^4 V = T.P.Q.(A+D.(Q-P))^T ; ! Additive genetic variance (q^2 in old notation) W = (T.P.Q.D)^T ; ! Dominance genetic variance M = n+A _ n+D _ n-A ; F = M|M ; G = M@U | U@M ; X = J*B@(\sum(j*b)~); ! relative proportions only required so no 1/16 needed Y = K*B@(\sum(k*b)~); Z = L*B@(\sum(l*b)~); End Algebra; End Group; Title build covariance matrices Calculation Begin Matrices; A comp = v1 D comp = w1 E lower 1 1 = E1 R lower 1 1 = R1 H Full 1 1 = H1 U unit 3 1 V unit 9 1 B full 1 1 = p1 J full 1 1 = A1 K full 1 1 = D1 End Matrices; Begin Algebra; S = R.R ; ! Shared residual P = E.E+S; ! Phenotypic variance Q = S; ! Cov of IBD 2 L = S; ! Cov of IBD 1 T = P|Q_Q|P ; ! IBD 2 var-cov O = P|L_L|P ; ! IBD 1 var-cov Z = P|S_S|P ; ! IBD 0 var-cov W = U@T_V@O_V@Z;! Vectorized 21-component covariance matrices X = A|D|E|R|J|K|B; End Algebra; option mxx=x.mat option append option format=(7(F13.6,1x)) End Title QTL model with heterogeneity and weights Data NInput=6 NModel=21 ! READ IN IBD WEIGHTS FOR THE 3 SIBSHIP TYPES RECTANGULAR FILE=mxgh2.rec LABELS famid sib1 sib2 p2 p1 p0 Select sib1 sib2 p0 p1 p2 ; Definition p0 p1 p2 ; Begin Matrices ; F Comp = F1 G Comp = G1 K Full 1 1 ! p(i)'s go here L Full 1 1 ! p(i)'s go here M Full 1 1 ! p(i)'s go here W Comp = W2 X Comp = X1 Y Comp = Y1 Z Comp = Z1 End Matrices ; Specify K p2 Specify L p1 Specify M p0 Means F_G_G ; Covariance W ; Weights K@X_L@Y_M@Z ; Options rs samecov multiple issat ! option samecov tells it not to re-invert cov matrix as it doesn't change End Drop @.5 2 End ! Eliminate effects of QTL Drop 1 End