GenABEL Tutorial for GWA Analysis
GenABEL Tutorial for GWA Analysis
1 Overview 7
1.1 Download necessary files . . . . . . . . . . . . . . . . . . . . . . . 9
2 Introduction to R 11
2.1 Basic R data types and operations . . . . . . . . . . . . . . . . . 11
2.2 Data frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3 Exploratory analysis of qualitative and quantitative traits . . . . 28
2.4 Regression analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.5 Answers to exercises . . . . . . . . . . . . . . . . . . . . . . . . . 40
3
4 CONTENTS
Overview
7
8 CHAPTER 1. OVERVIEW
Introduction to R
In this section we will consider the basic R data types and operations, as well
as tools for the analysis of qualitative and quantitative traits. Only basic R
functionality – the things which are crucial to know before we can proceed to
genetic association analysis – will be covered within this section. If you want
to make most of your data, though, we strongly recommend that you improve
your knowledge of R using books other than this one. A number of excellent
manuals (’An introduction to R’, ’Simple R’, ’Practical Regression and Anova
using R’, and others) is available free of charge from the R project web-site
([Link]
In the first part of this chapter you will learn about the most important
R data types and will learn how to work with R data. Next, we will cover ex-
ploratory data analysis. The chapter will end with an introduction to regression
analysis.
[1] 6
[1] 0.6666667
(division)
> 2^3
11
12 CHAPTER 2. INTRODUCTION TO R
[1] 8
(power)
> 2 - 3
[1] -1
(subtraction)
> 2 + 3
[1] 5
(summation)1 .
Mathematical functions, such as square roots, base-10 logarithm, and expo-
nentiation, are available in R as well:
> sqrt(5)
[1] 2.236068
> log10(2.24)
[1] 0.350248
> exp(0.35)
[1] 1.419068
[1] 1.418337
R functions include not only the standard mathematical ones, but also a
wide range of statistical function, for example, probability density functions of
many probability distributions. We will make extensive use of these at a later
stage, when computing significance and estimating statistical power.
For any function with a name say ’fun’, help may be obtained by typing
’help(fun)’ (or ?fun) on the command line2 .
R help pages have a standard layout, documenting usage of the function,
explaining function arguments, providing details of implementation and/or us-
age, explaining the value returned by the function, and giving references and
examples of the function use.
Most of the documented functions have examples of their usage at the
end of the ’help’ page, and these examples can be evaluated in R. E.g. try
’example(log10)’.
1 For
a complete list of arithmetic operations try help("+").
2 If
you run R directly from the Linux, OS X or Windows command line (i.e. not in RStudio
or the Windows R environment), you can exit the help by typing q.
2.1. BASIC R DATA TYPES AND OPERATIONS 13
> a <- 2
> b <- 3
Typing the variable name on the R command line will return its value, e.g.
> b
[1] 3
> exp(log10(sqrt(a+b)))
[1] 1.418337
gives the expected result we have obtained earlier using numerical arguments.
While the variables ’a’ and ’b’ contain single numeric values, variables in
general can be multi-dimensional; a one-dimensional example of such is the
vector (or array). Let us create an example vector and experiment with it:
Here, ’c()’ is a function, which combines its arguments to make a vector. This
vector is then assigned to a variable named ’v’.
Now, let us try different operations with this vector:
> v + 1
[1] 2 4 6 8 12
14 CHAPTER 2. INTRODUCTION TO R
It is easy to see that the result is a vector, which is obtained by adding one to
each element of the original vector v. Other arithmetic operations and mathe-
matical functions behave in the same way, e.g. the operation is performed for
each element of the vector, and the results are returned:
> 1/v
> log(v)
[1] 2 5 8 11 16
You can see that the summation was done element-wise, i.e. the first element of
the result vector is obtained as the sum of the first elements of v and ov, the
second is the sum of the second elements, and so forth.
Other arithmetic operations with two vectors are performed in the same
element-wise manner:
> v * ov
[1] 1 6 15 28 55
(multiplication)
> v^ov
(power).
The vector operations considered above returned a same-length vector as
output. There are others – statistical and summary – functions which evaluate
a vector as a whole and return a single value as output. For example, to obtain
a sum of elements of a vector, use
> sum(v)
[1] 27
Other examples of such functions are length, returning the number of ele-
ments of a vector, mean, returning the mean, var, returning the variance, etc.:
> length(v)
[1] 5
2.1. BASIC R DATA TYPES AND OPERATIONS 15
> mean(v)
[1] 5.4
> var(v)
[1] 14.8
One of the basic, and probably most used, data operations in R is sub-setting.
This refers to an operation which helps you deriving a subset of the data. Let
us create a short vector and play a bit with sub-setting. This vector will contain
5 simple character strings:
> a <- c("I am element 1", "I am element 2", "I am element 3",
+ "I am element 4", "I am element 5")
> a
[1] "I am element 1" "I am element 2" "I am element 3" "I am element 4"
[5] "I am element 5"
To find out what is the value of the i-th element of this vector, you can
sub-set it by a[i]. For example the 3rd elements is:
> a[3]
You can also select a bigger sub-set, e.g. all elements from 2 to 4:
> a[c(2:4)]
[1] "I am element 2" "I am element 3" "I am element 4"
Here, the operation c(2:4) stands for ’combine numbers from 2 to 4 into a
vector’. An equivalent result is obtained by
> a[c(2, 3, 4)]
[1] "I am element 2" "I am element 3" "I am element 4"
We can also easily get disjoint elements; e.g. if you want to retrieve elements
1, 3, and 5, you can do that with
> dje <- c(1, 3, 5)
> dje
[1] 1 3 5
> a[dje]
[1] "I am element 1" "I am element 3" "I am element 5"
Imagine you need to derive the IDs of the people with height over 170 cm.
To do that, we need to combine several operations. First, we should run the
logical function > 170 on the height data:
This returns a logical vector whose elements are ’TRUE’, when a particular
element of the tmphgt satisfies the condition > 170. The returned logical vector,
in turn, can be applied to sub-set any other vector of the same length3 , including
itself. Thus if you want to see the heights in people that are taller than 170 cm,
you can use
> tmphgt[vec]
As you can see, only the elements of tmphgt for which the corresponding value
of vec was ’TRUE’, are returned. In the same manner, the logical vector vec can
be applied to select elements of the vector of IDs:
> tmpids[vec]
You can combine more than one logical condition to derive sub-sets. For
example, to see what are the IDs of people taller than 170 but shorter than 190
cm, you can use
> tmpids[vec]
”expanded” to the total length by repeating the original vector head-to-tail. However, we will
not use this in our exercises.
2.1. BASIC R DATA TYPES AND OPERATIONS 17
[1] 2 3 4
> tmpids[vec]
You can see that now vec contains a vector whose elements are the indices of
the elements of tmphgt for which the logical condition holds.
Sub-setting for 2D objects (matrices) is done in a similar manner. Let us
construct a simple matrix and do several sub-setting operations on it:
To obtain the element in the 2nd row and 2nd column, you can use
> a[2, 2]
[1] 22
To access the element from the second row and third column, use
> a[2, 3]
[1] 32
Note that here, the row index (2) comes first, and the column index (3) comes
second.
To obtain the 2 × 2 set of elements contained in upper left corner, you can
do
> a[1:2, 1:2]
[,1] [,2]
[1,] 11 21
[2,] 12 22
4 Because it treats NAs for you
18 CHAPTER 2. INTRODUCTION TO R
1 2 3
1 1 4 7
2 2 5 8
3 3 6 9
Table 2.1: Vector representation of a matrix. Elements in the table are the
vector indices of the matrix elements.
[,1] [,2]
[1,] 11 31
[2,] 13 33
> a[1,]
[1] 11 21 31
> a[, 3]
[1] 31 32 33
. . . or columns 1 and 3:
[,1] [,2]
[1,] 11 31
[2,] 12 32
[3,] 13 33
> a[2, 2]
[1] 22
> a[5]
[1] 22
2.1. BASIC R DATA TYPES AND OPERATIONS 19
This way of accessing the elements of a matrix is based on the fact that
each matrix can be represented as a vector whose elements are numbered con-
secutively: the element in the upper-left corner has index 1, the element in
the second row of the first column has index 2, and the last element in the
bottom-right corner has the maximal value, as shown in Table 2.1.
You can sub-set matrices using logical conditions or indexes like you can
with vectors. For example, if we want to see which elements of a are greater
than 21, we can run
> a > 21
or, better
[1] 5 6 7 8 9
Note that in the latter case, a vector whose elements give the 1-D indicess of the
matrix, is returned. This vector indicates the elements of matrix a, for which
the condition (a > 21) is satisfied.
You can obtain the values of the matrix’s elements for which the condition
is fulfilled either by
[1] 22 23 31 32 33
or using
[1] 22 23 31 32 33
Once again, the latter method should be preferred. Consider the example
where some elements of the matrix are missing (NA) – a situation which is
common in real data analysis. Let us replace element number 5 with NA and
perform sub-setting operations on the resulting matrix:
> a
[1] NA 23 31 32 33
[1] 23 31 32 33
You can see that when a[a > 21] was used, not only the elements which are
greater than 21 were returned, but also NA was. As a rule, this is not what you
want, and which should be used unless you do want to make some use of the
NA elements.
In this section, we have generated a number of R data objects. Some of these
were numeric (e.g. vector of heights, tmphgt) and some were character, or string
(e.g. vector of study IDs, tmpids). Sometimes you need to figure out what the
class of a certain object is. This can be done using the class() function. For
example,
> tmphgt
> class(tmphgt)
[1] "numeric"
> tmpids
> class(tmpids)
[1] "character"
> a
> class(a)
[1] "matrix"
2.1. BASIC R DATA TYPES AND OPERATIONS 21
> a[1, ]
[1] 11 21 31
> class(a[1, ])
[1] "numeric"
which says that elements (at least of the first row) are numeric. Because all
elements of a matrix should have the same class, we can conclude that a is a
matrix containing numeric values.
At this point, it is worthwile inspecting what data objects were created
during our work. This can be done with the ls() command:
> ls()
Obviously, this ”list” command is very useful – you will soon find that it is
just too easy to forget the name of a variable which took a long time to create.
Sometimes you may wish to remove some of the data objects because you do
not need then anymore. You can remove an object using the rm() command,
where the names of objects to be deleted are listed as arguments. For example,
to remove the tmphgt and tmpids variables you can use
If you now look up what data objects are still left in you workspace with the
ls() command
> ls()
you find that you have successfully deleted tmphgt and tmpids.
At this point, you can exit R by typing q() on the command line and pressing
Enter.
Summary:
• You can get access to the top-level R documentation via the [Link]()
command. To search help for some keyword keywrd, you can use the
[Link](keywrd) command. To get a description of some function
fun, use help(fun).
• You can use R as a powerful calculator
22 CHAPTER 2. INTRODUCTION TO R
matrix always contains variables of the same data type, e.g. character or numeric, whereas a
data frame may contain variables of different types
24 CHAPTER 2. INTRODUCTION TO R
The aff (affected) variable here codes for a case/control status. Conventi-
nally, cases are coded as 1 and controls as 0. You can also see several ”NA”s,
which denotes a missing observation.
1. Investigate the types of the variables present in data frame assoc. For
each variable, write down the class.
A data frame may be thought of as a matrix which is a collection of (potentily
different-type) vectors. All sub-setting operations discussed before for matrices
are applicable to a data frame, while all operations dicussed for vectors are
applicable to a data frame’s variables.
Thus, as any particular variable present in a data frame is a conventional
vector, its elements can be accessed using the vector’s indices. For example, if
you would like to know what are the ID, sex and affection status for the person
with index 75, you can request
> assoc$subj[75]
[1] 75
> assoc$sex[75]
[1] 1
> assoc$aff[75]
[1] 0
Alternatively, using the matrix-style of sub-setting, you can see all the data
for person 75:
> assoc[75,]
subj sex aff qt snp4 snp5 snp6
75 75 1 0 1.014664 A/B B/A B/B
In the same manner as with matrices, you can get data for e.g. subjects 5 to
15 by
> assoc[5:15,]
subj sex aff qt snp4 snp5 snp6
5 5 0 0 0.1009220 A/B B/A B/A
6 6 1 0 -0.1724321 A/B A/A A/A
7 7 0 0 -0.3378473 B/B A/A A/A
8 8 0 0 -1.7112925 A/A B/B <NA>
9 9 1 0 -0.4815822 A/B B/A B/A
10 10 1 0 1.2281232 A/A B/B B/B
11 11 0 0 0.5993945 A/B B/A B/A
12 12 0 0 1.9792190 A/A B/B B/B
13 13 1 0 1.5435921 A/A B/B B/B
14 14 0 0 -1.6242738 A/B B/A B/A
15 15 0 0 -0.5160331 A/A B/B B/B
2.2. DATA FRAMES 25
The result is actually a new data frame containing data only on people with
index ranging from 5 to 15:
> x <- assoc[5:15,]
> class(x)
[1] "[Link]"
> dim(x)
[1] 11 7
[1] 12 13 33 41 54 68 72 76 89 106 118 142 156 161 175 181 193 219 241
[1] 12 13 33 41 54 68 72 76 89 106 118 142 156 161 175 181 193 219 241
At the same time, if you only want to check what the IDs of these people are,
try
> assoc$subj[vec]
[1] 12 13 33 41 54 68 72 76 89 106 118 142 156 161 175 181 193 219 241
Or, if we are interested to find what the IDs and the SNP genotypes are of
these people, we can try
> assoc[vec, c(1, 5, 6, 7)]
here, we select people identified by vec in the first dimension (subjects), and by
c(1, 5, 6, 7) we select the first, fifth, sixth and seventh column (variable).
The same result can be obtained using variable names instead of the vari-
ables’ indices. To remind you the variable names can be found with:
> names(assoc)
And now make a vector of the variable names of interest and filter the data
based on it:
> namstoshow <- c("subj", "snp4", "snp5", "snp6")
> assoc[vec, namstoshow]
[1] 75
2.2. DATA FRAMES 27
instead of assoc$subj[75].
While it is possible to explore the data presented in a data frame using
the sub-setting operations and screen output, and modify certain data elements
using the assignment (”<-”) operation, you can also explore and modify the data
contained in a data frame6 by using the fix() command (e.g. try fix(assoc)).
However, normally this is not necessary.
With attached data frames, a possible complication is that later on you may
have several data frames which contain variables with the same names. The
variable which will be used when you directly use the name would be the one
from the data frame attached last. You can use the detach() function to remove
a certain data frame from the search path, e.g. after
> detach(assoc)
we cannot use a direct reference to the name (try subj[75]) anymore, but have
to use the full path instead:
> assoc$subj[75]
[1] 75
Summary:
• The list of available objects can be viewed with ls(); the class of some
object obj can be examined with class(obj).
• You can attach a data frame to the search path by attach(frame). Then
the variables contained in this data frame may be accessed directly. To
detach the data frame (because, e.g. , you are now interested in another
data frame), use detach(frame).
2. What is the value of variable 1 for person 75? Check the value of this
variable for the first ten people. Can you guess what the first variable
is?
3. What is the sum of variable 2? Can you guess what data variable 2
contains?
[1] 129
[1] 0.516
This way to compute the proportion would only work correctly if there are no
missing observations (lenght() returns the total length of a variable, including
NAs).
Because of the way the males are coded, the same answer is reached by
> mean(sex)
[1] 0.516
However, that would not have worked if the sex was coded differently, e.g. with
”1” for males and ”2” for females.
Let us now try to find out the mean of the quantitative trait qt. By def-
inition, the mean of a variable, say x (with the i-th element denoted as xi )
is
ΣN x i
x̄ = i=1
N
where N is the number of measurements.
If we try to find out the mean of qt by direct use of this formula, we first need
to find out the sum of the elements of qt. The sum() function of R precisely
does the operation we need. However, if we try it
> sum(qt)
[1] -29.79333
2.3. EXPLORATORY ANALYSIS OF QUALITATIVE AND QUANTITATIVE TRAITS29
this returns ”NA”. The problem is that the qt variable contains ”NA”s (try qt
to see these) and then, by default, ”NA” is returned. We can, however, instruct
the sum() function to remove ”NA”s from consideration:
> sum(qt, [Link]=TRUE)
[1] -29.79333
[1] -0.1191733
This result, however, is not correct. The length() function returns the total
length of a vector, which includes ”NA”s as well. Thus we need to compute the
number of elements in qt that are not missing.
For this, we can use R function [Link](). This function returns TRUE if
the supplied argument is missing (NA) and FALSE otherwise. Let us apply this
function to the vector assoc$qt:
> [Link](qt)
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[49] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[61] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[73] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[85] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[97] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[109] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[121] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[133] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[145] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[157] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[169] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[181] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[193] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[205] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[217] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[229] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[241] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
var, etc.
30 CHAPTER 2. INTRODUCTION TO R
> 
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[46] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[76] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[91] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[106] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[121] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[136] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[151] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[166] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[181] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[196] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[211] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[226] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[241] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> sum()
[1] 250
[1] -0.1191733
While this way of computing the mean is enlightening in the sense of how
missing values are treated, the same correct result should be normally achieved
by supplying the [Link]=TRUE argument to the mean() function:
[1] -0.1191733
The function table(x) produces a frequency table for the variable x. Thus,
we can use
> table(sex)
sex
0 1
121 129
8A hidden trick here is that arithmetic operations treat TRUE as one and FALSE as zero.
2.3. EXPLORATORY ANALYSIS OF QUALITATIVE AND QUANTITATIVE TRAITS31
which, again, tells us that there are 129 males and 121 females in this data set.
This function excludes missing observations.
Tables of other qualitative variables, such as affection status and SNPs, can
be generated in the same manner.
As with arithmetic operations and mathematical functions, most of the R
operations can be combined within a single line. Let us try to combine logical
conditions and the table() command to check the distribution of number of
affected in men and women separately:
> table(aff[which(sex==1)])
0 1
98 31
> table(aff[which(sex==0)])
0 1
96 25
On the R command line pressing the “up-arrow” button makes the last
typed command re-appear (pressing it one more time will bring you to the
one before the last, so on). This is very handy when you have to repeat the
same analysis of different variables
aff
sex 0 1
0 96 25
1 98 31
Here, the first variable (sex) is presented in rows and the second (affection
status) in columns.
As is usually the case with R, the output may be saved as a new object (of
class ’table’, which is a variety of a matrix):
32 CHAPTER 2. INTRODUCTION TO R
[1] "table"
> a
aff
sex 0 1
0 96 25
1 98 31
[1] 31
aff
sex 0 1
0 0.384 0.100
1 0.392 0.124
0 1
0 0.384 0.100
1 0.392 0.124
In the above table, we see what proportion of people belong to four different
classes (affected male, affected female, unaffected male and unaffected female).
We may also be interested in the proportion of males in affected and unaffected.
This may be achieved by
> [Link](a, 2)
aff
sex 0 1
0 0.4948454 0.4464286
1 0.5051546 0.5535714
aff
sex 0 1
0 0.7933884 0.2066116
1 0.7596899 0.2403101
data: a
p-value = 0.547
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.6409648 2.3156591
sample estimates:
odds ratio
1.213747
snp5
aff A/A B/A B/B
0 31 88 71
1 9 26 17
We can also look up the proportion of affected among different genotypic groups
> [Link](a, 2)
snp5
aff A/A B/A B/B
0 0.7750000 0.7719298 0.8068182
1 0.2250000 0.2280702 0.1931818
showing that proportion of cases is similar in the ’A/A’ and ’A/B’ genotypic
groups and somewhat decreased in ’B/B’. It is easy to test if this affection is
statistically independent of genotype by doing a χ2 test
> [Link](a)
data: a
X-squared = 0.3874, df = 2, p-value = 0.8239
34 CHAPTER 2. INTRODUCTION TO R
which gives a (insignificant) genotypic association test with two degrees of free-
dom.
However, testing Hardy-Weinberg equilibrium, testing allelic effects, and
even computation of allelic frequency is not so straightforward. Such specific
genetic tests are implemented in special R libraries, such as genetics and
GenABEL-package and will be covered in later sections of this document.
At this moment we will switch to exploratory analysis of quantitative traits.
We will make use of the srdta data supplied with the GenABEL-package. As you
can remember from an earlier exercise, that library is loaded with library(GenABEL)
and the data are loaded with data(srdta). Then the phenotypic data frame
may be accessed through phdata(srdta).
summary is quite a useful function which may operate in different ways for
objects of different classes. Try summary(phdata(srdta)).
Histogram of phdata(srdta)$qt1
400
300
Frequency
200
100
0
−4 −2 0 2
phdata(srdta)$qt1
● ●
●
6
● ●
● ● ●
● ● ● ● ● ●
●● ●●●●●● ● ●●
●
●● ● ●●● ● ● ●●●
● ●
● ●● ● ● ● ● ●●●
●● ●●● ● ● ● ●●●● ● ●
● ● ●
●● ● ● ●● ●●● ●●
●●
●
●● ●●● ●●●●●●● ● ●● ● ● ●
● ● ●● ● ●● ●● ●
●●●●
●●●● ●●●
●
●●● ●● ●●●● ●● ● ●● ●●
● ●● ●●
● ●● ●●● ●● ●●● ● ● ●● ●
● ●
● ●
● ●●●●
●● ●
●●●●● ●●●●● ● ●● ●●● ● ●●●●
● ●●●● ●●●
●
●●
●● ● ●
●● ●
●● ●●● ●●● ●● ●●●●●● ●●●●
●
●●
●
●● ●●●● ●● ● ●
●
4
●● ● ● ●●● ● ●●
● ●● ●
●●●●
● ●●
●● ●●●●● ●●●● ●●
●●●●●●●●● ●●
●● ●● ●●●● ● ● ●●● ● ● ●●●●●●
● ● ●● ●●
●●
●●●● ● ●● ●
●● ● ● ●●● ● ●
●●●●●●●●●
●●
●
●●
●
●●
●●
●●
●●
●
●
●●●●
●●●
●
●
●
●
●
●●
●
●
●
●
●
● ●
●●
●●
●●
●●●●
●
●●●
●●
●
●●
●●●●●
● ●
●●
●
●●●●●● ● ●● ●
● ●● ●
●● ● ● ● ●●●
●●
● ● ●
●● ● ●
● ●● ●●●●● ●● ● ●
● ●
● ●
●● ● ● ●
phdata(srdta)$qt3
●●● ●
●● ●●
● ●
●●●● ●●●●
● ●●
● ● ●●●●● ●
●● ● ● ● ● ● ●● ●●●● ●
● ● ●
●●● ●●●●
● ●
●
●●●●
●●●●●●●●
●●
●●
●●●●●
●
●
●
●●
●
●
●●
●●●
●
●●
●●
●
●●●● ●
●
●
●
●●
●●●●
●
●●●●●●
●●
●
●●
●●●
●●
●
●
●
●●●
● ●
●●●●● ●●
●●●
● ● ● ●
●
●●●● ●● ● ●●●
●
●●
●●●
●
●●●
●●●
●
●●●●●
●●●●●
●●●
●●
● ●
● ●●●●● ● ●●
●
●● ●● ●
● ● ● ●
●● ●●● ●●● ● ●● ●
●●●● ● ●●●●● ●● ●●●●●●
●
●● ●
●● ●● ●●
●● ●
●● ●● ●● ● ●● ●● ●
●● ● ●
●
● ●●● ●●●
●
●●
●●●●●●●
● ●●●
● ●
● ●
●
●●
● ● ●● ● ● ● ● ● ●
●● ●●
● ●● ●
●● ●
● ●●●
● ● ●
●
●●
●●
●●
●
●●●
●●●
●
●
●
● ●
●●●
●
●
●
● ●●
●
●●●●●
●●
●●●
●
● ●
●
●
●
●
●
●●●●
●
●
●●
●●
●●
●
●●
●
●
●
●
●
● ●●
●●●
●●
● ●●
●
●
●●●●
●●●●
●●●●●● ● ●● ●
●●● ●● ●●●
●●●●
●●●●
●
●●
● ●●●●
●
●●
●●● ●●● ●
●●
●●●
●
●●
●●●
●
●●
●●
●● ●●
●●
●●●●
●
●
●●
●● ●●
●●
●●
● ●●
●●●●● ●
● ●●
●● ●
● ● ● ● ●● ● ● ●●
●
●
●
●●
●● ●● ●●
●
●●●●●●
●
●●
●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●●
●●●
●
●●
●●
●
●
●●
●
●
●●●
●●●
●
●
●
●
●
●●
●
●
●
● ●
●
●
●●
●●
●●
●●
●
●
●
●
●●●
●
●
●●
●
●●
●●●●●●
●
●●●●●
● ●●●●
●●●
●● ● ● ● ● ● ●
● ●●●● ●
●●●
●●
●
●
●●●
●●
●●
● ●
● ●
●
●
●● ●
●●
●●
●● ●●●●●
● ●●
●●
●● ●●●●
●
● ●
●●
●● ●
●● ● ●●
● ●●
● ● ●● ● ●●●● ● ●
●
●●●●●● ●
●● ●●● ● ●
●●● ●
●●● ●●
● ●●
●●●● ●
●
●●●●●●
●●●
●● ●●
●●
● ●●●●●●● ●●
●
● ● ●●● ● ●
●
●●●
● ● ●
● ●●
● ●
●
●
●
●
●
●
●●●
●
●
●●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●●●
●
●
●
●
●
●
●
●
●
●●
●●
●
●●●●●
●●
●
●●●
●
●●●
●
●
●
●
●
●
●●●●
●
●●●
●●
●
●●
●
●
●●
●
●●●
●●●
●
●
●
●●
●●●●
●
●
●●●
● ●
●●
●●●●● ●● ● ● ● ●
●
● ●●● ●● ●●●●●
● ● ● ●● ●●
●●● ● ●●
● ● ●● ●●● ● ●● ●
2
●
●●● ● ● ●● ●
●●
●
● ●●
●●● ●●●
●●
●●
●●
●●●
●●●●
●
●●
●●●●
●●●●● ●●
●● ●●●●
● ● ●●
● ●●● ●
●●●
● ●●
● ●●
●● ● ● ● ● ● ●● ● ●●
● ● ● ● ● ●●●● ●
● ● ● ● ●● ● ●●●●●
●
●●●●●
● ● ●●
● ●
●● ●●● ●●●●
●●●
● ●●●●
●●●●●● ●
● ●
●● ●
●
● ●● ●● ●● ● ● ●●
●●
●●
●
●●
●
●
●●●
●
●●
●
●
●
●●
●
●
●
●
●
●
●●
● ●
●●
●●
●
●●
●●
● ●●●
●
●●
●
●
●
●●
● ●
●
●
●
●●
●●●●
●
●
●●●
● ●●●
●●●
●●●●
●● ●
● ●● ●●
●● ● ● ● ● ●●
● ● ●●●● ● ●
●● ●●● ●
●●
● ●● ● ● ●●
●●
● ●● ●●●●● ●●●●●
● ●● ●●● ●● ●
●●
●●
●●
●●
●●●
●●
●
●●●●
●
●
●● ●●
● ●
●●●●
● ●
●
● ● ●
●● ●●●
● ●●●●
●●●●● ●● ●● ●●
● ● ●● ●●
● ● ●
● ●
●● ●●● ●
●●●● ●● ● ●
●●● ●
●●●● ●
●●●
●●●●
●● ●●
●● ● ● ● ●
● ●
● ● ● ●
● ●● ●●● ●
● ●●
●●●● ●● ● ●
●● ●
● ● ● ●
●●
● ● ●
● ●●● ● ●●●●● ● ●●● ●● ●●●● ● ● ●●● ●
● ● ●● ●●
●● ● ●●●●●
●●●● ●
● ●
● ●
● ● ●
●● ●●
●● ●●
●●● ●
●
●● ● ● ●●● ●●
●●● ● ●● ●● ●●●●● ●●
●
●● ● ●
● ● ●●
●
●
●●●●●● ●●● ●● ● ●●● ● ●
● ●● ● ● ●●● ● ● ●● ●● ● ● ●
● ●
● ● ● ● ●●
●
● ● ● ● ●● ● ● ●
●●
● ●●
0
● ● ●● ● ● ●
● ● ●
● ● ●
● ●
●
−2
−4 −2 0 2
phdata(srdta)$qt1
●● ●●
30 40 50 60 70
30 40 50 60 70
● ●●●● ●●
●
●
●
●
●
●● ● ●● ●●●
● ● ●●●●● ●
● ● ●●●●● ● ●
phdata(srdta)$age
phdata(srdta)$age
●
●● ●●●● ●● ●● ●
● ●● ●
●● ●
●
●
●
●
●
●
●
●
●● ●
●●●
●●
●
●●
●
●●
●
●
●
●
● ●
●
●●
●
●● ●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●●
●
●
●
●●
●
●
●● ●
●
●
●●
●
● ●● ● ●
●
●●
●●●
● ●●●
●
●
●●●
●●
●●
●●●●
●
●
●●●●●
●●
● ●●
●
●●
●
●●
●
●●
●
●
●●
●●
●
● ●
●
●●
●●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●●●
●●● ●
●
●●
●
●●
●
●● ●
●●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●
●
●
●
●●
●●●●●
●●●
●
●●
●
●● ●
●● ●
●●
●
●●
●
●●
●
●●
●●
●●
●
●●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●●
●
●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●●
●●●
●
●●
●
●
●
●●
●●
●
●●
●
●●●●●
●
●●
●
●● ●● ●
●●●
●
●
●●
●●
●●
●
●●
●
●●●
●
●
●●
●●
●
●
●●
●
●
●
●●
●
●
●
●●●
●
●
●
●●
●
●●●
●
●
●●●
●
●
●
●
●●
●
●●
●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●●
●●
●
●
●●●
●
● ●● ●
●
●
●●
● ●● ●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●●
●●
●
●
●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●
●●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●●
●●
●
●
●
●
●●●●
●●
●●● ●●●
● ● ●
●
●●
●
● ● ●
●
●●
●●
●●
●●
●
●●
●●
●
●●
●
●
●
●●
●●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●●
●
●
●●
●●
●
●
●●
●
●
●
● ●
●●
●
●
●●●
●
●●
●
●
●●● ● ●
●●
●
●● ●
● ●
●
● ●
●●
●
●●
●
●
●●●
●●
●●
●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●
●
●●
●
●●
●
●●
●●
●
●
●●
●
●
●●●
●
●●
●
●
●
●●
●
●
●●
●●●
●●
●
● ●●
●●
●
●●
●● ● ●
●●
●
●●
● ●●● ●●
●●
●
●
●●
●
●
● ●
●
●
●
●●
●
●
●●●
●
●
●
●
●●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●●
●
●
●●
●
●
●
●
● ●
●
●
●
●●
●●
●
●●
●●
●●
●
●●●
●
● ● ● ●
●
●
●●
● ● ●●
●
●●●
●
●●●
●
●●●●
●
●●
●
●
●●
●
●●
●
●
●●
●
●●
●●
●
●●
●
●●
●●
●●
●
●
●●●
●
●
●●
●
●●
●
●
●●
●
●●●
●●
●●
●●
● ●
●
●
●●
●
● ● ● ●
●
●●●
●●
●
●●
●●
●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●●
●
●
●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●●
●
●
●●●●
●●
●
●
●●
●
●
●●●
●●
●●
●●●●●●●
●
●
●●
●
● ●●●●●
●●
●●
●●
●●
●
●
●
●●
●
●
●●
●
●●
●
●
●●
●●
●●
●
●
●
●
●●
●●
●
●
●
●●
●●
●
●●
●●
●
●
●
●
●
●●
●●
●
●●
●
●
●●●● ●
●
●
●●
●
●
●
●
● ● ●●
●●●●●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●●
●●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●
●●
●
●● ●●
●●
● ●
●●●
●●
●
●
●
●● ●
●
●●
●
●●
●
● ●
●
●●●●
●
●●
●●
●
● ●●
●
●
●
●●
●●● ●
●●
●
●●●●● ●●
●
●●
●●
●
●● ●●●●● ●● ●
●●
●
●
●●●●●
●●●
●●
●●●
●●
●● ● ●
●
●●● ●
●●●●●
●● ●
●● ● ● ●
● ●
● ●
30 40 50 60 70 −2 0 2 4 6
phdata(srdta)$age phdata(srdta)$qt3
● ●
●● ●●
●
6
6
●●●● ● ●●
● ●●●●● ● ●● ●●
●
●●
phdata(srdta)$qt3
phdata(srdta)$qt3
● ● ●●● ●
● ● ●● ●● ●
●●
●●●●●●
●● ●●
● ●
● ●
●●
●●
●● ●
●●
●● ●●
●●
●● ●
●
●
●
●
●
●
●● ●● ●● ●●
●
●
●●
●
●
●●●
●●
●
●●●
●●
●●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●●
●
●
●●
●
●
●
● ●●
●
●● ● ●
●●
●● ●
●
●●
●
●
●
●
●
●
●
● ●●● ● ●●
●●
● ●●●●●
●●
● ●
●
●●
●●
●●
●●
●●
●●
●●
●●
●●
●●●
●●
● ●●● ● ●●
●
●
●●
●
● ● ● ●
●●●
● ● ● ● ●● ●
4
●●●●●●● ●●
● ●
● ●
●●●
●
●●
●●
●
●●
●●
●
●●
●
●●
●
●●
●●●●
●●●
●
●●
●●
●●
●●●
●●
● ●●● ●● ● ●
●
●
●●
●●● ●
●●●
● ●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
● ●●
●●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●●●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●●●●
●●
●●
● ● ●●
●
●
●
●
●
●
●
●●●● ●●●●● ●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●●
●●●
● ●●
●● ● ●●
●
●
●
●
●
●
●●
●
●
●●●●● ●
●
● ●
●●●
●
●●
●
●
●●
●●
●●
●
●●
●
●●
●●
●
●●
●
●●
●
●●
●●
●
●●
●●
●
●●
●
●●
●●
●●
●
●
●
●●
●●
●
●
●
●●●
●
●●●●●●● ●
●●
●
●
● ●●●●●●
● ●
●●
●
●
●●
●
●
●
●
●●●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
● ● ●●
●● ● ●●
●
●
●
●
●
●
●●
●
● ●●●●
●●● ●●●
●●● ●
●●
●
●●
●
●●
●
●●
●●●
●
●●
●
●
●●
●
●
●●
●
●●
●●
●●
●
●
●
●
●●
●
●
●●
●●
●
●●
●
●●
●●●●
●
●●
●●
●
●●●
●●●● ●● ●
●
●
●●
●
●
2
● ●● ● ●
● ●
●
●●
● ●
●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●●●
●●
●●
●
●
●●
●
●●
●●
●
●
●●
●
●
●●
●●
●
●●●
●
●●
●●
●
●
●●●
●●●
●
●
●●●● ● ● ●
●●
●
●
●
●●●● ●●● ●
●●
●
● ●
●
●
●●
●
●●
●●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
● ●
●
●●
●
●
●
●●●● ● ●
●●
●
●
●
●
●
●
●●
●
●
● ●● ●● ●
● ●
● ●
●
●● ●
●
● ●●
●● ●
●●
●
●
●●
●●●
●● ●
●●
● ●●●
●● ●
●
●
●
●●●
●●
●●● ●
●●● ●●●●●
● ●
●
●●
●●
●●
●●●
●
●●
●●
●
●
●●●
●
● ●
●
●●
●●●●
●●
● ●●● ● ●
●
●●
●
●
●
● ● ●●● ● ●●
●● ●●●
● ●●
●●
●
●●●
●
●●
●●
●
●●
●●
●●
● ●●
●●●●
●
●●●
●● ● ●
●●
●
●
●●
● ●●
●●●●●● ●
●●●●
●●
●
●
●
●
●
●
●●
●
● ●
●
●●●●
● ●
●●●●
●●
●
●
●
●
●
●
●●
●
●● ●●● ● ●
●
0
●
●
●● ● ●
●
●
●
●●● ● ●● ●●
●
● ● ●●
−2
−2
● ●
30 40 50 60 70 −2 0 2 4 6
phdata(srdta)$age phdata(srdta)$qt3
--------------------------------
Trait sex has 2500 measurements
Missing: 0 ( 0 %)
Mean = 0.51 ; s.d. = 0.5
NO outliers discovered for trait sex
--------------------------------
Trait age has 2500 measurements
Missing: 0 ( 0 %)
Mean = 50.0378 ; s.d. = 7.060125
NO outliers discovered for trait age
--------------------------------
Trait qt3 has 2489 measurements
Missing: 11 ( 0.44 %)
Mean = 2.60859 ; s.d. = 1.101154
NO outliers discovered for trait qt3
Before you start with the exercise: if a function returns unexpected results,
and you are confident that syntax was right, checking the help page is always
38 CHAPTER 2. INTRODUCTION TO R
a good idea!
The results of this analysis are stored in object ’a’, which has class ’lm’ and
contains many sub-objects:
> class(a)
[1] "lm"
> names(a)
At this moment you do not need to understand all these sub-objects; the mean-
ingful summary of analysis is produced with
> summary(a)
2.4. REGRESSION ANALYSIS 39
Call:
lm(formula = phdata(srdta)$qt2 ~ phdata(srdta)$age + phdata(srdta)$sex)
Residuals:
Min 1Q Median 3Q Max
-5.65 -1.80 -1.03 -0.31 883.08
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.55892 4.41667 -0.353 0.724
phdata(srdta)$age 0.14022 0.08668 1.618 0.106
phdata(srdta)$sex 1.30377 1.22393 1.065 0.287
Residuals:
Min 1Q Median 3Q Max
-5.65 -1.80 -1.03 -0.31 883.08
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.55892 4.41667 -0.353 0.724
age 0.14022 0.08668 1.618 0.106
sex 1.30377 1.22393 1.065 0.287
Call:
glm(formula = bt ~ age + sex, family = "binomial")
Deviance Residuals:
Min 1Q Median 3Q Max
-1.992 -1.091 -0.444 1.094 1.917
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.639958 0.330519 -14.038 < 2e-16 ***
age 0.088860 0.006463 13.749 < 2e-16 ***
sex 0.379593 0.084138 4.512 6.44e-06 ***
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
There is strong association between bt and sex and age. If you want to charac-
terise the strength of association to a binary trait with Odds Ratios, take the
exponents of the regression coefficient. For example, the odds ratio associated
with male is
> exp(0.3796)
[1] 1.4617
> idnames(srdta)[1]
2.5. ANSWERS TO EXERCISES 41
[1] "p1"
> male(srdta)[1]
p1
1
[1] "p22"
> male(srdta)[22]
p22
1
[1] 53
[1] 45
[1] 0.508
[1] 0.476
[1] "rs422"
> chromosome(srdta)[33]
rs422
"1"
> map(srdta)[33]
rs422
105500
42 CHAPTER 2. INTRODUCTION TO R
The map positions for and distance between markers 25 and 26 are:
> pos25 <- map(srdta)[25]
> pos25
rs365
91250
rs372
92750
rs372
1500
In this so-called for-loop the variable i cycles through all names in assoc and
for each of them it uses the cat function to print the name of the variable and
its class. The \n is the code for a new line.
> phdata(srdta)[75, 4]
[1] -0.04
[1] "p75"
[1] "p1" "p2" "p3" "p4" "p5" "p6" "p7" "p8" "p9" "p10"
[1] 1275
This is the sex variable – so there are 1275 males in the data set.
Answer of Exercise 6. Explore assoc
The number of affected (coded with ’1’) and unaffected (’0’) is
> table(aff)
aff
0 1
194 56
aff
0 1
0.776 0.224
snp4
A/A A/B B/B
109 105 29
> [Link](t)
snp4
A/A A/B B/B
0.4485597 0.4320988 0.1193416
44 CHAPTER 2. INTRODUCTION TO R
[1] 2500
Number of variables:
> length( names( phdata(srdta) ) )
[1] 7
[1] 2500 7
[1] 48
[1] 48
[1] 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 0 0 0 0 1 1 1 0 1 1 1 1 0 1 1 1 0 0 0 0
[39] 1 0 1 0 0 0 0 1 1 1
2.5. ANSWERS TO EXERCISES 45
[1] 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 0 0 0 0 1 1 1 0 1 1 1 1 0 1 1 1 0 0 0 0
[39] 1 0 1 0 0 0 0 1 1 1
[1] 26
[1] 1.128701
[1] 1.093374
The histogram for qt2 looks strange (you can generate it using hist(phdata(srdta)$qt2)):
it seems there are a few very strong outliers. You can also see that with summary:
> summary( phdata(srdta)$qt2 )
Introduction to genetic
association analysis in R
When analyzing several (dozens of) SNPs, facilities of base R are sufficient
and efficient for data storage and analysis. Few specific test, such as these
of Hardy-Weinberg Equilibrium (HWE) and Linkage Disequilibrium (LD), are
implemented in different libraries, e.g. genetics and GenABEL-package.
In this section, we will describe library genetics and will make use of it to
guide you through simple genetic analysis exercise using a small example data
set. In the last part, you will investigate a bigger data set as based on the
knowledge obtained in the first part, and will answer the questions.
> library(genetics)
47
48CHAPTER 3. INTRODUCTION TO GENETIC ASSOCIATION ANALYSIS IN R
The file you have loaded contains single data frame assocg. Let us load
> #load("RData/[Link]")
> # load assocbase data and convert snps into proper 'genetics' format
> load("RData/[Link]")
> assocg <- assoc
> assocg$snp4 <- [Link](assocg$snp4)
> assocg$snp5 <- [Link](assocg$snp5)
> assocg$snp6 <- [Link](assocg$snp6)
and briefly explore it:
> class(assocg)
[1] "[Link]"
> names(assocg)
[1] "subj" "sex" "aff" "qt" "snp4" "snp5" "snp6"
> dim(assocg)
[1] 250 7
You can see that assocg looks remarkably similar to the previously explored
data frame assoc (section 2.2, page 22). Indeed, they are almost equivalent.
Let us present the data for the subjects 5 to 15 and compare this output to that
presented on page 25:
> assocg[5:15,]
subj sex aff qt snp4 snp5 snp6
5 5 0 0 0.1009220 A/B B/A B/A
6 6 1 0 -0.1724321 A/B A/A A/A
7 7 0 0 -0.3378473 B/B A/A A/A
8 8 0 0 -1.7112925 A/A B/B <NA>
9 9 1 0 -0.4815822 A/B B/A B/A
10 10 1 0 1.2281232 A/A B/B B/B
11 11 0 0 0.5993945 A/B B/A B/A
12 12 0 0 1.9792190 A/A B/B B/B
13 13 1 0 1.5435921 A/A B/B B/B
14 14 0 0 -1.6242738 A/B B/A B/A
15 15 0 0 -0.5160331 A/A B/B B/B
The data are identical. However, the SNP data presented in the new data frame
have special class genotype, as implemented in genetics library:
> class(assocg$snp4)
[1] "genotype" "factor"
Previously, the SNP genotypes were coded as characters. This new way of
presentation allows library genetics to recognise the SNP data as genetic and
analyse them accordingly.
Let us attach the assocg data frame and explore what data analysis advan-
tages are achieved by application of library genetics.
3.2. EXPLORING GENETIC DATA WITH LIBRARY GENETICS 49
> attach(assocg)
As we noted in section 2.2, testing Hardy-Weinberg equilibrium, testing
allelic effects, and even computation of allelic frequency is not so straightforward
in base R. These tests, are, however, easy with library genetics. To see the
allelic frequencies and other summary statistics for a SNP, you can use
> summary(snp4)
Genotype Frequency:
Count Proportion
B/B 29 0.12
A/B 105 0.43
A/A 109 0.45
NA 7 NA
To check these characteristics in controls and cases separately, you can use
> summary(snp4[aff==0])
Genotype Frequency:
Count Proportion
B/B 22 0.12
A/B 81 0.43
A/A 87 0.46
NA 4 NA
> summary(snp4[aff==1])
50CHAPTER 3. INTRODUCTION TO GENETIC ASSOCIATION ANALYSIS IN R
Genotype Frequency:
Count Proportion
B/B 7 0.13
A/B 24 0.45
A/A 22 0.42
NA 3 NA
Let us check if HWE holds for the SNPs described in this data frame. We
can do exact test for HWE by
> [Link](snp4)
data: snp4
N11 = 109, N12 = 105, N22 = 29, N1 = 323, N2 = 163, p-value = 0.666
data: snp4[aff == 0]
N11 = 87, N12 = 81, N22 = 22, N1 = 255, N2 = 125, p-value = 0.6244
Pairwise LD
-----------
D D' Corr
Estimates: 0.2009042 0.9997352 0.8683117
X^2 P-value N
LD Test: 354.3636 0 235
The output shows results of the test for significance of LD, and estimates of the
magnitude of LD (D′ and correlation, r). To obtain r2 , you can either square
the correlation manually
3.2. EXPLORING GENETIC DATA WITH LIBRARY GENETICS 51
> 0.8683117*0.8683117
[1] 0.7539652
> LD(snp4,snp5)$"R^2"
[1] 0.7539652
The latter command is possible because the LD() function actually computes
more things than it reports. This is quite common for R functions. You can
apply names() function to the analysis objects to see (at least part of ) what
was actually computed. Try
> ld45 <- LD(snp4,snp5)
and check what are the sub-objects contained in this analysis object
> names(ld45)
[1] "call" "D" "D'" "r" "R^2" "n" "X^2"
[8] "P-value"
Any of these variables can be accessed through object$var syntax, e.g. to
check D ′ we can use
> ld45$"D'"
[1] 0.9997352
To check LD for more that two SNPs, we can compute an LD analysis object
by
> ldall$"P-value"
to see significance,
> ldall$"D'"
for D′ and
> ldall$"R^2"
52CHAPTER 3. INTRODUCTION TO GENETIC ASSOCIATION ANALYSIS IN R
1.2
1.0
0.8
0.6
0.4
0.2
0.0
−0.2
for r2 .
You can also present e.g. r2 matrix as a plot by
> image(ldall$"R^2")
A more neat way to present it requires specification of the set of threshold
(break points) and colors to be used (you do not need to try this example if you
do not want):
> image(ldall$"R^2",breaks=c(0.5,0.6,0.7,0.8,0.9,1),col=[Link](5))
Resulting plot is shown at figure 3.1.
For any R command, you can get help by typing help(command). Try
help(image) if you are interested to understand what are ”breaks” and ”col”;
or try help([Link]) to figure this color schema out.
1.2
1.0
0.8
0.6
0.4
0.2
0.0
−0.2
Figure 3.2: r2 plot for snp4, snp5 and snp6. Above diagonal: LD in cases;
below: controls
and even present it results for cases and controls on the same graph (you do not
need to produce this graph, which is presented at the figure 3.2):
> image(ldcases$"R^2",breaks=c(0.5,0.6,0.7,0.8,0.9,1),col=[Link](5))
> image(t(ldcontr$"R^2"),breaks=c(0.5,0.6,0.7,0.8,0.9,1),col=[Link](5),add=T)
54CHAPTER 3. INTRODUCTION TO GENETIC ASSOCIATION ANALYSIS IN R
Call:
lm(formula = qt ~ snp4)
Residuals:
Min 1Q Median 3Q Max
-2.63700 -0.62291 -0.01225 0.58922 3.05561
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.081114 0.092517 -0.877 0.382
snp4A/B -0.108366 0.132079 -0.820 0.413
snp4B/B -0.006041 0.201820 -0.030 0.976
From the summary output, it is clear that the model assumes arbitrary (esti-
mated) effects of the genotypes AA, AB and BB. Neither effect of AB nor BB
is significant in this case. The global test on two degrees of freedom (bottom of
the output) is also not significant.
If you want to include some covariate into your model, e.g. sex, you can
easily do that by adding the term to the formula:
> summary(lm(qt~sex+snp4))
Call:
lm(formula = qt ~ sex + snp4)
Residuals:
3.4. EXAMPLE ASSOCIATION ANALYSIS 55
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.110298 0.115260 -0.957 0.340
sex 0.053018 0.124493 0.426 0.671
snp4A/B -0.104429 0.132628 -0.787 0.432
snp4B/B -0.002452 0.202340 -0.012 0.990
Residuals:
Min 1Q Median 3Q Max
-2.57049 -0.64596 -0.00264 0.61094 3.01970
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.20579 0.13834 -1.487 0.138
sex 0.22649 0.18647 1.215 0.226
snp4A/B 0.05222 0.19024 0.274 0.784
snp4B/B 0.18071 0.28576 0.632 0.528
sex:snp4A/B -0.30191 0.26566 -1.136 0.257
sex:snp4B/B -0.35508 0.40531 -0.876 0.382
> table(snp4,add4)
add4
snp4 0 1 2
A/A 109 0 0
A/B 0 105 0
B/B 0 0 29
> summary(lm(qt~add4))
Call:
lm(formula = qt ~ add4)
Residuals:
Min 1Q Median 3Q Max
-2.54813 -0.62104 -0.02754 0.60584 3.00652
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.10476 0.08710 -1.203 0.230
add4 -0.03563 0.09133 -0.390 0.697
The model assuming dominant action of the ’A’ allele means that the means
of genotypes ’AA’ and ’AB’ are the same. This is equivalent to the model of
recessive action of ’B’ allele. To code SNP4 according to this model, we can use
function replace:
dom4
snp4 0 1
A/A 109 0
A/B 0 105
B/B 0 29
To test association with a binary outcome, we will use function glm with
binomial family:
> summary(glm(aff~snp4,family="binomial"))
3.4. EXAMPLE ASSOCIATION ANALYSIS 57
Call:
glm(formula = aff ~ snp4, family = "binomial")
Deviance Residuals:
Min 1Q Median 3Q Max
-0.7433 -0.7204 -0.6715 -0.6715 1.7890
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.3749 0.2386 -5.761 8.35e-09 ***
snp4A/B 0.1585 0.3331 0.476 0.634
snp4B/B 0.2297 0.4952 0.464 0.643
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
To make a test of global significance of the SNP effect, you can use
> anova(glm(aff~snp4,family="binomial"),test="Chisq")
Response: aff
In the manner similar to that described for quantitative traits, additive and
dominance/recessive models can be tested by proper coding of the genotypic
variable, e.g. to test the additive model, use
> summary(glm(aff~[Link](snp4),family="binomial"))
Call:
glm(formula = aff ~ [Link](snp4), family = "binomial")
Deviance Residuals:
58CHAPTER 3. INTRODUCTION TO GENETIC ASSOCIATION ANALYSIS IN R
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.4913 0.4164 -3.581 0.000342 ***
[Link](snp4) 0.1272 0.2268 0.561 0.574994
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Now you have learned all commands necessary to answer the questions of
the next section.
Exit R by typing q() command (do not save image) and and proceed to the
self exercise.
Ex. 4 — How many cases and controls are present in the data set?
Ex. 5 — If all subjects are used to test HWE, are there any SNPs out of HWE
at nominal P ≤ 0.05? Which ones?
Ex. 6 — If only controls are used to test the SNPs which are out of HWE in
total sample, are these still out of HWE?
Ex. 8 — For SNPs in strong LD, what is r2 for separate samples of cases and
controls?
3.6. ANSWERS TO EXERCISES 59
Ex. 12 — Test association between aff and snp5 and snp10, allowing for the
SNPs interaction effect. Use arbitrary (not an additive) model. Do you observe
significant interaction? How can you describe the model of concert action of
snp5 and snp10?
Ex. 13 — Test for association between the quantitative trait qt and SNPs
1-10 using additive model. Which SNPs are associated at nominal P ≤ 0.05?
Ex. 15 — Which SNPs are associated with the quantitative trait qt at nom-
inal P ≤ 0.05 when general genotypic (2 d.f. test) model is used?
Ex. 16 — ADVANCED: How can you describe the model of action of the
significant SNPs? Test if the data are compatible with additive/dominant/recessive
model.
Genotype Frequency:
Count Proportion
B/B 199 0.08
A/B 888 0.37
A/A 1287 0.54
NA 126 NA
Genotype Frequency:
Count Proportion
B/B 48 0.09
A/B 213 0.41
A/A 258 0.50
NA 30 NA
Answer (Ex. 5) — Only SNP 1 is out of HWE in the total sample. Here is
a sciript testing all SNPs (no need to reproduce that, just check the results):
> for (i in 1:10) {
+ snpname <- paste("snp",i,sep="")
+ cat("HWE P-value for SNP",snpname,"is",[Link](get(snpname))$[Link],"\n")
+ }
HWE P-value for SNP snp1 is 0.01083499
HWE P-value for SNP snp2 is 1
3.6. ANSWERS TO EXERCISES 61
data: snp1[aff == 0]
N11 = 1029, N12 = 675, N22 = 151, N1 = 2733, N2 = 977, p-value =
0.008393
snp5 NA NA 0.9083237
snp6 NA NA NA
Note that the fact that LD is higher in cases may mean nothing because the
estimates of LD are biased upwards with smaller sample sizes. For example in a
small sample (5 people) of controls we expect even higher LD because of strong
upward bias:
> LD(popdat[which(aff==0)[1:5],8:10])$"R^2"
snp4 snp5 snp6
snp4 NA 0.9995876 0.9995876
snp5 NA NA 0.9995876
snp6 NA NA NA
More elaborate methods, such as that by Zaykin et al. (2006), are required to
contrast LD between sample of unequal size.
data: t
p-value = 0.3104
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.9107753 1.3430565
sample estimates:
odds ratio
1.105811
> summary(glm(aff~sex,family=binomial()))
Call:
glm(formula = aff ~ sex, family = binomial())
Deviance Residuals:
Min 1Q Median 3Q Max
-0.7196 -0.7196 -0.6882 -0.6882 1.7644
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.31970 0.06981 -18.90 <2e-16 ***
sex 0.10062 0.09673 1.04 0.298
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
3.6. ANSWERS TO EXERCISES 63
Deviance Residuals:
Min 1Q Median 3Q Max
-0.7326 -0.7079 -0.7012 -0.6905 1.7675
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.26769 0.04832 -26.238 <2e-16 ***
qt -0.02514 0.04862 -0.517 0.605
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Response: aff
64CHAPTER 3. INTRODUCTION TO GENETIC ASSOCIATION ANALYSIS IN R
Response: aff
Response: aff
Response: aff
Response: aff
Response: aff
Response: aff
Response: aff
Response: aff
Response: aff
Answer (Ex. 12) — It appears that SNP10 genotype is only relevant in these
who are homozygous for the low-risk A allele at the SNP5; in such cases SNP 10
allele B is risk increasing. In these homozygous for SNP 5 A, we observe highly
significant increase in risk for heterozygotes for SNP10 and increased (though
3.6. ANSWERS TO EXERCISES 67
Deviance Residuals:
Min 1Q Median 3Q Max
-0.9906 -0.7340 -0.6323 -0.5215 2.0310
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.50840 0.08905 -16.938 < 2e-16 ***
snp5A/A -0.41802 0.19722 -2.120 0.0340 *
snp5B/B 0.33441 0.13360 2.503 0.0123 *
snp10A/B -0.01403 0.18251 -0.077 0.9387
snp10B/B -0.14983 0.55277 -0.271 0.7863
snp5A/A:snp10A/B 1.48369 0.32750 4.530 5.89e-06 ***
snp5B/B:snp10A/B 0.12989 0.27441 0.473 0.6360
snp5A/A:snp10B/B 0.82348 0.98963 0.832 0.4053
snp5B/B:snp10B/B -0.28562 1.23104 -0.232 0.8165
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Answer (Ex. 14) — Generally, results do not change much: still, SNPs 1, 4,
5, 6 and 9 are significantly associated, and p-values are close to these observed
without adjustment For SNPs
> for (i in 1:10) {
3.6. ANSWERS TO EXERCISES 69
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 2 7.8 3.8995 3.9845 0.01873 *
Residuals 2371 2320.4 0.9787
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 1 0.18 0.18376 0.1841 0.6679
Residuals 2372 2367.23 0.99799
Response: qt
3.6. ANSWERS TO EXERCISES 71
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 2 7.68 3.8417 3.8628 0.02114 *
Residuals 2387 2373.94 0.9945
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 2 6.48 3.2418 3.2798 0.03781 *
Residuals 2380 2352.48 0.9884
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 2 5.49 2.74680 2.7808 0.06219 .
Residuals 2377 2347.91 0.98776
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 2 4.02 2.01212 2.0368 0.1307
Residuals 2365 2336.31 0.98787
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 2 1.38 0.68987 0.6924 0.5005
Residuals 2368 2359.23 0.99630
72CHAPTER 3. INTRODUCTION TO GENETIC ASSOCIATION ANALYSIS IN R
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 2 15.6 7.8014 7.9982 0.0003453 ***
Residuals 2358 2300.0 0.9754
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Response: qt
Df Sum Sq Mean Sq F value Pr(>F)
get(snpname) 2 1.19 0.59456 0.6041 0.5467
Residuals 2381 2343.47 0.98424
Answer (Ex. 16) — For ’snp1’, though the data are compatible with either
additive, dominant or recessive model, the additive model provides best fit to
the data (largest p-value), while the recessive ’B’ model provide the wors fit
(almost significantly worse than the general model):
> table(snp1,[Link](snp1))
snp1 1 2 3
A/A 1287 0 0
A/B 0 888 0
B/B 0 0 199
> table(snp1,([Link](snp1)>=2))
snp1 FALSE TRUE
A/A 1287 0
A/B 0 888
B/B 0 199
> table(snp1,([Link](snp1)>=3))
snp1 FALSE TRUE
A/A 1287 0
A/B 888 0
B/B 0 199
> model_gen <- lm(qt~snp1)
> summary(model_gen)
Call:
lm(formula = qt ~ snp1)
Residuals:
Min 1Q Median 3Q Max
-3.5261 -0.6643 -0.0111 0.6765 3.5462
3.6. ANSWERS TO EXERCISES 73
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.02846 0.02758 -1.032 0.3022
snp1A/B 0.08200 0.04316 1.900 0.0575 .
snp1B/B 0.18644 0.07536 2.474 0.0134 *
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Model 1: qt ~ [Link](snp1)
Model 2: qt ~ snp1
[Link] RSS Df Sum of Sq Pr(>Chi)
1 2372 2320.5
2 2371 2320.4 1 0.04886 0.8232
> anova(model_dom,model_gen,test="Chisq")
Analysis of Variance Table
+ print(summary(model_gen))
+ model_add <- lm(qt~[Link](cursnp))
+ model_dom <- lm(qt~I([Link](cursnp)>=2))
+ model_rec <- lm(qt~I([Link](cursnp)>=3))
+ print(anova(model_add,model_gen,test="Chisq"))
+ print(anova(model_dom,model_gen,test="Chisq"))
+ print(anova(model_rec,model_gen,test="Chisq"))
+ }
Call:
lm(formula = qt ~ cursnp)
Residuals:
Min 1Q Median 3Q Max
-3.4311 -0.6636 -0.0013 0.6737 3.5489
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.02132 0.02972 0.717 0.4733
cursnpA/A 0.02953 0.04423 0.668 0.5044
cursnpB/B -0.14481 0.06192 -2.339 0.0194 *
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Model 1: qt ~ [Link](cursnp)
Model 2: qt ~ cursnp
[Link] RSS Df Sum of Sq Pr(>Chi)
1 2388 2375.7
2 2387 2373.9 1 1.7489 0.1848
Analysis of Variance Table
Model 2: qt ~ cursnp
[Link] RSS Df Sum of Sq Pr(>Chi)
1 2388 2374.4
2 2387 2373.9 1 0.44342 0.5043
Call:
lm(formula = qt ~ cursnp)
Residuals:
Min 1Q Median 3Q Max
-3.4719 -0.6589 -0.0084 0.6622 3.5285
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.01401 0.02878 0.487 0.6264
cursnpA/A -0.09667 0.05611 -1.723 0.0851 .
cursnpB/B 0.05727 0.04607 1.243 0.2140
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Model 1: qt ~ [Link](cursnp)
Model 2: qt ~ cursnp
[Link] RSS Df Sum of Sq Pr(>Chi)
1 2381 2352.7
2 2380 2352.5 1 0.22152 0.6359
Analysis of Variance Table
Call:
lm(formula = qt ~ cursnp)
Residuals:
Min 1Q Median 3Q Max
-3.4784 -0.6753 -0.0064 0.6703 3.5324
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.07617 0.05085 -1.498 0.1343
cursnpB/A 0.09417 0.05886 1.600 0.1097
cursnpB/B 0.14351 0.06096 2.354 0.0186 *
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Model 1: qt ~ [Link](cursnp)
Model 2: qt ~ cursnp
[Link] RSS Df Sum of Sq Pr(>Chi)
1 2378 2348.2
2 2377 2347.9 1 0.27462 0.598
Analysis of Variance Table
Call:
lm(formula = qt ~ cursnp)
3.6. ANSWERS TO EXERCISES 77
Residuals:
Min 1Q Median 3Q Max
-3.5482 -0.6673 0.0074 0.6546 3.6061
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.006298 0.021562 -0.292 0.77026
cursnpA/B 0.162230 0.065729 2.468 0.01365 *
cursnpB/B 1.002439 0.313057 3.202 0.00138 **
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Model 1: qt ~ [Link](cursnp)
Model 2: qt ~ cursnp
[Link] RSS Df Sum of Sq Pr(>Chi)
1 2359 2303.9
2 2358 2300.0 1 3.9528 0.04411 *
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Analysis of Variance Table
Introduction to the
GenABEL-package
In this section, you will become familiar with the GenABEL-package library,
designed for GWA analysis. Compared to the genetics package, it provides
specific facilities for storage and manipulation of large amounts of data, very
fast tests for GWA analysis, and special functions to analyse and graphically
present the results of GWA analysis (thus ”analysis of analysis”).
Start R and load the GenABEL-package library using the command
> library(GenABEL)
After that, load the example data set using the command
> data(srdta)
79
80 CHAPTER 4. INTRODUCTION TO THE GENABEL-PACKAGE
The data frame, which contains all phenotypic data in the study may be
accessed using the phdata function. Let us have a look at the first few rows of
the phenotypic data frame of srdta:
> phdata(srdta)[1:5,]
id sex age qt1 qt2 qt3 bt
p1 p1 1 43.4 -0.58 4.46 1.43 0
p2 p2 1 48.2 0.80 6.32 3.90 1
p3 p3 0 37.9 -0.52 3.26 5.05 1
p4 p4 1 53.8 -1.55 888.00 3.76 1
p5 p5 1 47.5 0.25 5.70 2.89 1
The rows of this data frame correspond to th estudy subjects, and the columns
correspond to the variables. There are two default variables, which are always
present in phdata. The first of these is “id”, which contains study subject
identification code. This identification code can be arbitrary character, numer,
or alphanumeric combination, but every person must be coded with an unique
ID. The second default variable is “sex”, where males are coded with ones (“1”)
and females are coded with zero (“0”).
It is important to understand that this data frame is not supposed to be
directly modified by the user, as its structure is coupled to the structure of
genotypic data. If at some point you need to manipulate (add/delete) the phe-
notypes included in phdata, you need to use such GenABEL-package functions
as [Link] and [Link] (see section 4.2).
The other part of an object of [Link]-class is gtdata, which contains
all GWA genetic information in an object of class [Link] class. It is not
supposed to be modified directly by user. The genotypic data can be accessed
through the gtdata function, e.g.
> gtdata(srdta[1:10, 1:10])
@nids = 10
@nsnps = 10
@nbytes = 3
@idnames = p1 p2 p3 p4 p5 p6 p7 p8 p9 p10
@snpnames = rs10 rs18 rs29 rs65 rs73 rs114 rs128 rs130 rs143 rs150
@chromosome = 1 1 1 1 1 1 1 1 1 1
@coding = 08 0b 0c 03 04 03 0c 04 08 0f
@strand = 01 01 02 01 01 01 02 01 01 01
@map = 2500 3500 5750 13500 14250 24500 27000 27250 31000 33250
@male = 1 1 0 1 1 0 0 1 0 0
@gtps =
40 40 40 80 40 40 40 40 c0 c0
40 40 00 00 40 40 40 c0 40 40
40 40 00 80 40 40 40 40 c0 c0
As you can see, these data are of little direct use as these are stored in an
internal format – you need to coerce that to another data type if you want
to manipulate/analyse these data using non-GenABEL-package functions (see
section ??).
The number of individuals described in an object of [Link]-class can
be accessed through nids function, e.g.
4.1. GENERAL DESCRIPTION OF [Link]-CLASS 81
> nids(srdta)
[1] 2500
[1] 833
The IDs of the individuals included in the study can be accessed via the
idnames function, for example the IDs of the first 7 individuals in the study are
> idnames(srdta)[1:7]
The sex of the individuals can be accessed using the male function:
> male(srdta)[1:7]
p1 p2 p3 p4 p5 p6 p7
1 1 0 1 1 0 0
where males (heterogametic sex) are assigned with “1” and a homogametic sex
(females) are assigned the value “0”.
Names of SNPs can be accessed using the snpnames function; for example
the names of the first 10 SNPs in the srdta are
> snpnames(srdta)[1:10]
[1] "rs10" "rs18" "rs29" "rs65" "rs73" "rs114" "rs128" "rs130" "rs143"
[10] "rs150"
rs10 rs18 rs29 rs65 rs73 rs114 rs128 rs130 rs143 rs150
"1" "1" "1" "1" "1" "1" "1" "1" "1" "1"
• Map position
> map(srdta)[1:10]
rs10 rs18 rs29 rs65 rs73 rs114 rs128 rs130 rs143 rs150
2500 3500 5750 13500 14250 24500 27000 27250 31000 33250
rs10 rs18 rs29 rs65 rs73 rs114 rs128 rs130 rs143 rs150
"TG" "GA" "GT" "AT" "AG" "AT" "GT" "AG" "TG" "CA"
82 CHAPTER 4. INTRODUCTION TO THE GENABEL-PACKAGE
For every SNP, the coding is represented with a pair of characters, for
example “AG”. For an “AG” polymorphism, you may expect “AA”, “AG”
and “GG” genotypes to be found in your population. The order (that is
“AG” vs. “GA”) is important – the first allele reported is the one which
will be used as a reference in association analysis, and thus the effects are
reported for the second allele. You can also access the reference allele with
the method refallele
> refallele(srdta)[1:10]
rs10 rs18 rs29 rs65 rs73 rs114 rs128 rs130 rs143 rs150
"T" "G" "G" "A" "A" "A" "G" "A" "T" "C"
and the effective (or ’coded’) allelel with
> effallele(srdta)[1:10]
rs10 rs18 rs29 rs65 rs73 rs114 rs128 rs130 rs143 rs150
"G" "A" "T" "T" "G" "T" "T" "G" "G" "A"
• The strand on which the coding is reported (’+’, ’-’ or missing, ’u’):
> strand(srdta)[1:10]
rs10 rs18 rs29 rs65 rs73 rs114 rs128 rs130 rs143 rs150
"+" "+" "-" "+" "+" "+" "-" "+" "+" "+"
Summary:
• GenABEL-package uses a special data class, [Link]-class, to store
GWA data.
• To access the content of an object of [Link]-class, a number of
functions is used
> phdata(srdta)[1:5, ]
> class(phdata(srdta))
[1] "[Link]"
> phdata(srdta)[1:5, 2]
[1] 1 1 0 1 1
[1] 1 1 0 1 1
> phdata(srdta)$sex[1:5]
[1] 1 1 0 1 1
> phdata(srdta)[1:5, ]
You can add more than one variable at once using the same function, how-
ever, in this case the second (“newph”) argument of the function should be a
data frame, which contains an ’id’ variable specifing the IDs of the individuals.
Imagine we have the data for individuals ’p1’, ’p2’ and ’p7’ (we will generate
random data for them; pay attention only to the result):
> newvalues <- matrix( rnorm(3*5), 3, 5 )
> newdata <- [Link](id=c("p1", "p2", "p7"),
+ ph1=1, ph2=1, ph3=1, ph4=1, ph5=1)
> newdata[, c(2:6)] <- newvalues
> newdata
p9 NA NA NA
p10 NA NA NA
Finally, if you need, you can delete some phenotypes from the phdata using
[Link] function. Let us delete the phenotypes we have just added:
> srdta <- [Link](srdta,
+ c("age_squared", "ph1", "ph2", "ph3", "ph4", "ph5"))
> phdata(srdta)[1:10, ]
Summary:
[1] "[Link]"
attr(,"package")
[1] "GenABEL"
86 CHAPTER 4. INTRODUCTION TO THE GENABEL-PACKAGE
and genotypc data, which can be accessed via the gtdata function:
> gtdata(ssubs)
@nids = 5
@nsnps = 3
@nbytes = 2
@idnames = p1 p2 p3 p4 p5
@snpnames = rs10 rs18 rs29
@chromosome = 1 1 1
@coding = 08 0b 0c
@strand = 01 01 02
@map = 2500 3500 5750
@male = 1 1 0 1 1
@gtps =
40 40 40
40 40 00
here, the first part of expression sub-sets srdta on selected IDs, and the sec-
ond tells which part of the retrieved sub-set we want to see. You can try
srdta[c("p141", "p147", "p2000"),], but be prepared to see long output,
as all information will be reported.
In a similar manner, we can also select on SNP name. For example, if we
are interested to see information on SNPs ”rs10” and ”rs29” for above people,
we can run
> phdata(srdta[c("p141", "p147", "p2000"), c("rs10", "rs29")])
@nids = 3
@nsnps = 2
@nbytes = 1
@idnames = p141 p147 p2000
@snpnames = rs10 rs29
@chromosome = 1 1
@coding = 08 0c
@strand = 01 02
@map = 2500 5750
@male = 0 0 0
@gtps =
40 40
To see the actual genotypes for the above three people and two SNPs, use
> [Link](srdta[c("p141", "p147", "p2000"), c("rs10", "rs29")])
rs10 rs29
p141 "T/T" "G/G"
p147 "T/T" "G/G"
p2000 "T/G" "G/T"
or
> [Link](srdta[c("p141", "p147", "p2000"), c("rs10", "rs29")])
rs10 rs29
p141 0 0
p147 0 0
p2000 1 1
4.4. EXPLORING GENETIC DATA 89
Summary:
• It is possible to obtain subsets of objects of [Link]-class and
[Link]-class using the standard 2D sub-setting model [i, j], where
i corresponds to study subjects and j corresponds to SNPs.
[1] 64 122 186 206 207 286 385 386 492 514 525 536 545 565 613
[16] 632 649 673 701 779 799 981 1008 1131 1186 1223 1281 1383 1471 1489
[31] 1501 1565 1584 1673 1679 1782 1821 1832 1866 1891 1953 2081 2085 2140 2224
[46] 2268 2291 2384 2420 2453
This shows summary of first three genotypes for people with age greater then or
equal to 65 y.o. The same result may be achieved by sub-setting using a vector
of logical values:
> vec <- (phdata(srdta)$age >= 65)
> table(vec)
vec
FALSE TRUE
2450 50
[1] "p64" "p122" "p186" "p206" "p207" "p286" "p385" "p386" "p492"
[10] "p514" "p525" "p536" "p545" "p565" "p613" "p632" "p649" "p673"
[19] "p701" "p779" "p799" "p981" "p1008" "p1131" "p1186" "p1223" "p1281"
[28] "p1383" "p1471" "p1489" "p1501" "p1565" "p1584" "p1673" "p1679" "p1782"
[37] "p1821" "p1832" "p1866" "p1891" "p1953" "p2081" "p2085" "p2140" "p2224"
[46] "p2268" "p2291" "p2384" "p2420" "p2453"
Let us explore the object returned by the summary function when applied to
[Link] class in more detail:
> a <- summary( gtdata(srdta[vec1, 1:3]) )
> class(a)
[1] "[Link]"
[1] 3 14
> names(a)
Histogram of crate
150
100
Frequency
50
0
crate
3. In controls (bt is 0)
Let us analyse the distribution of call rate in the whole study. For this, we
first need to obtain the vector of call rates:
> sumgt <- summary(gtdata(srdta))
> crate <- sumgt[, "CallRate"]
This vector may be depicted by a histogram
> hist(crate)
which shows that most SNPs have call rate between 93 and 97% (Figure 4.1).
As a next step, you would like to produce a summary table, showing how
many markers had call rate lower than, say, 93%, between 93 and 95%, between
95 and 99% and more than 99%. You can use the catable() command for that:
> catable(crate, c(.93, .95, .99))
The first cut-off category will detect SNPs which are deviating from HWE at
the Bonferroni-corrected P -level.
However, for these data it will make more sense to table the cumulative
distribution:
> catable(hwp, c(0.05/nsnps(srdta), 0.01, 0.05, 0.1), cum=TRUE)
If you would like to investigate the minor allele frequency (MAF) distribu-
tion, the same logic would apply. First, derive the MAF with
> afr <- sumgt[, "Q.2"]
> maf <- pmin(afr, (1. - afr))
Next, generate histograms for frequency and MAF:
> par(mfcol=c(2,1))
> hist(afr)
> hist(maf)
(shown in Figure 4.2) and then generate a table describing the frequency distri-
bution:
> catable(afr, c(0.01, 0.05, 0.1, 0.2, 0.5, 0.8, 0.9, 0.95, 0.99))
Note that we used “0” as the first category – this will give you the number of
monomorphic SNPs which we recommend to exclude from analysis.
Another function, [Link], produces summary SNP statistics per
person. Let us try producing this summary for the first 10 people:
> [Link](srdta[1:10, ])
94 CHAPTER 4. INTRODUCTION TO THE GENABEL-PACKAGE
100
150
80
100
Frequency
Frequency
60
40
50
20
0
afr maf
This table lists the number of genotypes scored for the person, call rate, and
heterozygosity. The outliers who have increased average heterozygosity may be
suggestive of contaminated DNA samples.
Let us analyse the distribution of heterozygosity:
[1] 0.3309457
> hist(het)
The resulting histogram is shown in Figure 4.3. It is easy to see that a few
people have very low heterozygosity, but there are no outliers with extremely
high values.
In this section, we covered the low-level functions summary and [Link].
On these functions a higher level genetic data quality control function, [Link],
is based. That function will be covered in the next section.
Summary:
96 CHAPTER 4. INTRODUCTION TO THE GENABEL-PACKAGE
Histogram of het
1200
1000
800
Frequency
600
400
200
0
het
1 This is something covered later in the section 4.3 (”Sub-setting and coercing [Link]”)
98 CHAPTER 4. INTRODUCTION TO THE GENABEL-PACKAGE
Answer (Ex. 2) — The names of markers located after 2,490,000 b.p. are
> vec <- (map(srdta) > 2490000)
> snpnames(srdta)[vec]
[1] "rs9273" "rs9277" "rs9279" "rs9283"
The names of markers located between 1,100,000 and 1,105,000 b.p. are:
> vec <- (map(srdta) > 1100000 & map(srdta) < 1105000)
> snpnames(srdta)[vec]
[1] "rs4180" "rs4186" "rs4187"
Answer (Ex. 3) — To learn what allele of “rs114” is the reference you need
to run
> coding(srdta)["rs114"]
rs114
"AT"
Here, the first (“A”) allele is the reference and thus the second (“T”) is the
effect allele. Remember that when using the [Link] function to convert
the genotypes to human-readable and R-operatable format, the homozygotes
for reference will be coded as “0”, heterozygotes as “1” and the non-reference
(“effect”) homozygotes will be coded as “2”:
> table([Link]( gtdata(srdta[, "rs114"] )),
+ [Link]( gtdata(srdta[,"rs114"] )))
0 1 2
A/A 1868 0 0
A/T 0 491 0
T/T 0 0 34
To compute the frequency of the effect allele of SNP “rs114” in the total sample,
you can go two ways. First, we can try to take a sum of all “rs114” genotypes
and divide it by twice the number of people:
> a <- [Link](gtdata(srdta[, "rs114"]))
> sum(a)
[1] NA
This, however, returns NA, because some of the genotypes are missing. We can
deal with this problem by running sum() with the option [Link]=TRUE:
> sum(a, [Link]=TRUE)
[1] 559
so the number of “effect” alleles is 559.
However, now we do not know what was the number of people for whom the
genotype was measured! – nids would return the total number of people, but
not the number of those measured for “rs114”.
This problem can be dealt with through using the [Link](A) function which
returns true when some element of A is not measured. Thus, the number of
people with measured genotype for “rs114” is
> nids(srdta)
[1] 2500
4.5. ANSWERS TO EXERCISES 99
Genome-wide association
analysis
In the first parts of this section you will be guided through a GWA analysis of a
small data set. In the last part you will investigate a larger data set by yourself,
do a verification study and will answer the questions. All data sets used assume
a study in a relatively homogeneous population. Try to finish the first part in
the morning and the second part in the afternoon.
Though only few thousands of markers located at four small chromosomes
are used in the scan, we still going to call it Genome-Wide (GW), as the amount
of data we will use is approaches the amount to be expected in a real experiment.
However, because the regions are small, and the LD between SNPs is high, some
specific features (e.g. relatively high residual inflation, which occurs because
large proportion of SNPs are in LD with the really associated ones) are specific
features of this data set, which are not observed in true GWA studies.
Start R and load the GenABEL-package library by typing
> library(GenABEL)
> data(ge03d2ex)
> ls()
[1] "ge03d2ex"
> class(ge03d2ex)
[1] "[Link]"
attr(,"package")
[1] "GenABEL"
To check what are the names of variables in the phenotypic data frame, use
103
104 CHAPTER 5. GENOME-WIDE ASSOCIATION ANALYSIS
> names(phdata(ge03d2ex))
No Mean SD
id 136 NA NA
sex 136 0.529 0.501
age 136 49.069 12.926
dm2 136 0.632 0.484
height 135 169.440 9.814
weight 135 87.397 25.510
diet 136 0.059 0.236
bmi 135 30.301 8.082
You can see that the phenotypic frame contains data on 136 people; the
data on sex, age, height, weight, diet and body mass index (BMI) are available.
Our trait of interest is dm2 (type 2 diabetes). Note that every single piece
of information in this data set is simulated; however, we tried to keep our
simulations in a way we think the control of T2D may work.
You can produce a summary for cases and controls separately and compare
distributions of the traits by
> [Link](ge03d2ex, by=dm2)
height NA
weight NA
diet 1.000
bmi NA
Here, the by argument specifies the grouping variable. You can see that cases
and controls are different in weight, which is expected, as T2D is associated
with obesity.
Similarly, you can produce grand GW descriptives of the marker data by
using
> [Link](ge03d2ex)
It is of note that we can see inflation of the proportion of the tests for HWE at
a particular threshold, as compared to the expected. This may indicate poor
genotyping quality and/or genetic stratification.
We can test the GW marker characteristics in controls by
> [Link](ge03d2ex, ids=(dm2==0))
106 CHAPTER 5. GENOME-WIDE ASSOCIATION ANALYSIS
It seems that indeed excessive number of markers are out of HWE in cases. If no
laboratory procedure (e.g. DNA extraction, genotyping, calling) were done for
cases and controls separately, this may indicate possible genetic heterogeneity
specific for cases.
In essence, the ’[Link]’ function uses the ’summary’ function
to generate the HW P -values distribution. It may be interesting to generate
this distribution using the ’summary’ function You do not need to do so, but this
example shows how you can generate summaries from underlying SNP-tables.
First, we need to compute summary SNP statistics by
Note the you have produced the summary for the gtdata slot of ge03d2ex;
this is the slot which actually contain all genetic data in special compressed
format.
You can see the first 5 rows of this very long summary table by
> s[1:5, ]
Note that the column ’Pexact’ provides exact HWE test P -values we need. We
can extract these to a separate vector by
The first argument used describes the model; here it is rather simple — the
affection status, dm2, is supposed to depend on SNP genotype only.
You can see what information is computed by this function by using
> an0
Here, let us look at the ’Results table’. P1df, P2df and Pc1df are most inter-
esting; the first two are vectors of 1 and 2 d.f. P -values obtained in the GWA
analysis, the last one is 1 d.f. P -value corrected for inflation factor λ (which
is in the lambda object). effB corresponds to the (approximate) Odds Ratio
estimate for the SNP.
Let us see if there is evidence for the inflation of the test statistics; for that
let us obtain λ with
> lambda(an0)
$estimate
[1] 1.033102
5.1. DATA DESCRIPTIVES AND FIRST ROUND OF GWA ANALYSIS109
● ●
12
● ●
●
●●
10
●
●●
●
●●●
●●
●●●
Observed χ2
●
8
●
●●
●●
●
●
●●
●●
●
●●
●
●
●●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●●
●●
6
●
●
●
●●
●
●
●
●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●●
●
●●
●
●●
●
●
●●
●
4
●●
●
●
●●
●
●●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●●
●
●●
●
●
●●
●
●●
●
●
●
●
●●
●
●●
2
●●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●
●
0
0 5 10 15
Expected χ2
Figure 5.1: χ2 − χ2 plot for a GWA scan. Black line of slope 1: expected under
no inflation; Red line: fitted slope.
$se
[1] 0.0005639231
The estimate of λ is 1.03, suggesting inflation of the test and some degree of
stratification. Though the value obtained seems to be small, it should be noted
that λ grows linearly with sample size, so for this small number of cases and
controls the value is worrisome.
The λ is computed by regression in a Q-Q plot. Both estimation of λ and
production of the χ2 − χ2 plot can be done using the estlambda function; this
was already done automatically when running qtscore function, but let us
repeat this manually:
$estimate
[1] 1.033102
$se
[1] 0.0005639231
− log10(P − value)
● ●
●
3
● ● ●
●
●● ● ● ● ● ● ●
●
●
● ●● ● ●
● ●
● ● ● ● ●● ● ●● ●
● ●●● ● ● ●● ●● ● ● ● ●●●●
●
2
●●● ● ● ●●
● ●● ● ●●● ● ● ●●
●
●
● ●
● ●● ●
● ●●● ● ● ● ●●● ● ●
● ●●● ●● ●●●
● ● ●●●● ● ● ● ● ●● ● ●
●●●
● ●● ●
●● ● ●
●●
●●●●● ● ● ● ●●● ●●● ●
● ● ● ●●● ●●●●● ●●
●
●
●●● ●●●●●● ●● ●
● ●● ●● ● ●
●●●●●
●● ●
●●●●●● ● ●●●●
●●●●
●●
● ●●●
● ● ● ● ●●●●
● ●● ●
● ●
●●●●●●
● ●
●●●
●● ●●●●
● ●
●●● ●
●●●●●
● ●●
●● ●
●
●●●
● ● ●●●●
●●● ●
●
●●
● ●
●● ●
● ●●
●●●
● ●
●●
●
●
●
●●
●●●● ●●
●●●●
●●● ●●●
●●
●●●●
●
●
●
●●
● ●●
●
●
● ●
●● ● ● ●●●● ●
● ●● ● ● ●●
● ● ● ● ●●●● ● ●
●
●
1
●
●
●●● ●
●●●●●●●●
●●
●
● ● ● ●
●●
●●●
●●●
●●
●
● ●●●
●●●
●
●
● ●●
●
●●
●●
●
●●
● ●
●
●●
●●●
●●
●●
●
● ●
●●
●
●●● ●
●
●●●●●
●●●●●●
●
●●●●
●●
●
●
●●●
● ●●●●
●●
●●●
●● ●●●
●●●
●●
●
●●
●
● ●●
●
●●●●
●
●●
●
●
●
●
●
●●●
●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●●
●●●
●
●
●
●
●
●●●
●
●●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●●●
●
● ●
●
●
●
●
●●
●
●
●
●●
●
●●●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●●
●
●
●
●●
●●
●
●
●
●
●
●● ●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●
●●●
●
●
●
●●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●
●
● ●
●
●
●
●
●
●●●●
●
●
●
●
●●●●
●
●
●
●
●●
●
●
●●●
●
●
●
●
●●
●
●
●●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●●●
●
●●
●
●●
●●
●●
●
●
●●
●
●
● ●
●●
●
●●
●
●●
●●
●
●●
●●
●
●
●●●
●
●●
●
●●●
●
●
●
●●
●
●
●
●●
●●
● ●
●●
●●
●●
●●
●
●
●
●●
●
●
●●
●
●●
●
●●
●
●
●
●●
●●
●
●●
●●
●
●●
●●
●
●●
●●
●
●● ●●
●
●
●●
●●
●
●
●●
●●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●●
●
●●
● ●
●
●●
●●
●
●●
●
●●
●
●●
●●
●●
●●
●
●●
●
●●
●●
● ●
●
●●
●
●●
●
●●
●
●
●●
●●●
●●●●
●
●●
●
●●
●
●●
●
●
●
●●
●●
●
●
●
●●●
● ●
●
●
●●
●
●●
●
●
●●
●●
●
●
●
●
●
●●●
●
●
●
●●●
●
●
●●
●
●
●
●
●●
●●●
●
●●●
●
●
●
●
●●
●
●●
●
●●●
●
●
●●
●●
●
●
●
●●
●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●
●●
●●
●
●
●●
●●●
●●
●
●●
●●
●
●●
●
●●
●
●●
●
●
●
●●
●
●
●●
●
●
●●●
●
●
●
●●●
●
●●
●
●●
●●
●
●
●●
● ●
●
●●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●●
●
●
●●
● ●
●
●
●
●●
●●
●
●
●●
●●
●
●
●●
●
●●
●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●
●●
●●
●
●
●●
●●
●
● ●
●
●●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●●
●
●●
●●
●
●●
●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●●
●●
●
●
●●
●
●●
●
●
●
●●●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●●
●●
●
●
●●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●
●●
●●
●
●●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●●●
●
●
●●
●
●
●
●●
●
●
●●
●●
●
●
●
●●
● ●●
●
●
●●
●
●
●●
●
●●
●
●●
●●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
● ●
●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●●●
●
●●
●
●
● ●
●
●
●●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
● ●
●●
●●●
●●
● ●
●
● ●
●●●●●●
●
●●●
●●●
●●●
●● ●●●
●●●
●●●●
●●
●●
●●
●
●●
●●
●
●●●
●●
●●
●
●●
●● ●●●
●●●
●●
●●●
● ● ●
●
●●●●●●●
●●● ●
●
●●
●● ●●
●●●
●●●●● ●●
●●
●●
●●
●●
● ●
●
●●
●
●●●
●
●●
●●
●
0
1 2 3 X
Chromosome
● ●
3
●● ● ●●
●● ● ● ● ● ● ●
●
●
● ●● ● ●
● ●
● ● ● ● ●● ● ●● ●
●● ● ● ● ●● ● ● ● ●●●●
●
2
● ●● ● ● ●●● ● ● ●● ●● ● ●●
●
●
●●●
● ●● ●● ● ●●
● ● ●●●● ● ●●
● ● ●● ● ●● ● ● ● ●● ●
● ●● ●
● ●
●● ●● ● ● ● ● ●
●●● ● ●●● ● ●● ● ●● ●● ●
●
●●●
● ● ●●● ●●
●
● ●●
●● ●●● ●●
●●●
●●
●● ●●
●●● ● ● ●●●
●
●●●● ●
●● ● ● ●●
● ● ●●● ● ● ●●
●
● ●
●●●●●
●●●● ●● ●●●●● ●
●●●● ●
●●●●●
● ●●
●● ●
●
●●
●●● ●●● ●
●●
● ●
●
● ●
●●●●●
●● ● ●●●●
●●●
●
● ●●
●
●●●●● ●
●●●
● ●●
●● ●●●●
●●
●●●●●
●
● ●
●●
●
●●●●
●
● ●
● ● ●●●●● ●●●●
● ● ●● ●● ● ● ●●
● ● ● ●
●● ● ●● ● ●
●● ●● ●
1
●
●
●●●●
● ●●
●●
● ●●●●
●●●
●● ●
●●
●●●
●●
●●●
●●
● ●●●
●●●
● ●●
●
●●
●●●
●
●● ●
●
●●
● ●●
●●
●●
●
● ●
●
●
●●●●
●● ●
●
● ●● ●
●●
●●●●●
●
●●●
●●●
●
●
●●
●●● ●●●●●
● ●
●● ●●●●
●●
●●
●●
●
●●
●
● ●
●
●
●●
●● ●●
●●●
●
●●●
●●
●●
●●●●
●●
●● ●●
●●
● ●
●●
●●
●
●●●
●●
●
●●● ●●●
●●●
●
●●
●●●●
●
●●
●
●
●
●●
●
●●●
●
●
●●
●● ●●●
●● ●
●●
●
●●
●
●●
●
●●●●●
●
●
●●
●●●
● ●●
●●
●
●● ●
●
●●
●
●●
●
●
●●
●●●●
●
●
●
● ●●
●
●●●●
●
●●●●
●●●
●●●
●
●
● ●
●●
●●
●
●●
● ●●
●●
●●
●
●●●
●
●●
●●
●
●●●
●
●
●●
●
●●
●
●
●●
●●
●●●●●
●●●
●
●
●●
●
●
●●●
●●
●
●
●●
●●●
●●
●●
●
●
●●
●
●
●
● ●●●●
●● ●
●
●
●●
●
●
●
●●
●
●●
●
●●
●●●
●●●
●
●●●
●
●●●●
●
●●
●● ●
●●
●
●●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●●
●●
●●●●
●●
●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●●
●
●●●
● ●
●●
●●
●
●●
●
●●
●
●●
●●
●●●●
●
●●●
●
●●
●
●
●●
●
●●
●
●●
●● ●
●●
●
●●
●
●
●●
●
●●●
●
●
●
●
●●
●●
●●
●
●●
●
●●
●
●●
●●
●●
●
● ●
●
●
●●
●
●●
●●
●
●●
●
●●
●
●
●●
●●
●●
●
●
●
●●
●
●●●
●●
●
●
●●
●
●
● ●
●
●●●●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●●
●● ●
●●
●●
●
●
●
●● ●
●
●
●●
●
●●
●
●●
●
●
●
●●
●●
●●
●
●
●
●●
●●
●
●●
●
●
●●
●●
●
●●
●●
●
●●
●
●●
●●
●
●
●●
●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●●
● ●
●
●
●
●●
●
●
●●
●●
●
●
●
●●●●
●●
●
●
●●
●
●●
●
●●
●
●●●
●
●
●
●●
●●
●
●●
● ●
●
●●
●
●●
●
●
●●●
●
●●●
●
●
●
●●●
●
●●●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●●
●
●
●
●●
●
●●●
●●
●
●
●
●●
●
●●●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●●
●
●●●
●●
●●
●●
●
●●
●●
●
●●
●
●
●●
●●
●
●
●●
●
●●
●
●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●●
●
●●
●
●●●
●
●
●
●●
●
●●
● ●
●●●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●●
●●
●
●
●
● ●
●
●
●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●●
● ●
●
●●
●
●●
●
●
●●
●●
●
●
●●
●
●
●
●
●
●
●●●
●
●●
●
●●
● ●
●
●●
●
●
●
●
●●
●
●
●
●●
●●●
●●
●
●●
●
●
●●●●
● ●●
●
●●
●
●●●
●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●●● ●
●●●
●●●
●
●●●●●
●●●
●
●●●●
●
●
●●
●●
●●
●
●●
● ●
●●
●
●
●
●●
●
●●
●
●
●●●
●
●
●●
●
●
●●
● ●
●●
●
●
●●●
●
●
●●●●●
●
●●
●●●
●● ●
●
●
●●
●●
●●●
●
●
●●●●
●●
●
●●
●
●
●
●●
●
●●
●●
●
●●●
● ●●
●
●●
●
●●
●
●●
●
●●
●
●●
●●● ●
●
●●
●●
●
●●●●
●●
●
●
●
●●●
●
●
●
●●
●
●●
●
●
●● ●
●
●
●
●●
●
●●
●
●
●●●
●
●
●●
●
●●●●
●
●●
●
●
●
●●●
●
●●
●
●●
●
●
●●●
●
●
●●●
●●
●
●
●
●●●
● ●
●
●
●
●●
● ●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●●●●
●●
●●●
●
●
●
●
●
0
1 2 3 X
Chromosome
Figure 5.2: − log10 (P -value) from the genome scan before QC procedure. Raw
analysis: darker circles; corrected analysis: lighter circles
The ’se’ produced by estlambda can not be used to test if inflation is signif-
icant and make conclusions about the presence of significant or insignificant
stratification.
We can also present the obtained results using the ”Manhatten plot”, where
the SNP genomic position is on the horizontal axis and − log10 of the P -value
is shown on the vertical axis:
> plot(an0)
The resulting plot is show in Figure 5.2. By default, − log10 (P -value) of the
uncorrected 1 d.f. test are shown; see thehelp to figure out how this behaviour
can be changed.
We can also add the corrected P -values to the plot with
> [Link](an0, df="Pc1df", col=c("lightblue", "lightgreen"))
You can see that the P -values corrected by genomic control are uniformly lower
than the P -values from ’raw’ analysis. This is to be expected as genomic control
simply divides the ’raw’ χ2 statistics by a constant λ for all SNPs.
You can also generate a descriptive table for the ”top” (as ranked by P -value)
results by
5.1. DATA DESCRIPTIVES AND FIRST ROUND OF GWA ANALYSIS111
> [Link](an0)
|
| | 0%
|
|======================================================================| 100%
(you may skip the ’quiet=TRUE’ argument, then you will see progress)
Now let us generate the summary of the results
> [Link](an0.e, sort="Pc1df")
Summary:
• The descriptives family of functions was developed to facilitate the
production of tables which can be directly used in a manuscript — it is
possible to save the output as a file, which can be open by Excel or Word.
See e.g. help([Link]) for details.
skip Hardy-Weinberg checks in the first round of QC. This can be achieved by
setting HWE P -value selection threshold to zero ([Link]=0):
> qc1 <- [Link](ge03d2ex, [Link]=0)
Excluding people/markers with extremely low call rate...
4000 markers and 136 people in total
0 people excluded because of call rate < 0.1
6 markers excluded because of call rate < 0.1
Passed: 3994 markers and 136 people
no X/Y/mtDNA-errors to fix
RUN 1
3993 markers and 134 people in total
304 (7.613323%) markers excluded as having low (<1.865672%) minor allele frequency
36 (0.9015778%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (P <0)
1 (0.7462687%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2747262 (s.e. 0.03721277)
3 (2.238806%) people excluded because too high autosomal heterozygosity (FDR <1%)
Excluded people had HET >= 0.4856887
Mean IBS is 0.7709982 (s.e. 0.02094168), as based on 2000 autosomal markers
2 (1.492537%) people excluded because of too high IBS (>=0.95)
In total, 3653 (91.4851%) markers passed all criteria
In total, 128 (95.52239%) people passed all criteria
RUN 2
3653 markers and 128 people in total
80 (2.189981%) markers excluded as having low (<1.953125%) minor allele frequency
0 (0%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (P <0)
0 (0%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2748341 (s.e. 0.01695461)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7745814 (s.e. 0.01793637), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 3573 (97.81002%) markers passed all criteria
In total, 128 (100%) people passed all criteria
RUN 3
114 CHAPTER 5. GENOME-WIDE ASSOCIATION ANALYSIS
Note that normally you will NEVER run this simple form of the QC function –
you should always provide a number of thresholds specific to the platform you
used for genotyping. See help to [Link]() for detailed list of arguments.
The default values used by the function are rather relaxed compared to the
thresholds routinely used nowadays with most of the platforms.
From the output you can see that QC starts with checking the data for SNPs
and people with extremely low call rate. Six markers are excluded from further
analysis due to very low call rate. Next, X-chromosomal errors are identified.
The function finds out that all errors (heterozygous male X-genotypes) are due
to two people with wrong sex assigned and one marker, which looks like an
autosomal one. This actually could be a marker from the pseudoautosomal
region, which should have been arranged as a separate ”autosome”. Nine people
are found to have intermediate inbreeding at the X-chromosome and are also
excluded from analysis.
Then, the procedure finds the markers with low call rate (≤ 0.95 by default)
across people, markers with low MAF (by default, low MAF is defined as less
than a few copies of the rare allele, see help for details); people with low call
rate (default value: ≤ 0.95) across SNPs, people with extreme heterozygosity
(at FDR 0.01) and those who have GW IBS ≥ 0.95. These default parameters
may be changed if you wish (consult the help).
Because some of the people fail to pass the tests, the data set is not guar-
anteed to be really ”clean” after single iteration, e.g. some marker may not
pass the call threshold after we exclude few informative (but apparently having
low quality) samples. Therefore the QC is repeated iteratively until no further
errors are found.
You can generate a short summary of the QC by marker and by person
through
5.2. GENETIC DATA QC 115
> summary(qc1)
$`Per-SNP fails statistics`
NoCall NoMAF NoHWE Redundant Xsnpfail
NoCall 42 0 0 0 0
NoMAF NA 384 0 0 0
NoHWE NA NA 0 0 0
Redundant NA NA NA 0 0
Xsnpfail NA NA NA NA 1
no X/Y/mtDNA-errors to fix
Applying this function does not make any difference for the example data set,
but you will need to use it for the bigger data set.
At this point, we are ready to work with the new, cleaned, data set data1.
However, if we try
> length(dm2)
[1] 136
we can see that the original phenotypic data are attached to the search path
(there are only 128 people left in the ’clean’ data set). Therefore we need to
detach the data by
116 CHAPTER 5. GENOME-WIDE ASSOCIATION ANALYSIS
> detach(phdata(ge03d2ex))
and attach new data by
> attach(phdata(data1))
At this stage, let us check if the first round of QC improves the fit of genetic
data to HWE, which may have been violated due to by genotyping errors which
we hopefully (at least partly!) eliminated:
> [Link](data1)[2]
You can see that the fit to HWE improved, but cases are still have excess number
of markers out of HWE. This may be due to genetic sub-structure.
This step may take few minutes on large data sets or when using old com-
puters!
function
5.3. FINDING GENETIC SUB-STRUCTURE 117
The numbers below the diagonal show the genomic estimate of kinship (aka
’genomic kinship’ or ’genome-wide IBD’), the numbers on the diagonal corre-
spond to 0.5 plus the genomic homozigosity, and the numbers above the diagonal
tell how many SNPs were typed successfully for both subjects (thus the IBD
estimate is derived using this number of SNPs).
Second, we transform this matrix to a distance matrix using standard R
command
> [Link] <- [Link]([Link])
Finally, we perform Classical Multidimensional Scaling by
> [Link] <- cmdscale([Link])
By default, the first two principal components are computed and returned.
This may take few minutes on large data sets or when using old computers!
> cl2
0.15
●
●
●●
●
0.10
●
● ●
● ●● ●
● ● ●
● ● ●● ●
● ●● ● ●
0.05
● ● ●
● ●● ●
● ●
● ● ●● ●● ● ●●
● ● ●
[Link][,2]
● ● ●●
● ●
●
●● ● ●
● ● ●● ●
0.00
● ● ●●●●
● ● ●●
● ●● ●
● ●
● ●● ●
●
● ●●● ● ●
−0.05
●● ● ● ●
● ● ●
● ●
● ●
● ● ●
● ● ● ●
● ● ●
●
● ● ●
●● ● ●
−0.10
● ● ●
●
●
●
−0.15
[Link][,1]
Figure 5.3: Mapping samples to the space of the first two Principle Components
resulting from analysis of genomic kinship. Red dots identify genetic outliers.
Now you will need to use the BIGGER cluster for to select study subjects.
Whether this will be cl1 or cl2 in you case, is totally random.
We can form a data set which is free from outliers by using only people from
the bigger cluster:
> data2 <- data1[cl2, ]
5.3. FINDING GENETIC SUB-STRUCTURE 119
no X/Y/mtDNA-errors to fix
RUN 1
3573 markers and 124 people in total
40 (1.119507%) markers excluded as having low (<2.016129%) minor allele frequency
0 (0%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (FDR <0.2)
0 (0%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2780246 (s.e. 0.01642372)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7704698 (s.e. 0.01247442), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 3533 (98.88049%) markers passed all criteria
In total, 124 (100%) people passed all criteria
RUN 2
3533 markers and 124 people in total
0 (0%) markers excluded as having low (<2.016129%) minor allele frequency
0 (0%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (FDR <0.2)
0 (0%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2780246 (s.e. 0.01642372)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.771093 (s.e. 0.01246105), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 3533 (100%) markers passed all criteria
In total, 124 (100%) people passed all criteria
> summary(qc2)
120 CHAPTER 5. GENOME-WIDE ASSOCIATION ANALYSIS
Indeed, in the updated data set several markers do not pass our QC criteria
and we need to drop a few markers. This is done by
> data2 <- data2[qc2$idok, qc2$snpok]
This is going to be our final analysis data set, therefore let us attach the phe-
notypic data to the search path, so we do not need to type phdata(data2)$...
to access dm2 status or other variables:
> detach(phdata(data1))
> attach(phdata(data2))
> ####
> #[Link] <- data2
> #save([Link], file="[Link]")
> ####
Before proceeding to GWA, let us check if complete QC improved the fit of
genetic data to HWE:
> [Link](data2)[2]
$`Cumulative distr. of number of SNPs out of HWE, at different alpha`
X<=1e-04 X<=0.001 X<=0.01 X<=0.05 all X
No 1 2.000 2e+01 101.000 3533
Prop 0 0.001 6e-03 0.029 1
> [Link](data2[phdata(data2)$dm2==1, ])[2]
$`Cumulative distr. of number of SNPs out of HWE, at different alpha`
X<=1e-04 X<=0.001 X<=0.01 X<=0.05 all X
No 0 1 17.000 79.000 3533
Prop 0 0 0.005 0.022 1
5.4. GWA ASSOCIATION ANALYSIS 121
You can see that now there is no excessive number of SNPs out of HWE in the
sample (total, or cases, or controls)
You can see that the relation to weight is maintained in this smaller, but
hopefully cleaner, data set; moreover, the relation to age becomes borderline
significant.
If you check descriptives of markers (only HWE part shown)
> [Link](data2)[2]
you can see that the problems with HWE are apparently fixed; we may guess
that these were caused by Wahlund’s effect.
Run the score test on the cleaned data by
> [Link] <- qtscore(dm2, data2, trait="binomial")
122 CHAPTER 5. GENOME-WIDE ASSOCIATION ANALYSIS
3
●
●
●
● ●
● ●
● ●
● ●
● ● ●
● ●
− log10(P − value)
● ● ● ●
● ● ●
●● ●●
●
● ● ●● ●
2
● ● ●
● ● ● ● ●
● ● ●● ●
● ●
● ● ● ● ●
●
● ●
● ● ● ●● ● ●●
● ●●
● ● ●● ●
●
●● ● ●●● ● ● ●● ● ● ● ●●
● ● ● ● ● ● ● ● ●
● ●● ●●●● ● ● ● ● ●● ● ●●●
● ●● ●● ● ● ●●
●● ●●●
● ●● ● ● ●●● ● ● ●
● ● ● ●
●
●
● ● ●● ● ● ●● ● ● ●● ●● ● ●● ●
● ●●
● ●
● ● ● ● ●●● ● ● ●● ●
●●● ● ●●●
●●● ● ●● ● ●
●●●●● ●●
● ●●●
● ● ●●● ● ● ● ● ● ●●●● ● ● ●●
● ●● ● ● ● ● ● ●●●● ●● ● ●●
● ●●● ● ● ●● ●
●
●● ●
● ●●●
●●●●● ●●● ●●●● ●● ●
●● ● ●●●
● ●● ● ●
●●● ● ●●
● ●● ●●● ●
●●●
● ● ● ● ●●● ●●●
● ●●● ●● ● ●●●● ●●
● ● ●● ●
●
●● ● ●●● ● ● ●● ●
●●
●
●●●●● ● ● ●●● ● ● ●●
●●
●● ● ● ●●●
1
● ●● ●● ●●● ● ● ●● ●
●
●● ● ● ● ● ●●●● ● ●●●●● ● ●● ●●● ●
●●
● ●
●●
●●●●● ● ● ● ● ● ●●●
● ●
● ●
●●
●
● ●● ●● ● ● ● ●●● ●● ●●●●●● ●● ●●
●
●● ●●
●● ●●●● ●● ●
● ●●
● ●●●●
●●●●●●
●●● ● ● ●
● ●●●● ● ●● ●●● ●●
●●●●●●●
●●●●
● ● ●●●●● ●● ●●●●
●●
●●●● ●●● ●● ● ●●
●●●●●●●
● ●
●● ● ●
●●●● ● ● ●●●●● ●● ●● ●●● ● ●● ● ● ●●● ●
●
●● ●●●● ●● ●
●●●
●●● ● ●● ●● ●● ●● ● ● ● ●● ●●● ●● ● ●● ● ● ● ●
●
●●
●● ●●
● ● ●●●●●
● ●● ● ●●●● ●●
● ●
●●● ●
● ●
●●
●● ●●●●● ●
●
● ●●●● ●● ●● ●
●●●●● ●● ●●● ●
● ●● ●
● ●● ●
●
●●●● ●
●●
●
● ●●●● ●
●●
●●
●●
●
●
●
●
●
●●●● ●●
● ●●●
●●
●●
●
● ●
●●●●●
●
● ●
● ●
●
●
●
●
●
●
●●
●●●
●●●●
●●
●●●●
●●●
●
●●●
● ● ●●●● ●●●● ●
●
●●
●
●● ●●●
●
●
●
●●●
●●●●
●
●
● ●
●●●●
●
●●
●
●
●●
●●●
●●●●●
●
●●
●
●●●
●
●
●
●
●
●●
● ●
● ●●●
●
●
●
●
●
●●●
●
●
●
●
●
●
●● ●●
● ●
●
●
● ●
●
●
●
●
● ●●
●●●●●
●
● ●
●●
●
●●
●
● ●●
●●
●
●●
●
●
●●
●
●
●●
●
●●
●●●●●
●● ●
●●●
●
●
●●●●
●
●●
●
● ●●
●
●
●●
●●
●
●
●●●
●
●
●●
● ●●●
●
●
●●
●
●
●
●
●●●
●
●●●
●
●●
●
● ●● ●
●
●
●●
●●
●
●●●●●●
●
●● ●●●● ●● ●
● ●●
●
●● ●●●
●●●
● ●●● ●
●●●
●
●●●●●●● ●● ●
●
●● ● ●●●●●● ● ●
●●●
●●●● ●
●●
● ●●●
● ●● ●● ●
● ●
●●●●
●●
● ●● ● ● ●●
●
● ● ● ●●●●●● ● ●●●
●●● ●
● ● ●●
●
● ●● ● ● ●●● ● ●● ●●
●●● ●● ● ●●● ●●●● ●
●
●
●
●
●
●
●●
●●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●●●
●
● ●●
●
●
● ●
●●●
●
●
●●
●●●
●
●
●●
●
●
●●
●
●
●●●●
●
●●
●
●
●
●●
●●●
●●●●
●●
●
●●
●
●
●
●●●
●
●
●
●
●●●● ●
●
●
●
●
●
●
●
●●
●
●●●●
●●●
●
●
●
●● ●
●
●●●
●●●
● ●
●●●
●●●●
●
●●●●
●
●
●
●
●●●
●
●●
●
●
●
●●●●
● ● ●●●
● ●●● ●●● ●
●
●●
●
●●
●●
●
●
●
●
●
●●
●● ●
●●●
●●
●
●
●●
●
●
●
●●
●
●
●
●●●
●
●●●
●●
● ●●
●● ●●
● ●
●
●● ●
●
●
●●
●●● ●
●
●
●●●
●●●
●
● ●●
●●●●
●●●
●
●●●
●●●
●●
●●●●
● ● ●
● ●●●
● ●
●
●●
●
●●
●●
● ● ●
●● ●●
● ●●●●
●●●
●●
●●●
● ●●
●
● ● ●
● ●●
●●●
● ●
●●
●●
●
●● ● ●●
●●●●
●
● ●
●●
●
● ●●●●
●
● ●●●● ●
●● ●
●●●
● ●
●●●
● ●●
●●●● ● ●
●
●●●●
● ●●
●●●●
●
● ● ●
●●
●●● ●
●●●●
●
●
●●●●●●●
●●●
●
●●
●●
●●●●
●●●●
●
●
●● ●●
●●
●●
●●
● ●
●
● ●●●
●●●●●●
●●●●●
● ● ●
●●●
●●●
●
●● ● ● ●
●●●● ● ● ● ●●● ● ●
● ●● ● ● ●● ● ●
●● ● ●● ● ● ●● ●
●●● ●●● ● ● ●●
●
●
●
●
●●●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
● ●
●●
●
●
●
●●
●
●
●●
●
●
●●●
● ●●
●
●●
● ●
●●
●●
●
●
●●
●●
● ●
●●
●
●
●●●
●
●
●●
●●
●
●
●
●●
●
●
●●
●●
●
●●●
●●
●
●
●●
●
●
●
●
●
●●
●
●
●●●
●
●
●●
●
●
●●
●
●
●
●
●
●
●●
●●
●●●
●
●
●
●●
●
●
●●
●
●●
●●●
●
●
●●●
●
●●
●
●
●
●
●
●
●
●
●●●●
●●
●
●
●●
●
●●
●
●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
●●
●●
●
●
●●●
●● ●
●●
●● ●
●
●
●
●
●
●
●
●
●
●●
●●
●●
●
●●●
●●
●
●
●
●
●
●●●
●
●●
●●
●
●●●
●
●●
●●
●
●●
●
●●●
●
●●●●
●●
●
●●
●●
●
●●
●●
● ●
●
●●
●●
●●
● ●●
●
●●
●
●●
● ●●● ●
●●
●●
●●
●
●●●
●
●●●
●●●
●
●●
●● ●●●●●
●
●
●●●
●
● ●
●●●
●
●●
●
●●●●●
●
●
●●
●●
●●
●●
●
●●
●
●
●●●
●
●
●
●●
●●
●
●●
●
● ●
●
●●
●●
●
●
●
●●●
●
●●
●●●●
●●
●●
●
●●
●●●
●
●●●
●
●●
● ●
●●●
●● ●
●
●●
●●
●●
●
●
●●●
●●
●
●
●
●
●●
●
●
●●
●
●●
●●
●
●
●●
●
●
● ●
●
●●
●●●
●●●●●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●●●
●
●●
●●
●
●●
●
●
●●●●●
●
●
●●
●
●●
●●●
●●
●
●
●●●
●
●
●●
●
●
●●
●●
●
●
●●
●
●
●
●●
●● ●
●
●
●●
●
●
● ●
●
●●
● ●●
●
●
●●
●●
●
●
●
●
●
●
●●●
●●
●●
●●
●●●
●●●●
●
●
●
●●
●
●
●
●●
● ●
●●●
●
●●●
●
●●
●
●
●
●
●● ●●
●
●●
●●●
●●●●●
●
●
●
●●
●
●
●●
●
●
●
●●
●●
●
●●●
●●
●
●●●
●●
●
●
●
●●
● ●
●
●●
●●
●
●
●●
●●
●●
●●
●
●
●
●●
● ●
●●●
●
●●
●●
●●
●●
●●
●
●●●
●●●● ●
●●●
●
●● ●●
●●
●●●
●●●●●●
●
●
●● ●●
●●●●
●
●●
●
●
●●●● ●● ●●● ●●
●●●●●●●●
●●●
● ●●
●● ●
●● ●
●
●●
●●
●●●
●●
●●●
●●
●
● ●
●●
●● ●
●●●●●●
●●
●
●●●●
●●●● ●● ●
●●●●
●●
●●
● ●
0
1 2 3 X
Chromosome
Figure 5.4: − log10 (Corrected P -value) from the genome scan after the QC
procedure.
> lambda([Link])
$estimate
[1] 1.036958
$se
[1] 0.0007178
there is still some inflation, which is explained by the fact that we investigate
only a few short chromosomes with high LD and few causative variants.
Produce the association analysis plot by
(Figure 5.4).
Produce the scan summary by
Comparison with the top 10 from the scan before QC shows that results
changed substantially with only few markers overlapping.
You can see similar results when assessing empirical GW significance:
> [Link] <- qtscore(dm2,
+ data2, times=200, quiet=TRUE, trait="binomial")
|
| | 0%
|
|======================================================================| 100%
Again, none of the SNPs hits GW 5% significance. Still, you can see that
after QC the top markers achieve somewhat “better” significance.
In the last part, we will do several adjusted and stratified analyses. Only
empirical P -values will be estimated to make the story shorter. To adjust for
sex and age, we can
> [Link] <- qtscore(dm2~sex+age,
+ data2, times=200, quiet=TRUE, trait="binomial")
|
| | 0%
|
|======================================================================| 100%
> [Link]([Link])
You can see that there is little difference between adjusted and unadjusted
analysis, but this is not always the case; adjustment may make your study much
more powerful when covariates explain a large proportion of environmental trait
variation.
5.4. GWA ASSOCIATION ANALYSIS 125
|
| | 0%
|
|======================================================================| 100%
Ex. 2 — How many markers are present in the original data set?
Ex. 9 — How many sporadic X errors do you still observe even when the
female male and non-X X-markers are removed? (do not forget to Xfix(s)
these
Ex. 10 — How many ”twin” DNAs did you discover?
Ex. 13 — How many cases and controls are presented in the data after QC?
Ex. 14 — How many markers are presented in the data after QC?
Ex. 18 — Do these SNPs overlap much with the ones ranked at the top before
the QC? If not, what could be the reason?
Ex. 19 — Select 10 SNPs which you would like to follow-up. Say, you’ve se-
lected rs1646456, rs7950586, rs4785242, rs4435802, rs2847446, rs946364, rs299251,
rs2456488, rs1292700, and rs8183220. Make a vector of these SNPs with
> #vec12<-c("rs1646456", "rs7950586", "rs4785242", "rs4435802", "rs2847446",
> # "rs946364", "rs299251", "rs2456488", "rs1292700", "rs8183220")
Load the stage 2 (replicaton) data set by
> #data(ge03d2c)
and select the subset of SNPs you need by
> #confdat <- ge03d2c[, vec12]
Analyse the confdat for association with dm2.
Ex. 20 — Given the two-stage design, and applying the puristic criteria spec-
ified in the lecture, for how many SNPs you can claim a significant finding?
Ex. 21 — Using the same criteria, for how many SNPs you can claim a repli-
cated finding?
Answer (Ex. 1) — :
> table(phdata(ge03d2)$dm2)
0 1
487 463
Answer (Ex. 2) — :
> nsnps(ge03d2)
[1] 7589
Answer (Ex. 4) — :
> res0 <- qtscore(dm2, data=ge03d2, times=200,
+ quiet=TRUE, trait="binomial")
|
| | 0%
|
|======================================================================| 100%
> ### something funny is going on here
> ### disabeling next line
> #lambda(res0)
> ds <- [Link](res0)
Summary for top 10 results, sorted by P1df
> ds
Chromosome Position Strand A1 A2 N effB se_effB chi2.1df P1df Pc1df
rs1646456 1 653 + C G 938 NaN NaN NaN NA NA
rs7950586 1 849 - T A 938 NaN NaN NaN NA NA
rs4785242 1 1766 - T C 936 NaN NaN NaN NA NA
rs4435802 1 5291 + C A 943 NaN NaN NaN NA NA
rs2847446 1 5555 + T A 937 NaN NaN NaN NA NA
rs9308393 1 6739 + T C 937 NaN NaN NaN NA NA
rs946364 1 8533 - T C 938 NaN NaN NaN NA NA
rs299251 1 10737 + A G 942 NaN NaN NaN NA NA
rs2456488 1 11779 + G C 934 NaN NaN NaN NA NA
rs1292700 1 12710 - A C 941 NaN NaN NaN NA NA
effAB effBB chi2.2df P2df
rs1646456 NaN NaN 0 NA
rs7950586 NaN NaN 0 NA
5.6. ANSWERS TO EXERCISES 129
RUN 1
7580 markers and 934 people in total
73 (0.9630607%) markers excluded as having low (<0.267666%) minor allele frequency
75 (0.9894459%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (P <0)
4 (0.4282655%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2558271 (s.e. 0.02102863)
4 (0.4282655%) people excluded because too high autosomal heterozygosity (FDR <1%)
130 CHAPTER 5. GENOME-WIDE ASSOCIATION ANALYSIS
RUN 2
7432 markers and 918 people in total
42 (0.5651238%) markers excluded as having low (<0.2723312%) minor allele frequency
0 (0%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (P <0)
0 (0%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2562716 (s.e. 0.0151377)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7872975 (s.e. 0.01587625), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 7390 (99.43488%) markers passed all criteria
In total, 918 (100%) people passed all criteria
RUN 3
7390 markers and 918 people in total
0 (0%) markers excluded as having low (<0.2723312%) minor allele frequency
0 (0%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (P <0)
0 (0%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2562716 (s.e. 0.0151377)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7844231 (s.e. 0.01656417), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 7390 (100%) markers passed all criteria
In total, 918 (100%) people passed all criteria
> summary(qc1)
$`Per-SNP fails statistics`
NoCall NoMAF NoHWE Redundant Xsnpfail
NoCall 82 0 0 0 0
NoMAF NA 115 0 0 0
NoHWE NA NA 0 0 0
Redundant NA NA NA 0 0
Xsnpfail NA NA NA NA 2
no X/Y/mtDNA-errors to fix
RUN 1
7390 markers and 918 people in total
0 (0%) markers excluded as having low (<0.2723312%) minor allele frequency
0 (0%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (P <0)
0 (0%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2562716 (s.e. 0.0151377)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7873545 (s.e. 0.01636484), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 7390 (100%) markers passed all criteria
In total, 918 (100%) people passed all criteria
> summary(qc2)
$`Per-SNP fails statistics`
NoCall NoMAF NoHWE Redundant Xsnpfail
NoCall 0 0 0 0 0
NoMAF NA 0 0 0 0
NoHWE NA NA 0 0 0
Redundant NA NA NA 0 0
Xsnpfail NA NA NA NA 0
isfemale NA NA NA 0 0 0 0
ismale NA NA NA NA 0 0 0
isXXY NA NA NA NA NA 0 0
otherSexErr NA NA NA NA NA NA 0
Answer (Ex. 6) — The list of genetic females who are coded as males is
> qc1$isfemale
[1] "id3374" "id6263" "id6835" "id8410" "id8509" "id8519" "id8542" "id2701"
[9] "id6494" "id3100"
Answer (Ex. 7) — The list of genetic males who are coded as females is
> qc1$ismale
[1] "id193" "id8475" "id2461" "id5669" "id7245" "id8301"
Answer (Ex. 9) — Eight ’sporadic’ X-errors are left after removing people
with likely sex code errors (seven in the data set after first step of QC)
Answer (Ex. 10) — The list of IDs failing IBS checks (’twin’ DNAs) is
> qc1$ibsfail
[1] "id3368" "id9668" "id5437" "id956" "id386" "id660" "id2115" "id8370"
no X/Y/mtDNA-errors to fix
RUN 1
7390 markers and 893 people in total
5 (0.067659%) markers excluded as having low (<0.2799552%) minor allele frequency
0 (0%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (FDR <0.2)
0 (0%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2565083 (s.e. 0.01505982)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7882472 (s.e. 0.01153768), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 7385 (99.93234%) markers passed all criteria
In total, 893 (100%) people passed all criteria
RUN 2
7385 markers and 893 people in total
0 (0%) markers excluded as having low (<0.2799552%) minor allele frequency
0 (0%) markers excluded because of low (<95%) call rate
0 (0%) markers excluded because they are out of HWE (FDR <0.2)
0 (0%) people excluded because of low (<95%) call rate
Mean autosomal HET is 0.2565083 (s.e. 0.01505982)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7904758 (s.e. 0.01152922), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 7385 (100%) markers passed all criteria
In total, 893 (100%) people passed all criteria
> summary(qc2)
$`Per-SNP fails statistics`
NoCall NoMAF NoHWE Redundant Xsnpfail
NoCall 0 0 0 0 0
NoMAF NA 5 0 0 0
NoHWE NA NA 0 0 0
Redundant NA NA NA 0 0
Xsnpfail NA NA NA NA 0
134 CHAPTER 5. GENOME-WIDE ASSOCIATION ANALYSIS
Answer (Ex. 18) — There is little overlap between SNPs before and after
QC:
> #snps0
> #snps1
Answer (Ex. 21) — SNP “rs7903146” had empirical P -value ≤ 0.05 at both
stages, and very strong joint significance. It can be claimed as replicated.
You can check if any of the SNPs you have identified as significant or repli-
cated are the ones which were simulated to be associated with dm2 by using
the command [Link](c("snpname1", "snpname2", "snpname3")) where
snpnameX stands for the name of your identified SNP. The ”true” SNPs can be
found on NCBI and some are located in known T2D genes (just because we
used these names to name the ”significant” ones).
Chapter 6
137
138CHAPTER 6. GWA ANALYSIS IN PRESENCE OF STRATIFICATION: THEORY
involved, most of these associations will be genetically false positives – noise as-
sociations generated by strong genetic and phenotypic divergence between the
two populations.
The scenario described above is extreme and indeed it is hard to imagine a
genetic asociation study in which two very distinct populations are so blintly
mixed and analysed not taking this mixture into account. However, a more
subtle scenario where several slighly genetically different populations are mixed
in the same study is frequently the case and a matter of concern in GWA studies.
In this chapter, we will define what is genetic structure, and how it can be
quantified (section 6.1); what are the effects of genetic structure on the standard
association tests (section 6.2) and specific association tests which take possible
genetic structure into account (section 6.3).
The text of this chapter is in large part based on a chapter of a book
published by Elsvier. We thank Elsvier for the permission to repro-
duce this material. COPYRIGHT NOTICE: Reprinted from ”Analy-
sis of Complex Disease Association Studies: A Practical Guide”, Yurii
Aulchenko, chapter ”Effects of Population Structure in Genome-wide
Association Studies”, 123-156, Copyright 2011, with permission from
Elsevier
alleles are called ”identical-by-descent”, or IBD for short. If the chance of IBD
is high, this reflects high degree of genetic relationship. As a rule, relatives share
many features, both environmental and genetic, which may lead to confounding.
Genetic relationship between a pair of individuals is quantified using the
”coefficient of kinship”, which measures that chance that gametes, sampled at
random from these individuals, are IBD.
Thus for the purposes of gene-discovery we can define genetic population use
retrospective terms and based on the concept of IBD:
Two individuals, I1 and I2 , belong to the same genetic population if (a)
their genetic relationship, measured with the coefficient of kinship, is greater
then zero and (b) their kinship is much higher than kinship between them and
some individual I3 , which is said to belong to other genetic population.
One can see that this definition is quantitative and rather flexible (if not
to say arbitrary): what we call a ”population” depends on the choice of the
threshold for the ”much-higher” probability. Actually, what you define as ”the
same” genetic population depends in large part on the scope aims of your study.
In human genetics literature you may find references to a particular genetically
isolated population, population of some country (e.g. ”German population”,
”population of United Kingdom”), European, Caucasoid or even general hu-
man population. Defining a population is about deciding on some probability
threshold.
In genetic association studies, it is frequently assumed that study partic-
ipants are ”unrelated” and ”come from the same genetic population”. Here,
”unrelated” means, that while study participants come from the same popula-
tion (so, there is non-zero kinship between them!), this kinship is so low that it
has very little effect on the statistical testing procedures used to study associa-
tion between genes and phenotypes.
In the following sections we will consider the effects of population structure
on the istribution of genotypes in a study population. We will start with as-
sumption of zero kinship between study participants, which would allow us to
formulate Hary-Weinberg principle (section 6.1.1). In effect, there is no such
thing as zero kinship between any two organisms, however, when kinship is very
low, the effects of kinship on genotypic distribution are minimal, as we will see
in section 6.1.2. The effects of substructure – that is when study sample consist
of several genetic populations – onto genotypic distribution will be considered
in section 6.1.3. Finally, we will generalize the obtained results for the case
of arbitrary structures and will see what are the effects of kinship onto joint
distribution of genotypes and phenotypes in section ??.
P (N N ) = (1 − q) · (1 − q) = p2 ,
P (N D) = q · (1 − q) + (1 − q) · q = 2 · p · q, (6.1)
P (DD) =q·q = q2
Individuals
P(DD) P(DN) P(NN)
D D D N N N
P(D) P(N)=1-P(D)
Alleles
Figure 6.1: Genotypic and allelic frequency distribution in a population; q =
P (D) = P (DD) + 12 · P (DN ).
to realize that, especially if the study participants are believed to come from
the same genetic population, most of the times when deviation from HWE is
detected, this deviation is due to technical reasons, i.e. genotyping error. There-
fore testing for HWE is a part of the genotypic quality control procedure in most
studies. Only when the possibility of technical errors is eliminated, other possi-
ble explanations may be considered. In a case when deviation from HWE can
not be explained by technical reasons, the most frequent explanation would be
that the sample tested is composed of representatives of different genetic pop-
ulations, or more subtle genetic structure. However, unless study participants
represent a mixture of very distinct genetic populations – the chances of which
coming unnoticed are low – the efffects of genetic structure on HWE are difficult
to detect, at least for any single marker, as you will see in the next sections.
6.1.2 Inbreeding
Inbreeding is preferential breeding between (close) relatives. An extreme ex-
ample of inbreeding is a selfing, a breeding system, observed in some plants.
The inbreeding is not uncommon in animal and human populations. Here, the
main reason for inbreeding are usually geographical (e.g. mice live in very small
interbred colonies – dems – which are usually established by few mice and are
quite separated from other dems) or cultural (e.g. noble families of Europe).
Clearly, such preferential breeding between relatives violates the assumption
of random aggregation, underling Hardy-Weinberg principle. Relatives are likely
to share the same alleles, inherited from common ancestors. Therefore their
progeny has an increased chance of being autozygous – that is to inherit a copy
of exactly the same ancestral allele from both parents. An autozygous genotype
is always homozygous, therefore inbreeding should increase the frequency of
homozygous, and decrease the frequency of heterozygous, genotypes.
Inbreeding is quantified by the coefficient of inbreeding, which is defined as
the probability of autozygosity. This coefficient may characterize an individual,
142CHAPTER 6. GWA ANALYSIS IN PRESENCE OF STRATIFICATION: THEORY
A A B B A B
P=1/2 P=1/2
C D E F C D E F
P=1/2 P=1/2 P=1
P=1
G H G H
P=1/2 P=1/2
J J
6
P=1/2 =1/64
Figure 6.2: Inbred family structure (A) and probability of individual ”G” being
autozygous for the ”Red” ancestral allele
leading to genotype BB. The chance that the founder allele is A is p, and the
chance that the founder allele is B is q. If the person is not autozygous, then the
expected genotypic frequencies follow HWE. Thus, the probability of genotype
AA is (1 − F ) · p2 + F · p, where the first term corresponds to probability that
the person is AA given it is not inbred (p2 ), multiplied by the probability that
it is not inbred (1 − F ), and the second term corresponds to probability that a
person is AA given it is inbred (p), multiplied by the probability that the person
is inbred (F ). This computations can be easily done for all genotypic classes
leading to the expression for HWE under inbreeding.
P (AA) = (1 − F ) · p2 + F · p = p2 + p · q · F
P (AB) = (1 − F ) · 2 · p · q + F · 0 = 2 · p · q · (1 − F ) (6.2)
P (BB) = (1 − f ) · q 2 + F · q = q2 + p · q · F
0.5
0.4
0.3
P(g)
0.2
0.1
0.0
AA AB BB
Genotype, g
Figure 6.3: Genotypic probability distribution for a locus with 50% frequency
of the B allele; black bar, no inbreeding; red, F = 0.001; green, F = 0.01; blue,
F = 0.05
6.1. GENETIC STRUCTURE OF POPULATIONS 145
Thus, even in populations with strong inbreeding, rather large sample sizes
are required to detect the effects of inbreeding on HWE at a particular locus,
even at relatively weak significance level of 5%.
While the chance that deviation from HWE due to inbreeding will be sta-
tistically significant is relatively small, inbreeding may have clear effects on the
results of HWE testing in GWA study. Basically, if testing is performed at
a threshold corresponding to nominal significance α, a proportion of markers
which show significant deviation will be larger than α. Clearly, how large this
proportion will be depends on the inbreeding and on size of the study – expec-
tation of T 2 is a function of both N an F . A proportion of markers showing
significant deviation form HWE at different values of inbreeding, sample size,
and nominal significance threshold, is shown in table 6.1. While deviation of
this proportion from nominal one is minimal at large α’s and small sample sizes
and coefficients of inbreeding, it may be 10-fold and even 100-fold higher than
the nominal level at reasonable values of N and F for smaller thresholds.
BB, respectively. As you can see the observed distribution has much higher
frequencies of homozygous genotypes – excess of homozygotes.
It is notable, that the differences between the observed homozygotes fre-
quencies and these expected under HWE are both 0.125, and, consequently, the
observed heterozygosity is less than that expected by 0.125 · 2 = 0.25.
The phenomenon of deviation from HWE due to the fact that considered
population consist of two sub-populations, is known as ”Wahlund’s effect”, after
the scientist who has first considered and quantified genotypic distribution under
such modelWahlund (1928).
Such marked differences between observed and expected under HWE are
very easily detected; for the above example, a sample of ≈ 35 people is enough
to reject the hypothesis of HWE (power > 80% at α = 0.05).
However, the differences we can see in real life are not so marked. For
example, the common Pro allele at position 12 of the peroxisome proliferator-
activated receptor gamma is associated with increased risk for type 2 diabetes.
The frequency of the Pro allele is about 85% in European populations and
Caucasian-Americans, about 97% in Japan and 99% in African-American (see
table 1 from Ruiz-Narvez (2005)). Table 6.3 shows hypothetical observed and
expected genotypic proportions in a sample composed of 50% Caucasians and
50% African-American.
You can see that observed distribution and the one expected under HWE are
very similar; only a sample as large as 1,800 people would allow detection of the
deviation from HWE (power > 80% at α = 0.05). The situation is similar for
most genes observed in real life – while the frequencies may be (or may be not)
6.1. GENETIC STRUCTURE OF POPULATIONS 147
Expected
p2 2pq q2
Difference
pqFst −2pqFst pqFst
very different for populations, which diverged long time ago, for relatively close
populations expected frequency differences are small and large sample sizes are
required to detect deviation from HWE due to Wahlund’s effect at a particular
fixed locus.
Let us summarize, what genotypic proportions are expected in a sample,
which is a mixture of two populations. Let each population is in HWE, and
the frequency of the B allele is q1 in population one and q2 in population two.
Let the proportion of individuals coming from population one is m in the mixed
population, and consequently the proportion of individuals from population two
is (1 − m). The allelic frequencies, and genotypic distributions in the original
and mixed populations are presented in tale 6.4.
The frequency of the B allele in the mixed population is just the weighted
average of the allelic frequencies in the two populations, q = m · q1 + (1 − m) · q2 .
Let us denote the frequency of the A allele as p = 1 − q. It can be demonstrated
that the genotypic frequency distribution in the mixed sample is the function of
the frequency of allele B in the sample, q, and ”disequilibrium” parameter D:
P (AA) = p2 + p · q · Fst
P (AB) = 2 · p · q · (1 − Fst ) (6.5)
P (BB) = q 2 + p · q · Fst
where
m · (1 − m) · (q1 − q2 )2
Fst = (6.6)
p·q
You can see that equation 6.5, expressing the genotypic frequencies distri-
bution under Wahlund’s effect, is remarkably similar (actually, is specifically
re-written in a form similar) to the equation 6.2, expressing the genotypic pro-
portions under the effects of inbreeding. Again, the reason is that Fst (as well
as F of equation 6.2) is easily estimated from the data as the ratio between
the observed and expected variances of the genotypic distributions. Then the
2
expected non-centrality parameter for the test of HWE is simply N · Fst , where
N is the sample size. Therefore our results concerning the proportion of tests
expected to pass a particular significance threshold when genome-wide data are
analyzed (table 6.1) hold, with replacement of F with Fst .
We can compute that the values of Fst , corresponding to the population
mixtures presented in tables 6.2 and 6.3 are 0.49 and 0.067, respectively, which
148CHAPTER 6. GWA ANALYSIS IN PRESENCE OF STRATIFICATION: THEORY
gives us a shortcut to estimate the sample size required to detect deviation from
HWE due to Wahlund’s effect (at α = 0.05 and power 80%): N > 7.85/0.492 ≈
32 and N > 7.85/0.0672 ≈ 1771.
A typical value of Fst for European populations is about 0.002 (up to
0.023Nelis et al. (2009)); very large sample sizes are required to detect de-
viation from HWE at any given locus at such small Fst ’s. However, the effects
onto the proportion of markers failing to pass HWE test in GWA may be visibly
inflated (table 6.1).
X (Oi − Ei )2
T2 = (6.7)
i
Ei
2 2
+ ((2s0 +s2Sp
1 )−2Sp)
+ ((s1 +2s2S(1−p)
2 )−2S(1−p))
Under the null hypothesis that the frequency of alleles is the same in cases
and controls (and, as you will see later, that HWE halds in total sample) the
test statistic is distributed as χ2 with one degree of freedom.
An alternative, Armitage’s trend test for proportions, can be used to test
the null hypothesis. This test is performed using the 2x3 genotypic table (6.5).
The null hypothesis assumes that the frequency of cases is the same in all
genotypic groups; alternative is that the frequency is not the same, but are,
however, not totally arbitrary. As it follows from the name of the test, a trend
in proportions is assumed, that is the frequency of cases among people with
heterozygous genotypes AB should be exactly between the frequencies of cases
in two homozygous classes. This hypothesis may be formalized using parameters
beta0 , the expected frequency of cases in the AA group, and β1 , the increase
in frequency of cases in the AB group. The expected frequency of cases in the
AB group is then (β0 + β1 ); the frequency of cases in the BB group is assumed
to be (β0 + 2 · β1 ). Parameters p0 and p1 can be estimated using the maximum
(r1 +2r2 )−pR
likelihood; β̂1 = (n 1 +4n2 )−pN
, where p = 2n2N
2 +n1
is the frequency of the B allele
R
in the total sample. Then, β0 is estimated as β̂0 = N − β̂1 p. Is can be shown
that the chi-square test 6.7 based on these expectations takes the form
test Ta2 is the test for association in presence of HWE; when HWE does not
hold, even in absence of association, the values of Ta2 are greater then the values
of Tt2 test, possibly leading to false positive conclusions about association in
presence of deviations from HWE. Therefore the trend test Tt2 is to be prefered
when testing for genetic association Sasieni (1997).
For study of association between genotype and a quantitative traits, linear
regression analysis is performed. Let us denote the vector of phenotypes as
y, with particular values yi (i = 1, . . . , N ). Let code the genotypes with a
quantitative variable, which reflects the number of B allels. Thus, we will code
AA as 0, AB as 1, and BB as 2. Let us denote the vector of genotypes as g,
with particular values gi (i = 1, . . . , N ) taking the value of 0, 1 or 2. The linear
regression model assumes that the expectation of the trait is
E[yi ] = µ + βg · gi
xi gi /N − xi gi /N 2
P P P P P P
Cov(y, g) N xi g i − xi g i
β̂ = = P 2 = (6.10)
gi /N − ( gi )2 /N 2 N gi2 − ( gi )2
P P P
V ar(g)
V ar(y)
Under the null hypothesis, the variance of β̂ is V ar0 (β̂g ) = N ·V ar(g) , and
the score test statistic
is distributed as χ2 with one degree of freedom. Here, V ar0 β̂g denotes the
variance under the null hypothesis. Denote the correlation between y and g,
√ Cov(y,g) , as r. Then Tq2 = N · r2 .
V ar(y)·V ar(g)
It is worth to note that Armitage’s trend test can be expressed as a linear
regression test. In the table 6.5 Let us code the genotypic groups based on the
number of B allels. Thus, we will code AA as 0, AB as 1, and BB as 2. Let
us also code the cases with ”1” and controls with ”0”. Let y denote the vector
of phenotypes and g the vector of genotypes coded in this way. Then, if we
perform linear regression of the case-control status onto the number of B alleles
in the genotype, the estimate of the regression coefficient is (following 6.10)
P P P
xi gi − xi gi /N (r1 + 2r2 ) − pR
β̂ = =
gi2 − ( gi )2 /N
P P
(n1 + 4n2 ) − pN
Thus, the expected proportions in the Armitage’s trend test are provided
by solution of linear regression equation, in which regression of case-control
status, coded as ”0” and ”1” is performed onto the number of B alleles. It can
be further demonstrated that the trend test statistics 6.9 can be expressed as
Tt2 = N · r2 , where r2 is squared coefficient of correlation between y and g.
In the next two sections we will consider the effects of genetic structure on
the standard tests for association described above. The extensive treatment of
the problem is mainly due to the seminal works of Devlin, Roeder, Bacanu, and
6.2. EFFECTS OF POPULATION STRUCTURE ON STANDARD TESTS FOR ASSOCIATION151
which, for a common allele with frequency of 0.2 translates to the probability
0.64.
Let us quantify these two sources of bias. Following Devlin et al. (2001)
let us assume that the number of cases and the number of controls is the same,
N . Let us denote the vector of genotypes, coded as 0, 1, and 2 of cases as X,
with Xi (i = 1, . . . , N ) being the genotype of the i-th case, and the vector of
genotypes of controls as Y (with Yj , j = 1, . . . , N being the genotype of j-th
control). The trend and the allelic tests statistic are proportional to the square
1 brothers and sisters
152CHAPTER 6. GWA ANALYSIS IN PRESENCE OF STRATIFICATION: THEORY
P P
of T = Xi − Yj . The variance of this statistic, in general form, is
PN PN
V ar(T ) = P V ar(Xi ) + i=1 V ar(Y
i=1 P i)
+2 i<j Cov(Xi , Xj ) + 2 i<j Cov(Yi , Yj ) (6.12)
P P
−2 i j Cov(Xi , Yj )
Let us consider a sitatuation in which cases come from one popualtion, and
controls from the other population; each of the populations is in HWE and
the difference between the populations is characterized with Fst (see equation
6.6). Under this model, V ar(Xi ) = V ar(Yi ) = 2pq(1 + Fst ), and the covariance
between any pair of genotypes from the same population is 4pqFst . Then
V ar(T ) = 2pq(1 + Fst ) · N + 2pq(1 + Fst ) · N
+2 · 2pqFst · N (N − 1)/2 + 2 · 2pqFst · N (N − 1)/2 + 0
= 4pqN · (1 + Fst + 2Fst (N − 1)) ≈ 4pqN (1 + 2N Fst )
(6.13)
here, 4pqN corresponds to the binomial variance of T in absence of genetic
structure, while Fst + 2 · Fst · (N − 1) reflects the inflation of the variance.
As the second term is the function of the sample size, large inflation may be
achieved even with small vaules of Fst . Note that here the sample size is 2N ,
as we assumed N cases and N controls.
Above we have considered an example in which we know the Fst between
the population of cases and the population of controls. In a practical study, a
number of cases and controls is usually sampled from each genetically different
population. Let the proportion of individuals sampled from population c among
cases is ac and the proportion of individuals coming from that population among
controls is uc . Then, it can be shown that
X
V ar(T ) ≈ 4pqN (1 + 2 · N · Fst · (ac − uc )2 ) (6.14)
c
As it follows from this equation, the variance of the estimated frequency dif-
ference depends on the composition of the sample. Maximal inflation is achieved
when the cases and controls are sampled from different populations, while if
2
P
c (ac − uc ) = 0 – which is achieved by sampling equal number of cases and
controls from each sub-population – the variance inflation is minimal.
These results canbe generalized to arbitrary relations between cases and con-
X
trols. Let us denote kinship between cases i and j as fij , kinship between con-
Y XY
trols as fij , and the kinship between a case and a control as fij . ThenDevlin
et al. (2001)
V ar(T ) = 4pqN · (1 +Fst + N2 i<j fij X
P
2
P Y 2
P P XY (6.15)
+ N i<j fij − N i j fij )
This equation demonstrates that the variance is inflated not only in a case
when cases and controls come from genetically distinct populations, but that
X
also ”criptic relations” among either cases (some fij > 0) or controls (some
Y
fij > 0) may lead to increased variance of the test. Because summation (e.g.
X
P
i<j fij ) is performed overl all pairs of cases/controls, cryptic relations may
have a strong impact onto inflation of the variance.
Generally, the variance of the T can be expressed as V ar(T ) = 4N pq(1+Fst +
D(f X , f Y , f XY )). Here, 4N pq corresponds to the binomial variance assuming
6.2. EFFECTS OF POPULATION STRUCTURE ON STANDARD TESTS FOR ASSOCIATION153
HWE and independence between cases and controls, the second term – Fst –
accounts for increase in variance due to deviation from HWE, and the last,
which is a function of kinship – D(f X , f Y , f XY ) – accounts for dependencies
T2
bewteen cases and controls. The test 4N pq(1+Fst +D(f X ,f Y ,f XY )) is distributed
M edian(Ti2 )
λ̂ = (6.16)
0.4549
For the tested markers, the corrected value of the test statistic is obtained by
2 2
simple division of the original test statistic value on λ̂, Tcorrected = Toriginal /λ.
Note that this procedure is correct only if the same number of study participants
was typed for any marker, as you will see later.
As you can see, the genomic control procedure is computationally extremely
simple – one needs to compute the test statistic using a simple test (e.g. score
test), compute the median to estimate λ, and divide the original test statistics
values onto λ̂.
How to choose ”null loci” is a GWA study? In a genome, we expect that
a small proportion of markers is truly associated with the trait. Therefore in
practice, all loci are used to estimate λ. Of cause, if very strong (or multiple
weak) true associations are present, true association will increase the average
value of the test, and genomic control correction will be conservative. To relax
this, it has been suggestedSladek et al. (2007) to use, say, 95% of the least
significant associations for estimation of the inflation factor; however, the ques-
6.2. EFFECTS OF POPULATION STRUCTURE ON STANDARD TESTS FOR ASSOCIATION155
tion of selection of cut-off is not obvious, and all markers are used in practice
in most studies.
We have observed that the inflation factor λ is a function of sample size, N
– the bigger is the sample size, the larger is inflation. If this is the case, how
can we compare inflations between different GWA studies? A good idea is to
use a standardized inflation, say, inflation per 1,000 subjects. For a quantitative
trait analysis, inflation factor can be expressed as λ ≈ (1 + N ∗ D(sample)),
where N ∗ D(sample) is a term, which grows linear with sample size, at some
rate determined by sample characteristics.
Therefore a standarsized inflation factor can be etimated as
λ̂ − 1
λ̂1000 = 1 + · 1000,
N
where N is the sample size and λ̂ is the estimate from the total sample.
What about a case-control sample? For such samples, a standardized λ is
computed for a fixed number of cases and controls, say 1000; we will denote such
standardized inflation as λ1000,1000 to distinguish it from the one computed for
a quantitative traits. If we denote the number of cases as Na and the number
of controls as Nu , then
Clearly, we have assumed that in our GWA study the sample size was equal
for all studied markers; this fact allows for very simple estimation of λ̂ (equation
6.16) and correction of the test statistic. It may happen, however, that the
number of participants typed for different marker loci is different; for example,
this may happen when all study participans were typed for SNP panel one, and
then a part of the study was additionally typed at a different panel. In such
situation, expectation of a Tq2 test for a quantitative trait can be expressed as
N
E[Tq2 ] = 1 + (λ1000 − 1) ·
1000
It is straightforward to obtain an estimate of λ1000 by performing linear re-
gression of the observed test statistic values onto the sample size used; note
that the intercept should be fixed to 1 in this procedure. Other, more effective
procedures may be thought of.
For binary traits, if sample is composed from Na cases and Nu controls, the
expression for the expected value of the test statistic is similar to that obtained
for quantitative traits, however, geometric mean of the number of cases and
controls are usedFreedman et al. (2004):
1 1
+
E[Tt2 ] = 1 + (λ1000,1000 − 1) · 1000
1
1000
1
Na + Nu
60
50
40
Mean T^2
30
20
10
0
Figure 6.4: Mean Tt2 test statistic as frequency of the B allele, q. Models
considered: additive, green; recessive, red; dominant, blue; over-dominant, cyan.
estimation of λ and further correction of the tests. Does the same apply to other
genetic models?
In figure 6.4 the results for additive, dominant, recessive, and over-dominant
model tests are presented. Simulated study consisted of 1000 cases and 1000
controls; the differentiation between the case and control populations was as-
sumed Fst = 0.002. Armitage’s trend test was used in analysis. One can see
that when a common polymorphism is studies (0.05 < q < 0.95), the additive
model test (green line) does not depend on the frequency of the B. The range
of allele frequencies in which the additive model does not depend on these de-
pends of the values of Fst and the sample size: the larger differentiation, and
the smaller the sample size, the narrower is the range.
However, other one degree of freedom tests (recessive, red; dominant, blue;
over-dominant, cyan) do depend on the allele frequency very much across all
the range of allelic frequencies (figure 6.4, see Zheng et al. (2005) for details).
Thus, it is important to remember that the genomic control was developed
for, and works with additive genetic models; even in this framework, behaviour
6.3. ANALYSIS OF STRUCTURED POPULATIONS 157
of λ depends on allelic frequencies when theses are too low or too high – thus
application of genome-wide derived inflation factor to such marker loci may be
incorrect for loci with low minor allele frequency. What is somewaht sustaining
statistically is the fact that such correction will be conservative, and not liberal
– but the same may be worrysome biologically (e.g. missed true positives). For
other types of model, lambda can, at least in theory, be estimated taking into
account the allelic frequency of the locus in question. However, these methods
are not implemented yet in packages for genome-wide association analyses.
Other important thing to remember about genomic control is that it assumes
uniorm Fst across the genome. This may not be the case for some (e.g. selected)
genomic regions. Such regions may still generate very high test statistic, even
after appropritate genomic control correctionCampbell et al. (2005); basically,
the frequency distribution at such loci may vary from population to popula-
tion much more then the average across the genome. A number of methods
taking genetic structure of study population into account directly (structured
association, EIGENSTRAT, reviewed later), can deal with such situations.
Finally, what levels of genomic control inflation parameter are acceptable in
GWA studies? As the question is of how much the total test statistic is affected,
non-standardized inflation may be used to address the question. Despite of lack
of clear guidance, the general practice in the field is to consider the values of
λ̂ < 1.01 as small, λ̂ < 1.05 as moderate and still acceptable. If λ̂ > 1.1,
this suggest strong influence of genetic structure or other design factors on the
test statistic. While GC statistically correct method, such analysis lacks power;
good practice is to consider use of other methods, which take the structure of
the sample into account in diect manner.
Kinship
1 2 3
Population A Population B
Figure 6.5: Three samples from two populations. 1: Family-based sample; 2,3:
random sample of ”independent” people
ticipants share common ancestors few (1-4) generation ago, the kinship between
study participants is high, and the study can be classified as a family-based one
(Study 1 of figure 6.5). When common ancestors between study participants is
expected say ¿5 generations ago, the kinship between study participants is low,
and such study may be classified as a population-based sample of ”indepen-
dent” people (Studies 2 and 3 of figure 6.5). Now consider two groups of study
participants (samples 2 and 3). Any person from group 2 is expected to share
a common ancestor with a person from the same study group with much higher
probability than with a person form group 3; thus these represent two genetic
population (see page 139 for the retrospective definition of genetic population).
It shouldbe kept in mind that if kinship is very low (expected common ances-
tors dozns of generations ago), this would translate in high degree of genetic
differentiation. Moreover, this reflects a long history of isolation, which usually
means geographic sepration, and accumulation of cultural and other environ-
mentsl differences between the populations, which may be crucial in association
studies.
Of cause, a particular study is usually characterized by some mixture of
populations and some relatednes between study participants. We will, however,
first consider the two extreme scenarios – analysis of samples of ”independent”
subjects from different populations, and analysis of a family-based study.
effect and its variance are estimated within each strata separately, and then
these estimates are pooled to generate global statistics. The strata can be known
from design (e.g. place of birth or ethnicity of parents) or estimated from GWA
data. By doing this, we allow for arbitrary trait distribution, characterized
by stratum-specific mean and variance, in each stratum. Clearly, this may be
crucial when different populations characterized by different environments are
included in analysis.
Combining the evidence across strata may be done using a number of meth-
ods, e.g. Cochran-Mantel-Haenszel test for binary outcomes. One of the most
simple ways to combine the evidences coming from multiple strata – or studies
– is to use fixed effects inverse variance meta-analysis.
In essence, this method is equivalent to combining likelihoods coming from
separate studies, using quadratic approximation. Denote coefficients of regres-
sion estimated in N studies/strata as βi , and associated squared standard errors
of the estimates as s2i where i ∈ 1, 2, ..., N . Note that the regression coefficient
should be reported on the same scale, e.g. centimeters, meters, or using obser-
vations reported on the standard normal scale. Define weights for individual
studies as
1
wi = 2
si
Then the pooled estimate of the regression coefficient is
PN
w i βi
β = Pi=1
N
i=1 wi
As you can see, the weights have straightforward interpretation: the bigger
the weight of the study (meaning the small is the standard error in the study),
the larger is the contribution from this study onto the pooled estimate.
The standard error of the pooled estimate is computed as
1
s2 = PN
i=1 wi
When binary traits are studied, and results are expressed as Odds Ratios
with P − values, it is also possible to apply inverse variance method. For this,
you need to transform your Odds Ratios using natural logarithm, and, on this
scale, estimate the standard error. Generic inverse variance pooling may be
applied to the data transformed this way; the final results are back-transformed
onto Odds Ratio scale using exponentiation.
160CHAPTER 6. GWA ANALYSIS IN PRESENCE OF STRATIFICATION: THEORY
E[yi ] = µ + βg · g
are estimated. These are free of correlations, and can be used as the new ”trait”
in further analysis. This procedue allows for very fast GWA analysis in step 2
(for large sample sizes, much faster then above-described two-step approach),
also it has a great flexibility as the environmental residuals can be analysed
using a large variaty of methods. At the same time, the GRAMMAR test for
association is conservative, and the estimates of the effects obtained in step 2
are downward biasedAulchenko et al. (2007a). While conservativity of the
test may be dealt with using ”reverse genomic control”Amin et al. (2007), the
issue of bias in effect estimates has no solution yet. The GRAMMAR model is
implemented in GenABEL software packageAulchenko et al. (2007b).
Strictly speaking, above described two-step tests are correct if the distribu-
tions of covariates in the first and the second parts of the model are independent
162CHAPTER 6. GWA ANALYSIS IN PRESENCE OF STRATIFICATION: THEORY
L
1 X (gl,i − pl )(gl,j − pl )
fˆij = (6.19)
L pl (1 − pl )
l=1
where L is the number of loci, pl is the allelic frequency at l-th locus and gl,j
is the genotype of j-th person at the l-th locus, coded as 0, 1/2, and 1, cor-
responding to the homozygous, heterozygous, and other type of homozygous
[Link] et al. (2007); Astle and Balding ((in press); Price et al.
(2006) The frequency is computed for the allele which, when homozygous, cor-
responds to the genotype coded as ”1’.
Inetrestingly, use of the kinship matrix instead of pedigree kinship (when
available) may lead to higher power, especially when ”dense” pedigres and traits
with high heritability are considered (YSA, unpublished data). This is likely to
happen because genomic-based kinship is likely to reflect true genetic relations
better than (possibly not completely correct) pedigree expectations.
6.3. ANALYSIS OF STRUCTURED POPULATIONS 163
Figure 6.6: The European genetic structure (based on 273,464 SNPs). Three
levels of structure as revealed by PC analysis are shown: A) inter-continental; B)
intra-continental; and C) inside a single country (Estonia), where median values
of the PC1&2 are shown. D) European map illustrating the origin of sample
and population size. CEU – Utah residents with ancestry from Northern and
Western Europe, CHB – Han Chinese from Beijing, JPT - Japanese from Tokyo,
and YRI – Yoruba from Ibadan, Nigeria. (reproduced from Nelis et al. (2009))
6.3. ANALYSIS OF STRUCTURED POPULATIONS 165
Different
Mixed
Structured Models
Association +
Structured
Population
Association
EIGENSTRAT,
PC-adjustment
Genomic Mixed
Control Models
Same
6.4 Links
Here are some useful links to software which can be used for analysis in struc-
tured populations:
EIGENSTRAT: [Link]
GenABEL: [Link]
MACH: [Link]
PLINK: [Link]
Chapter 7
First, let us check how much test statistic inflation is there if we ignore
stratification.
> [Link] <- qtscore(dm2,data1)
> lambda([Link])
167
168CHAPTER 7. GWA IN PRESENCE OF GENETIC STRATIFICATION: PRACTICE
$estimate
[1] 1.051744
$se
[1] 0.000756613
We now will consider several ways to account for stratification, namely, stru-
cutured association analysis, method of Price et al. (EIGENSTRAT), a similar
method based on adjusting for the principal components of variation of genomic
kinship matrix, and use of a mixed model.
One of the ways to do that is to perform structured association analysis. In
such analysis, effect and its variance are estimated within each strata separately,
and then these estimates are pooled to generate global statistics. The strata can
be known from design (e.g. place of birth or ethnicity of parents) or estimated
from GWA data.
To do structured association analysis we need to define a variable which will
tell what population the study subjects belong to. In previous section, we stored
the names of ’outlier’ subjects in variable cl1:
> cl1
We can use function %in% to find out what names of subjects are in cl1:
Let us check how the ’population’ is distributed among the cases and con-
trols:
> table(pop,phdata(data1)$dm2)
pop 0 1
0 47 77
1 0 4
As we have seen before, one of the clusters contains only the cases.
Now, structured association may be done with qtscore function by specify-
ing strata argument:
$estimate
[1] 1.03431
$se
[1] 0.0007059588
We can compare the original results, results of analysis excluding outliers, and
structured association analysis by
7.1. ANALYSIS WITH ETHNIC ADMIXTURE 169
●
●
●
3
● ● ●
● ●
●
● ● ● ● ● ●●
●● ● ●
●● ● ●●●●● ●● ●
● ●
●
● ●
●
●● ● ● ●●● ●
●●● ● ● ● ● ●● ●● ● ● ● ●●●
●●● ●● ● ● ●
●●●
●● ●● ●● ●●
● ● ●●● ●●
● ● ●● ●● ●● ●
● ● ●● ●●●
● ●
● ●●●●●● ● ● ●●●
●
●●
● ●
●● ● ● ●
●●●●●
● ●
●●●● ● ● ● ● ●
● ●● ●●
●●●●●
● ●●● ●●
●● ● ●●
●●
● ●●
● ●● ●● ● ●●● ●● ●●● ●● ●● ● ● ● ●● ●
● ●●
●●●
●
● ●●●●●●●● ●
●
●●●● ●
●●●●●●●
●●●●
●●●
●●●
●●
●●
● ●●
●● ●
●●●
● ●●● ●
● ●
●
●●●●
●●
●●●●●
● ●
●●●●
● ●
●
●● ●● ●
●●●●●● ●●
●●
●●●●
●●
●●●●●
●●●●
●●
● ● ●
●●● ● ●●●
●●
●●●
●
● ●●●●● ●
●●●
●●●
●
●●
●● ●●●
●
●
●●●●
● ●●
●
1
●
●●
● ●●
● ●●
● ●●● ●
●●
● ●● ●
●●●
● ● ● ●● ●●●●
● ●
●● ●
●●● ●●● ●
●● ●●● ●● ● ● ●●● ●● ●
●●● ● ● ●● ● ● ● ● ●● ● ●●
●●●
● ●●
●●
●
● ●
●
●●
●
●●●
●●
●●
●
● ● ●●●●
●
●
●●●
●
●●
●
●●
●●●
●
●●
●●●
●●
●●●
●●●
●
●
●
● ●●●●
●
●●
●
●●●
●●
●●
●
●●
●●
●
●
●●
●●●
●●
●●●
●●
●●
●
●●
●
●
●
● ●● ●● ● ●
●●
●
●●●
●●
●
●●
●
●●●●
●
●●● ●
●●
●
●●
●●
●●
●●
●
●
●●
● ●
●●
●●
● ●●
●●
●
●●●
●
●●
● ● ●●●
●●
●
●●
●●
●
●●
●
● ●●
●●●
● ●
●●●●
●● ●
●●
●●
●
●●
●
●
●●
●
●
●
●●
●●●●
●●
●
●●
● ●
●●
●●
●●●●
●
●●●
●
● ●
●
●●
●
●●
●
●●●
●●
●
●
●●
●●●
●●●●● ●
●● ●●
●●●
●●
●
●
●●
●●
●●
● ●● ●
● ●
●●
●
●●
●
●
●●
●●
●
●
●●
●●
● ●
●
●
●
●
●●
●
●●●●●●
●
●
●●
1 2 3 X
Chromosome
●
●
3
●
● ●● ●
● ●
●
● ● ● ●● ●
●
● ●
●● ● ●●● ● ●
●● ●
● ● ● ●
● ● ● ●● ●
●
●● ●
● ●
●
●
●
●●
●
●●● ● ●
●
●●●●● ●● ● ● ● ●●● ●●●
● ● ● ● ●
● ● ● ● ●●●
● ● ●
● ●●●
●● ● ●
●● ●
●●● ●●●
●
● ●●●●●
● ● ●●
● ●● ● ● ●●
●
●● ●●●
●● ●● ●●● ●
● ●●●
●● ●●●●● ● ●●●●● ● ● ●●●●
●● ● ● ● ●
● ●● ●
●●●● ●●
● ●●●
●
●●
●●●
●
●
●
● ●● ●
●●●
●
●●
●●●
●●
●
●●
● ●
●
●●●
● ●●● ●●●
● ●
●
●●●●●
●
● ●
●●●
●●
● ●●
●●
●
●
●●
●●●● ●
●
●●●
●● ●●●
●
●
●
●
●●● ●
●
●●●
●
●
●● ●●● ●●●●●●● ●●●●● ●
●●●
●●●
●●
●
●
● ●●
●
● ●
● ●
● ●● ●
●● ●
●● ●● ●●
●
●●●●
●● ●●●●
●
● ●
●●
●●
● ●
●●●●●
1
● ● ● ● ● ● ● ● ● ●●
●
●●●●●
●
● ●●
●
●●
●●
●
●
●
●
●
●
●
●●
●●
●● ●●
●
●●
● ●●
●
●
●●●●
●●●
●
●●
●
●
●
●●●
●
●
●●●
●
●●
●
● ●
●
●
●
●
●●
●
●
●
●
●●
●●
●
●
●
●●
●
●●●
●●
●●
●
●
●
●
●
●●
●●●●
●
●
●
●
●●
●
●●
●
●
●●
●●●●●
●●
●
●
●
●●●
●
●
●
● ●
●
●●
●
●
● ●
●●
●
●
●
●
●
●
●
●●
●●
●●
●
●
●●
●
●
●
●●
●
●
●
● ●
●
●●
●
●●
●
●●
●●●
●●●
●
●
●●
●
●●
●
●
●●
●
●●
●
●● ●●
●●●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●●●●
●
●
●
●
●●
●
●
●●
●
●●
● ●
●●
●
●
●●●● ●●●
●
●
●
●●
●
●●●
●●
●
●
●
●
●
●
●
●
●
●●●●
●●
●
●
●
●●
●
●
●
●●
●
●●●
●●●
●
●
●●
●
●●●
●
●
●
●
●
●●
●
●●
●●
●
●
● ●
●
●
●●●
●
● ●
●●
●● ●
●●
●
●
1 2 3 X
Chromosome
●
●
3
●
● ●● ●
● ●
●
● ● ● ●● ●
●
● ●
●● ● ●●● ● ●
●● ●
● ● ● ●
● ● ● ●● ●
●
●● ●
● ●
●
●
●
●
●●
●●● ● ●
●
●●●●● ●● ● ● ● ●● ● ●●●
● ● ● ● ●
● ● ● ● ● ●●● ● ●
● ●●●
●● ● ●
●●●●
●●● ●●●
●
● ●●●●●
● ● ●●
● ●● ● ● ●●
●
●● ●●●
●● ●● ●●●● ●
●●
●●●●●●●● ● ●●●●● ● ●
●●●●●●●●●●●● ●● ● ●
●●●● ●●
● ●●●
●
●●
●●●
●
●
●
● ●● ●
●●●
●●
●●●
●●
●
●
● ●
●
●●●
●
● ●●● ●●●
● ●
●
●●●●●
●
● ●
● ●●
●● ●● ●
●
●●●
●●●● ●
●
●●●
●● ●●●
●
●
●
●
●●● ●
●
●●●
●
●
●● ●●● ●●●●●●● ●● ●● ●●
● ●●●
●
●
● ●
●●
●●● ●
● ●
● ●● ●●●
●● ● ●●
● ●●
●● ●●●●
●
● ●
●●
●●
● ●
●●●●●
1
● ● ● ● ● ● ● ● ● ●●
●
●●●●●
●
● ●●
●
●
●●
●●
●
●
●
●
●
●
●
●
●●
●●
●● ●●
●
●●
● ●●
●
●
●●●●
●●●
●
●●
●
●
●
●●●
●
●
●●●
●
●●
●
● ●
●
●
●
●
●●
●
●
●
●
●●
●●
●
●
●
●●
●
●●
●●●
●●
●
●
●
●
●
●
●●
●●●●
●
●
●
●
●●
●
●●
●
●
●●
●●●●●
●●
●
●
●
●●●
●
●
●
● ●
●
●●
●
●
● ●
●●
●
●
●
●
●
●
●
●●●
●●
●●
●
●
●●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●●
●
●●
●●●
●
●
●
●
●
●●●
●
●●
●
●●
●
●
●
●● ●
●
●
●●
●
●
●●
●●
●
●●●
●●
●
●
●●●●●
●
● ●●●
●
●
●
●●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●
●●●
●
●
●
●●
●
●
●
●●
●
●●
●●
●●●
●
●
●●
●
●
●
●●●
●
●
●
●
●
●●
●
●●
●●
●
●
● ●
●
●
●●●
●
● ●
●●
●●●●
●●
●
●
1 2 3 X
Chromosome
> par(mfcol=c(3,1))
> plot([Link],ylim=c(1,6))
> plot([Link],ylim=c(1,6))
> plot([Link],ylim=c(1,6))
> par(mfcol=c(1,1))
The resulting plot is presented at figure 7.1. In this case, there is little difference,
because all people belonging to the smaller sub-population are cases.
Other way to adjust for genetic (sub)structure is to apply the method of
Price et al. (EIGENSTRAT ), which make use of principal components of the
genomic kinship matrix to adjust both phenotypes and genotypes for possible
stratification. In GenABEL-package, such analysis is done using egscore func-
tion.
> [Link] <- egscore(dm2,data=data1,kin=[Link])
> lambda([Link])
$estimate
[1] 1.102747
$se
[1] 0.001043038
> par(mfcol=c(3,1))
> plot([Link],ylim=c(1,6))
Now let us apply adjustment for the stratification by use of the principal
components of genetic variation. For that we first need to extract the principal
components of genetic variation by constructing the distance matrix
$estimate
[1] 1.004946
$se
[1] 0.0007356663
> plot([Link],ylim=c(1,6))
Finally, let us use the full genomic kinship matrix for the adjustemnt for
pupulational structure. First, let us estimate the polygenic model with
> h2a$esth2
[1] 0.2547813
Now we can perform mixed model approximation analysis using mmscore func-
tion
7.1. ANALYSIS WITH ETHNIC ADMIXTURE 171
●
● ●
3
● ● ●
● ●
●
● ● ● ●● ●
●
● ● ● ●● ● ● ● ●●●
●● ●●
● ●● ● ● ●● ●●
● ●
2
●
●
●●● ●● ● ●● ● ●● ●● ● ●● ●●●●● ● ● ●● ● ● ● ●●
●
●● ● ●●
●
●
● ● ●●●● ●● ● ●
● ●● ● ● ● ●
● ●●●
● ● ●● ● ● ●● ● ●● ●● ● ●●
●
●
●● ●
●●●●
●
●●
●
●●
●
●
● ●●
●
●●
● ●● ●
●●● ●●
● ●●●●●
●
●●●
●● ● ● ●
●●
●●● ●
●
●
●
●●
●
● ● ●●
● ● ●
●●●
●
● ●●
● ●● ● ●●●
●●
● ● ● ●
●●
●● ● ● ● ●●● ●● ●
●
●
●
●●
● ●●●
●● ● ●
● ●
●
●
●
●● ● ●● ●● ●
●
●
●●●
●
●●
●● ●●● ● ●●
●●
● ● ●●●
● ● ●●
● ●●● ●●
● ● ● ●● ●
●●●●
●
● ●● ●
●
● ● ●● ●●●●●●
●
● ● ●●●●● ● ●● ●
● ● ●● ●●●● ●● ●●
● ●● ●● ● ●●● ●
●● ●●●●●
● ● ● ●●●●●● ●●● ●●●● ● ● ● ●
● ●
●●●●
●●● ●●
●●●●
● ● ● ●● ●● ● ● ●● ● ●● ●● ●●
● ●
●●● ●●●●●
● ● ●
● ●●
1
●●● ●● ●
●●
●●●●●●●●● ●● ●●
●● ●●●
●● ●
●●●● ●
●●●
● ●
●●●●●●●●
● ●● ●
●● ●● ●
●● ●●
●●●● ●●
●●● ●
●●● ●●
● ●
●
●●
●●● ●●
●● ●
●●●● ●● ●●
●● ●
●●● ● ●●
●● ● ●
● ●●
● ●●●
● ● ●
●●
●●
●
● ●● ● ● ●●●●●● ●● ●● ●
●● ●
●● ●●
● ● ●
● ● ●
● ●
●●●
●● ● ●● ●
●● ●●
● ●● ●●
● ● ● ● ●● ● ● ●● ●● ● ●●● ●●●
● ● ● ●
●●
● ●
●●
●●●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●●
●●●
●
●●
●
●
●●
●
●
●●
●
●●●●
●●●●●
●●
● ●
●●
●●●●●
●
●●
●
●
●●
●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●●●
●
●
●
●
●●●
●
●●
●●
●●
●
● ●●
●
●●
●
●
●
●
●
●●
●
● ●●
●
●
●
●
●●
● ●
●●●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●● ●
●
●
●
●●●
●
●●
●●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●●
●
●
●
●
●●
●
●●●
●●
●
●●
●
●●
●
●●
● ●
●●
●
●
●
●
●
●●
●●
●
●
●
●
●
●●
●
●
●●
●● ●
●●
●●●
●
●●●
●
●●●
●●
●
●
●●
●● ●
●
●● ●
●●
●●
●
●
●●●●
●
●
●●●
●
●
●
●
●
●
●●●
● ●●●
●
●●
●
●
●●
●
●●
●●
●
●
●●●
●
●●
●
●
●
●
●
●●●
●
●
●
●
●
●●
●●
●
● ●
●●
●
●
●
●
●●
● ●
●
●●
●●
●
●●
●
●●
●
●
●
●●●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●●
●
●
●●
●●
●●
●
●●
●●
●●●
●
●●
●
●
●
●
●
●
●●
●●
●●
●●
●●
●
●●●
●●
●
●
●
●●
●
●●
●
●
●
●
●●
●
●
●●●
●
●●
●
●
●●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●●
●●●
●
●
●●●
●
●
●
●
●
●●
●●
●
●●●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
● ●
●
●
●●
●
●
●
●●
● ●
●
●●
●
●
●●
●
●●
●●●
●●
●
●●
●
●●
●●
●● ●
●●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●●
●
●●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●●
●
●
●●
●
●●
●
●●
●●
●●
●
●
● ●●
●●
●●●
●
●●
●●
●
●
●●
●●
●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●
●●
●
●●
●●
●●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●●
●
●●●
●
●●●
●●●
●
●
●●
●
●●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●●●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●●
●●
●
●●
●
●
●
●
●
●
●●
●
●
●
●●
●● ●
●●●●
●
●●
● ●●●
●●
●●
●●
●●
●●● ●●
●
● ●
●●●
●●
●●
●●
●●●
● ●●●
●●
●●●●●●●●
●●
● ●
●
● ●●●●
●●●●●●●
●●
●
●
●●●
●● ●
●
●●●
●●
●●
●
●●●
●
●●●●●
●●
● ●●
●
● ●
●●●
●●
●●●●●●●●●●
● ●●
●
●●●
●●●●
●●
●●
●●●
●●
●
● ●●
●
● ●●
●●
●●
●●
●●● ●
●●
●●●●●●●●
●● ●
●
●
●●
●●●●●
● ●
● ●●
●●●●●
●●
●● ●●
●●●
●
● ●●●●
●
●
●●●
●
●
●
●●●
●●
●●●
●
●
●●
● ●
●
●●
●●
●
●
●●
●●
●●●
●
●
●●
●
●
●●●●
● ●●●
●
●●
●
●●
●
●
●●●
●
●●
●
●●●●
● ●●●
●
●●●
●
●
●
●●
●
●
●●
●●
●●●
● ●
●
●●
●●
●
●●
●
●
●●
●
●●
●●
●●
●●●●
●
●●
●●
●●●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●
●
●●●●
●●
●●
●●
●
●● ●●●●
● ●
●
●●
●●●●
●
●
●●
●
●●
●
●●
●●
●
●●
●
●
● ●●
●●●
●●
●
●●
●●
●
●
●●
●●
●●
●●
●
●●●●
●●
●●
●
●●
●●
●
●●●
●●
●
●●
●●
●
●●
●●●
●●
●●
●●
●
●
●●
●
●
●● ●
●
●
●●
●●
●●
●●●
●
●
●
●●●
● ●●
●●
●
●●
●●
●
●
●
●●●●●
● ●
●●●●
●●
●
● ●
●●
●●
●
●
●●
●
● ●
●
●●
●
●●
●
●●
●●●
●
●●
●●
●●
● ●
●
●
0
1 2 3 X
Chromosome
●
3
● ● ● ● ● ●
● ● ● ●● ●
● ● ● ●
● ●● ● ● ● ●● ●●● ● ●
● ●● ●
2
● ● ● ●● ● ● ●
●●
● ● ●
● ●●● ●●●●●● ●● ● ●●●● ● ●● ● ● ● ● ● ●●● ● ● ● ● ●●●
● ●
● ● ●● ●● ● ●●●●
● ● ● ●● ●●
● ●●
● ●●●●
● ● ● ●● ● ● ●● ●●
●
●●
●
●●
● ● ●
●●●●
● ●●●
● ● ● ●● ●
● ●●
●
●●
● ●●●
●● ● ●●
●● ●●
●
●
●●
●
● ● ● ●
● ●● ●
●●
●●
●
● ● ●●●● ● ●
●● ● ●●
● ●●
●● ●
●
●●●
● ●●● ● ●● ●●●●
●
●●
●●● ●●●
●● ●● ●●● ●●●
●
●
●
●
●●● ● ●
●
●●●●
● ●● ●●●●●●
● ● ●●
● ● ●
●● ●●●● ●●●● ● ●● ●●
●● ●●●●●●●●● ●
● ●● ●
● ●
●●● ● ● ● ● ● ●●
● ●●●●●
●● ● ●● ●● ●●●●●● ●
● ●● ●● ●
●● ●● ● ● ● ●● ● ● ●
1
●● ●●●
● ● ●●●●● ● ●●
●●● ●● ●●● ● ●● ● ● ●●●
●●
● ●
●●● ●
●●●● ●●● ● ●● ●
● ● ● ●●●● ●● ● ●
● ● ●● ●●●●● ● ●●
●●
●●●
● ●●
● ●●●
●
●●
●●●●●
● ●● ●● ● ●
●
●
●
●
●●●●
●●●
●
●●●
●●
●
●●
●
●
●●
● ●
●
● ● ●
●●●
●
●
●
●
●●●●●
●●
●●
● ●
●●●
●
●
●
● ●●
●
●
●
●●●●
●
●●●●
●●
●●
●
●●
●●●
●
●
●
●●
●
●●● ●●
●
●
●●●
●●
●
●
●
●
●
●
●
●
●●
●
●●●
● ●
●●●
●
●
●
●●
●●
●
●
● ●●
●● ●
●
●●
●
●●
● ●●
●● ●
●●●●● ● ●
●
●
●
●●
●●
●●
●
●
●
●
●
●
●
●●●● ●●
●●
●●●●
●●●●
●
●
●●
●●
●
●●
●● ●●
●
●
●●
●
●
●●
●●●
●●
●
●
●
●
●
●●●●
●
●●
●●●
●●
●●
●
●●●
●●
●
●●
●●
●●●
●●
●
●●●●
●●
●●
●
●●●●
●●
●●
●
●●
● ●
●●
●●
●●
●●●
●
●
●●●
●
●● ●
●●
●●●●
●●●
● ●
●●
●●●
●●
●●
●
●●●
●●
●
●●
● ●●
●●●●
●
●● ●
●●
●
●●●
●●
●
●
●● ●●●
●
●●
●●●
●
●●●
●●
●●●
● ● ●
●
●
●●
●
●●
●●●
●●
●●●●●
●●
●●
●
●●
● ●
●●●
●●●●
● ●●● ●
● ●
●●
●●
●
●●●
●●
●●
●
●
●●
●
● ● ●
●
●
● ●
●
●●
●●
●
●●●
●
●●
●
●
●
●●
●●●●
●●
●●●
● ●●●
●
●
●●
●●●
● ●
●●
●●
●
●
●●●●●
●●
●
●●
●
●●
●
●●
●
●●●●
●
●●
●●
●
●
●●●
●
●●
●●
●●●
●
●●
●●
●
●●●
●
●
●●●
●
●●●
●●●●
●
●
●
●
●●
●●
●
● ●
●
●●
●●
●
●
●●
●
●
●●●
●
●
●●
●●●●●
●
●●●
●
●
●●
●●
●●
●●
●
●●
●●●
●
●
●●
●●
●●
●
●
●●
●
● ●
●
●●
●●
●●●●●
●●
●●●
●● ●●●
●●
●●
●
●●
●●
●●
●
●
●●
●●
●
●●
●●
●●
●●
●
●●
●●
●●
●
●●
●●
●●●●
● ●
●●●●
●
●
●
●●
●●
●●
●
●
●●
●●
●
●
●●
●
●●
●
●
●
● ●
●
●
●
●●●●
●●●
●●
●
● ●
●
●●●
●
●
●●
●
●●
●
●
●●
●
●●
●●
●●
●●
●●
● ●
●
●●
●●
●
●
●●
●
●●
●
●●●
●●
●
●●
●
●
●●●
● ●●
●●
●
●● ●
●
●●
●
●
●●●
●
●●
●●
●
●
●●●
●
●●
●
●●
●
●
●●
●
●●●●
●
●●
●
●
●●
●●
●
●●
●●
●●
●
●●
●
●●
●●●
●
●
●
●●
●
●●
●●
●●
● ●
●●●
●
●
●●●
●
●●●
●
●
●
●●
●
●●●
●
●●●
●
●●
●●
●
●
●●
●
●
●●
●●
●●
●●
●
●●●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●●
●
● ●●●
●
●●
●
●●●
●
●●●
●
●●
●
●
●●
●
●
●●
●●
● ●
●
●
●●
●
●●
●●
●
●●
●
● ●
●
●●
●●
●
●
●●
●
●●
●● ●●
●●
●
●
● ●
●
●
●●
●
●●
●●
●
●
●●●
●●
●●●
●
●●
●●
●●
●
●●
●
●●
●
●●
●
●●
●●
●
●●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●●
●
●●
●●
●
●
●●
●●●
●
●
●●
●
●
●●
●●●
●
●
●●
●
●
●● ●
●
●
●●
●
●
●
●●
●●●
●
●
●●
●
●●
●●
●
●
●●●
●●
●
●
●●
●●
●
●
●●
●●●
●
●
●●
●●
●●
●●
●●
●
●
●
●
●●
●● ●
●
●●
●
●
●●
●
●
●●
●
● ●
●
●●
●●
●
●●
●●
●
●
●●●
●●
●●
●
●
●
●●
●
●
●
●●●
●●
●
●●●
● ●●
●●
● ●
●●●
●●●
●
●
●●●
●
●
●●
●
●●
●
●●●●●
●●
●
●
●
●●
●
●●●
●
●
●
●●
●●
● ●●
●● ●●
●
●
●●
●●
● ●●
●● ●
●
●●
●●
●
●●
●
●●
●●
● ●
●●●
●●●
●●
●●●
●
●●●
●
●●
●
●●●
●●
●
●●
●
●
●●
●
●●●
●●●●
●●●●
●●
●●
●●
● ● ●●
●●
●●●
●
●●
●●
●●
●
●●
●
●●
●●
●●●●
●●
●
●●
●
●●
● ●
●●●
●
●●●●
●
● ●●●
● ●
●●
●
●
●●
●●
●●
●●
●●
●●
● ●●
●
●●
●●
●
●●●
●● ●
●
●
●●●●
●
●●
●●
●●●●
●
●
● ●
●●
●●●
●●●
●
●●
●●●●●●
● ●
●●●●
●●●
●
●●
●
● ●
●●
●
●
●
●●
●●
●●●●
●●
●●
●
●
●●
●
●
0
1 2 3 X
Chromosome
mmscore(h2a, data1)
− log10(P − value)
●
3
● ● ●
●
●●●
● ● ●
● ● ●
●
● ●● ●● ● ● ●
2
● ● ● ●
●● ●● ● ●
● ●●● ● ●● ●●●● ● ●●● ●
●●● ● ● ● ● ● ●●● ●● ● ●
● ●
●● ● ● ● ●
● ●
●
● ●●●● ●●●●● ● ● ● ● ●●● ● ●●
●● ●● ● ● ●● ● ● ● ●●●●● ● ●● ● ●
●● ●●
●
●
●●●
●● ●
●
●
● ●●● ●●●
● ●●
●
● ●● ●●●●
● ●●●●
●●●
●● ●
● ●●●● ●●●●●● ● ●
●●●●
●
●●●● ●● ●
●●
●●●●●
●●● ●
●
●
●● ●● ● ●
●●●●● ● ● ●●●●
● ●● ●● ●● ●
●●
●
● ● ●
● ● ●
●●
●
● ●● ●
● ●●
● ●●●●
● ●● ● ●● ●● ● ● ● ●
● ●● ● ● ●●● ●● ● ●●●● ● ●●●●
●●●●● ● ●●● ●●●●●
● ● ●●
●● ● ●●
● ● ● ● ●● ●●● ● ● ●●
1
● ●
● ●
●● ●
●●●●
●● ●●● ● ● ●●
● ●
●● ●● ● ● ● ●●●●●
●● ●●● ● ●● ● ●● ● ● ● ●●●
● ●
● ●●
●
● ●
● ● ●
●● ●
●
● ●● ● ●●● ● ●
●●●●
●
●●
●●●
●
●
●
●
●●
● ●●
●●
●●
●●●
●
●
●
●
●
●
●
●●●
●
●●
●●●●●●
●
●
●●
●
●
●●●●
●
●
●●
●●
●
●
●
●
●
●●●
●
●
●
●●●●
●
●
●
●
●
●
●●
●
●●●●
●●●
●●●
●●●
●●
●●
●
●●
●●●
●
●●●
● ●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●●
●●
●
●
●
●
●
●
●
●●
● ●
●
●
●
●
●●●
●●●
●
●
●
●● ●●
●
●
●
●
●
●●●
●
● ●
●
●
●●●●
●
● ●
●●●
●●
●
●
●
●
●
●
●
●
●
●●●●
●● ●●●●
●
●
●
●
●
●
●
●
●
●●●
●
●
●●
●
●
●●
●●
●
●●
●●
●
●
●
●●
●●●
● ●●●●● ●●●
●
●●
●
●
●
●
●
●
●●
●●
●●●
●
●●●
●
●
●●● ●●●●
●
●●●●●
●
●● ●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
● ●
●
●
●●
●
●●●
●
●
●
●
●
●
●
●●
●●
●
●●
●
● ●●
●
●● ●●
●
●
●●
●●
●●●
●
●●
●
● ●●
●●
●
●
●●
●●
●●
●●●
●●● ●
●
●
●●
●●●
●
●●
●●
●●
●●
●
●
●●●●
●
●●
● ●
●
●
●●
●●●●
●
●●●●
● ●
●●
● ●
●
●●
●
●●●
●
●●●
●●
●●●
●●
●●
●●●●
●
●●
●●
●
● ●
●
●
● ●●
●●●●
●●
●●
●
●●●●
●●
●
●●
●
●●
●
●●●
●
●●●
●● ●
●●
●● ●
● ●
●
●●
●
●●●●●
●●●●
●
●●
●●●
● ● ●
●● ●●
● ●
● ●●●
●
●
●●
●●
●●
●●
●●● ●●●●
●●●
●
● ●
●
●●
●●
●
●●
●
●
●●
●●●●
●●●
●
●● ●●
●●
●
●●
●●●●
●●
●●●
●
●
●●
●●●
●
●●
●●
●
●
●
●●
●
●
●●●●
● ●
●
●●
●
●
●●●
●●
●●●
●●●
●
●●
●●
●●
●●
●●
●
●
●
●●
●
●●●
●●
●●
●●●
●
●●
●
●●
●
●●
●
●●
●
●●●●
●
●
●●●
●●●
● ●
●
●●
●●●
●
●●
●
●●
●
●●
●●
●●
●
●
●●
●
●
●●
●●
●●
●
●●
●● ●
●
●●
●
● ●
●
●●●
●●
●●
●
●● ●●
●●
●
●
●
●●●
● ●
●●
●
●
●●
●●
●
●●
●●
●
●●
●●●
●
●●
●●
●
●
●●●●
●●●
● ●●●
● ●
● ●●
●
●●
●
●●
●
●
●●
●
●●
●
●
●
●●
● ●
●●
●●●
●● ●
●
●
●●
● ●
●
●
●
●●●
●●
●
●
●●●
●●
●
●●●
●●●●
●●
●
● ●●
●●
●●
●●
●●
●
●●
●●
● ●
●
●
●●
●●
●
●● ●●
●
●
●●
●
●
● ●
●
●
●●●
●
●●●
●
●
●●
●
●
●●
●
●
●●●●
●
●
●●
●●
●●
●
●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●●●●
●
●●●
●●
●
●
●●
●●
●
●
●●●
●
●●
●
●
●●
●
●●●
●
●●
●●●●
●
●
●●●
●
●●
●●●
●
● ●●
●
●
●●
●●
●●
●
●●●
●●
●
●●
●
●●
● ●
●
●●
●●
●
●
●
●
●●●
●
●●
●
●● ●
●
●
●●
●
●●
●
●
●●
●●
●
●●●
●●
●
●
●●
●
●●
●
●● ●●
●
●● ●
●●
●
●●
●●
●
●
●●
●●
●●
●●
●●●
●
●
●●
●●●●●
●
● ●
●
●●
●●
●
●●
●●
●●
●●
●
●
● ●
●
●●
●
●●
●●
●
●●
●●
●●
●
●●
●●
●
●●
●●●
●●
●
●
●●
●● ●
●
●●
●●
●
●●
●
●●
●
●
●●
●●●
●●
● ●●
●
●●
●
●
●
●●
●●
●
●
●●
●
●
●●●
●●
●●
●
●●●
●
●●●
●●
●
●●
●●
● ●
●●●●●
●
●
● ●
● ●
●●
●
●●
●
●●
●●
●●●●
●●
● ●
●●
●●●
●
●●●●
●
●
●●
● ●●
●
●●●
●
●●●●●●●
●
●●●●●●●
●
●
●●●
●●●
●
●●
●
●●
●
●
● ●
●
●●●●
●●●
●●●
● ●
●●●
● ●
●●
● ●
●
●●●
●●
●
●
●
● ●
●●
●●
● ●●
●●
●●●●●●
● ●
●
●
●●
●●
●
●
●●
●
●●
●●
●
●
●●
●●●
●
●●● ●
●●
●● ●
●
●
●●●
●
●●
●
●
● ●
●●●●●
●
●
●●
●●
●●●●
●● ●
●
●●●●●●
● ●
●●●
●
●●●
●●●
●
●●
●●
●
●
● ●●
●●
●●●●●●
●
●●
● ●●●●●●
●●
●●● ●●
●●
●●
●●
●●●●
●
●● ●
●
●● ●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●●
●●
●●
●
●
●●●
●
●●
●
●
●●
●●
●
●●●
●●●
●●
●
●●
●●
●●
●●●
● ●
●
●●
●●
●
●●
●
● ●
●
●●
●●
●
●
●●
●
●●●●
●●
● ●
●
●
●●●
●
●
●
●●
●
●
0
1 2 3 X
Chromosome
$estimate
[1] 1
$se
[1] NA
> plot([Link],ylim=c(1,6))
> par(mfcol=c(1,1))
Two traits (’quat’ and ’bint’) ara available for analysis. Investigate relations
between phenotypes and covariates. Perform association analysis. Answer the
questions
DATAPROBLEM: ok, here is a problem; replacing the ’strdat’
with data set available within GenABEL. Hence comments to the
analysis below are not making sense anymore
Ex. 1 — What covariates are significantly associated with the traits?
Ex. 2 — How many SNPs and IDs are presented in the data set?
Ex. 3 — How many SNPs and IDs pass the quality control (use SNP and ID
call rate of 0.98)?
Ex. 5 — Is there evidence that the test statistics for trait quat is inflated
(what is λ?)
Ex. 6 — Is there evidence that the test statistics for trait bint is inflated
(what is λ?)
Ex. 7 — How many genetically distinct populations are present in the data
set? How many people belong to each population?
Ex. 10 — What is the strongest SNP associated with trait quat? What model
(method and covariates used) gives best results? Is the finding GW-significant?
Ex. 11 — What is the strongest SNP associated with trait bint? What model
(method and covariates used) gives best results? Is the finding GW-significant?
Y =µ+G+e (7.1)
parameters:
2 1
L(µ, σG , σe2 ) = − 2
· loge (Φ · σG + I · σe2 )
2
2
+ (Y − µ)T · (Φ · σG + I · σe2 )−1 · (Y − µ) (7.2)
2
where µ is intercept, σG is the proportion of variance explained by the polygenic
2
component, and σe is the residual variance.
Covariates such as sex, age, or a genetic marker studied for association can
be easily included into the model:
X
Y =µ+ βj · Cj + G + e
j
Here, Cj is the vector containing j-th covariate and betaj is the coefficient
of regression of Y onto that covariate.
This mixed morel leads to likleihood
2 1
L(µ, σG , σe2 , β1 , β2 , ...) = − 2
· loge (Φ · σG + I · σe2 )
2
T
X
2
−1
+ Y − (µ + β j · C j ) · Φ · σG + I · σe2
j
X
· Y − (µ + βj · Cj ) (7.3)
j
Y = µ + βg · g + G + e
where g is the vector containing genotypic values. In this mode, you can specify
a variety of 1 d.f. models by different coding of the vector g. For example, if you
consider an ”AG” polymorphism and want to estimate and test additive effect
of the allele ”G”, you should code ”AA” as 0 (zero), ”AG” as 1 and ”GG” as
2. Under this coding, the βg will estimate additive contribution from the ”G”
allele. If you are willing to consider dominant model for G, you should code
”AA” and ”AG” as 0 and ”GG” as 1. Recessive and over-dominant models can
be specified in a similar manner. If, however, you want to estimate general 2
d.f. model, the specification should be different:
Y = µ + βa · g + βd · Ig=2 + G + e
where g is coded as 0, 1 or 2, exactly the same as in the additive model, and Ig=2
is the binary indicator which takes value of one when g is equal to 2 and zero
otherwise. In this model, βa will estimate the additive and βd – the dominance
effect. There may be other, alternative coding(s) allowing for essentially the
same model, for example
Y = µ + β1 · Ig=1 + β2 · Ig=2 + G + e
7.2. ANALYSIS OF FAMILY DATA 175
would estimate trait’s deviation in these with g = 1 (β1 ) and these with g = 2
(β2 ) from the reference (g = 0).
The classical way to estimate mixed polygenic model and test for significance
is Maximum Likelihood (ML) or Restricted ML (REML) using equation (7.3).
However, when large pedigrees are analysed, ML/REML solution may take pro-
hibitively long time, i.e. from minutes to hours for single SNP analysis, making
study of hundreds of thousand of SNPs impossible. Therefore fast approximate
tests were developed for the purposes of GWA association analysis in samples
of relatives.
Here we will cover two of fast approximations available, FAmily-based Score
Test for Association (FASTA, Chen & Abecasis, 2007) and Genome-wide Rapid
Analysis using Mixed Models And Score test (GRAMMAS, Amin et al, 2007).
Both tests are based on the classical polygenic mixed model and are performed
in two steps.
First, polygenic model as specified by equation (7.1) and likelihood (7.2) is
estimated using available data.
Secondly, the maximum likelihood estimates (MLEs) of the intercept, µ̂,
2
proportion of variance explained by the polygenic component, σ̂G , and residual
2
variance, σ̂e , are used to compute the FASTA test statistics
2
2
(g − E[g])T · (Φ · σ̂G + I · σ̂e2 )−1 · (Y − µ̂)
TF2 = 2 + I · σ̂ 2 )−1 · (g − E[g])
(g − E[g])T · (Φ · σ̂G e
It can be shown that TF2 follows χ21 when pedigree structure is 100% complete
and 100% correct. As this is never actually the case, application of GC to correct
for residual inflation is recommended.
FASTA test results in unbiased estimates of the SNP effect and correct
P − values. Please keep in mind that this is correct – as for any score test
– only when alternative is reasonably close to the null, i.e. when the SNP
explains small proportion of trait’s variance. Disadvantages of this test are
that is can be relatively slow when thousands of study subjects are analysed,
and that permutation procedures can not be applied to estimate genome-wide
significance, because the data structure is not exchangeable.
Other test, GRAMMAS, also exploits MLEs from the polygenic model (7.1).
However, these are used to first compute the vector of environmental residuals
ê, using standard equation
ê = σ̂e2 · (Φ · σ̂G
2
+ I · σ̂e2 )−1 · (Y − µ̂)
This test is conservative, but GC can be used to correct for the deflation of
the test statistics.
The fact that environmental residuals ê are not dependent on pedigree struc-
ture leads to a nice property of the GRAMMAS test: the data structure be-
comes exchangeable and permutations may be used to estimate genome-wide
significance. When used in combination with GC, P − values derived from
176CHAPTER 7. GWA IN PRESENCE OF GENETIC STRATIFICATION: PRACTICE
> #load("RData/[Link]")
> data([Link])
> erfs <- [Link][1:100,]
> phdata(erfs)$qtbas <- phdata(erfs)$weight
> pkins <- matrix(rnorm(nids(erfs)^2,sd=0.01),ncol=nids(erfs),nrow=nids(erfs))
> ls()
> class(erfs)
[1] "[Link]"
attr(,"package")
[1] "GenABEL"
> class(pkins)
[1] "matrix"
You can see that there a two objects, erfs and pkins, presented in the data.
The class of the first object is standard GenABEL-package’s [Link]-class;
this is the object containing GWA data. The other object contains kinship
matrix, as estimated from pedigree data.
You can check the number of people and SNPs in the data set with
> nids(erfs)
[1] 100
7.3. EXAMPLE GWA ANALYSIS USING FAMILY-BASED DATA 177
> nsnps(erfs)
[1] 7374
As usual, it is advisable to check the distribution of SNPs by chromosome:
> table(chromosome(erfs))
1 2 3 X
3482 1927 1417 548
(here, 23 stays for pseudo-autosomal region of the X chromosome); you can see
that markers are evenly spread over the chromosomes.
Summary marker statistics can be generated by
> [Link](gtdata(erfs))
$`Minor allele frequency distribution`
X<=0.01 0.01<X<=0.05 0.05<X<=0.1 0.1<X<=0.2 X>0.2
No 336.000 1289.000 1275.000 1625.00 2849.000
Prop 0.046 0.175 0.173 0.22 0.386
> pkins[1:5,1:5]
By definition, pedigree kinship should take values between 0 and 0.5 (plus
some small amount from inbreeding); kinship between (non-inbred) sibs or an
offspring and the parent is 1/4. You can see that in the upper-left corner there
is one inbred sib-pair (or parent-offspring pair; ”id2” and ”id5”). You can also
see that this matrix is symmetric around the diagonal.
Let us summarise the distribution of kinship coefficients; in doing this we
want to generate the summary for every off-diagonal element only once. Func-
tion [Link] can be used to get the ”lower triangle” sub-matrix elements:
> summary(pkins[[Link](pkins)])
> hist(pkins[[Link](pkins)])
Here, the estimated kinship is shown below the diagonal, and the number of
informative SNP pairs used for estimation is shown above the diagonal.
You can see that ”genomic kinship” coefficients may take values lower than
zero, which is consequence of the fact that in effect ”genomic kinship” is simply
covariance between the vectors of individual genotypes. This quantity, though
it provides an unbiased estimate of kinship, can be lower than zero.
> summary(gkins[[Link](gkins)])
7.3. EXAMPLE GWA ANALYSIS USING FAMILY-BASED DATA 179
0.15
●
● ● ●●
● ●
●
0.10
●
●● ● ●
●
● ● ● ●● ● ●●●● ●
● ●● ●●● ●● ● ●
● ● ●● ●●● ●
●●● ● ●● ● ●● ●● ● ● ●
●● ●●●● ● ●● ●
0.05
●
● ●● ● ●●● ●● ● ● ● ● ●● ●
●●●● ●● ●● ●
● ● ●
●● ● ●
●
● ● ● ●●●
●●● ● ●●● ●●● ● ●●
●● ● ●●
● ● ●● ●●● ●
● ● ● ● ● ●● ●● ●
pcs[, 1:2][,2]
●● ● ●● ●● ● ●●● ● ● ● ● ● ●
● ● ● ●● ● ●● ●● ● ●● ● ● ●
●●
●●● ●●●●
●● ●●
●●●●● ●● ●● ●●●●●● ●● ● ●● ●● ●
●● ●● ●●
● ● ● ●●●● ●●
● ●●
●● ● ●
● ●●●●● ●
● ●●
● ●● ●●● ● ●● ● ●
● ● ● ●●●● ●
●
● ●
● ●● ●
● ●●●●
●
●
● ●
● ●● ●● ●●● ● ●●●
●
●● ● ● ●
● ● ●
●●●● ● ● ●● ●● ●●● ● ●
● ●● ●●●● ●●●●●● ● ●●● ●●●● ●●
●●● ●● ● ●
0.00
● ●●●● ●
●●
● ●
●
●● ●● ●
●
●
●● ●●●●
●●●
● ● ●● ●●●●
● ●● ● ●● ●●
● ●● ●● ● ●● ●
● ● ●● ● ●●● ●●●● ● ● ●● ●●● ●●●●● ●● ● ●●
●●
●● ● ● ● ●● ●
● ● ●● ● ● ● ●●
●● ●●●● ● ●
● ●● ●● ●● ● ●
● ●●● ●● ● ● ●
●
●● ●
●
●
●
●
●● ●●●●●●●●
●
●● ● ●
● ● ● ●● ●● ●● ● ●●●●●
● ●●●●●●●●● ●● ● ●●● ●● ●●●● ● ●●●●● ●
● ●
● ●
● ● ● ●● ●● ●
●● ●● ●● ●
●
● ●●●●●
●
●●● ●●
● ● ●●●●
● ●
● ●
●●●● ●●
●●● ●● ● ●● ●
● ●●● ● ●● ● ● ●●
● ●● ●● ●
−0.05
● ● ● ● ●● ● ●
● ●● ●●●● ● ●●
● ●●●●● ● ●
● ● ●● ● ●
● ●
●
● ● ● ●● ●● ● ● ●
●
●●● ● ●
●
● ● ● ● ● ●
●● ● ● ● ●●● ● ●● ● ● ●●
● ●
●
● ● ● ●● ● ● ●
● ● ● ●●● ● ●●● ●●
● ● ●● ●● ● ● ● ● ● ●
● ●●
● ● ●● ●
● ●● ●●● ● ●
−0.10
● ● ●● ●● ● ●
● ● ●
●
● ● ● ●
● ●● ●
●●
pcs[, 1:2][,1]
here, the average is quite close to that obtained with pedigree kinship.
We can also draw a histogram of the distribution of ”genomic kinship” co-
efficients (shown at figure 7.4B):
> hist(gkins[[Link](gkins)])
and can easily graphically present relations between genomic and pedigree kin-
ship with
> plot(pkins[[Link](pkins)],gkins[[Link](gkins)])
(shown at figure 7.5), and estimate correlation between the two with
> cor(pkins[[Link](pkins)],gkins[[Link](gkins)])
[1] 0.01196389
From the graph, you can clearly see that, though there is a very strong
correlation between genomic and pedigree kinships, these are not identical.
In real data, you may find that there are some points where pedigree data
clearly suggest relation different from that suggested by genomic data. Which
one to believe? Generally, pedigrees are more prone to errors than genotypic
180CHAPTER 7. GWA IN PRESENCE OF GENETIC STRATIFICATION: PRACTICE
Histogram of pkins[[Link](pkins)]
800
Frequency
400
0
pkins[[Link](pkins)]
Histogram of gkins[[Link](gkins)]
2000
Frequency
1000
0
gkins[[Link](gkins)]
Figure 7.4: Distribution of the pedigree (upper histogram) and genomic (lower
histogram) kinship coefficients for erfs data set.
> lambda(qts)$est
[1] 1.033775
This is relatively high value, suggesting presence of close relatives in data and
high heritability of the trait.
The top 10 hits from GWA analysis can be displayed with
> [Link](qts,sort="Pc1df")
here, nominal P − values after genomic control are given in column named
”Pc1df”.
We can estimate genome-wide empirical significance by using the same func-
tion with times argument, which tells the number of permutations:
|
| | 0%
|
|======================================================================| 100%
> [Link](qts.e,sort="Pc1df")
(argument ”quiet” supress warning messages; this is used for the purposes of
this tutorial, normally you do not need to specify this option)
As you can see, in this analysis nothing comes even close to genome-wide sig-
nificance, as indicated by genome-wide corrected P − values (column ”Pc1df”)
all >> 0.05 .
Let us estimate polygenic model with
> h2 <- polygenic(qtbas,kin=gkins,data=erfs)
The results of estimation are contained in ”h2an” element of the resulting
analysis object:
> h2$h2an
$minimum
[1] 747.5489
$estimate
[1] 92.3114671 0.4273438 663.0750850
$gradient
[1] -1.421085e-07 -5.684342e-08 1.278977e-07
$code
[1] 1
$iterations
[1] 7
In the ”estimate” list, the MLEs shown correspond to intercept µ̂, heritability
ĥ2 = σ̂G
2 2
/(σ̂G + σ̂e2 ), and total variance σ̂T2 = σ̂G
2
+ σ̂e2 . You can see that
heritability of the trait is indeed high – almost 80%.
Under these conditions (hight heritability, presence of close relatives) we
may expect that FASTA and GRAMMAS analysis exploiting heritability model
and relationship matrix in exact manner may have better power compared to
simple GC.
Let us run FASTA test using estimated polygenic model, as specified by h2
object:
> mms <- mmscore(h2,data=erfs)
There is little residual inflation left when we use ”genomic kinship” matrix:
> lambda(mms)$est
[1] 1
> [Link](mms,sort="Pc1df")
If you compare these results to that obtained with simple GC, you can also
see that the ranks of top hits have changed quite a bit; unbiased estimated of
genetic effects were obtained.
However, we can not estimate genome-wide significance with FASTA, be-
cause the data structure is not exchangeble.
Using GRAMMAS method, you can estimate nominal P − values by
> grs <- qtscore(h2$pgres,data=erfs,clam=FALSE)
> lambda(grs)$est
[1] 0.8998862
In the above analysis, note that the estimated ”inflation” factor λ is less
than one, i.e. now it is the GRAMMAS deflation factor. In order to obtain
non-concervative test statistics, we had to say to qtscore that deflation is OK
(parameter clam=FALSE).
We can see ”top” nominal corrected P − values with
> [Link](grs,sort="Pc1df")
By comparing this output to that from FASTA test, you can see that P −
values are quite close, but the effects are underestimated with GRAMMAS, as
expected.
However, the streangths of GRAMMAS test is not only its speed, but also
possiblity to estimate genome-wide significance. This can be done by
|
| | 0%
|
|======================================================================| 100%
> [Link](grs.e,sort="Pc1df")
0.15
●
● ●
●
● ●
●
● ●
●
0.10
● ● ●● ●
●● ● ● ● ●
●● ●
● ● ●
●
●● ●●
gkins[[Link](gkins)]
●●
● ● ●● ●
●
● ●●● ●
● ●●
● ●
●● ●
● ●● ● ●● ● ●
●
● ●● ● ● ●●
● ●● ●● ● ● ● ● ●● ● ●● ● ●● ●● ●●
0.05
●●● ●● ● ●
● ● ● ● ● ● ● ● ●● ● ● ●●●● ● ●
●● ● ● ●●● ● ● ●
● ●● ●●●● ● ● ● ●●
●● ●
●●● ● ●●●●●●●● ●
● ●●●
●
●● ●●● ●● ●
●● ● ●
●● ●●●●●● ●● ●●●● ●●
● ●●●
●● ●
●●
●●● ●● ●
● ● ●●● ●
●
●● ●●
● ● ●●●●
● ●●
●
● ● ●●
●
●
●●●●●●
●
●
●
●
●●
●
● ●●●
●
● ● ●●●●●●●●
●● ●●● ● ● ● ●
● ●● ●● ●
●●● ● ● ●●● ●●●
● ●
●● ● ●● ● ●●●●●
●●
●●●●
● ●●●
●●●●
●●● ●● ●●
● ●
●●●●●● ●
●●●●●●●●●●
● ●●●
●● ●●●
● ●●
●●● ●●
●●●
●
●● ● ● ●
● ● ●●●● ●●
●●
●●●
●●
● ● ●
●●
●● ●●
●●●●
● ●
● ●
● ●
●
● ●●
●●●●●●● ●● ●● ●●●● ●
●
● ● ● ●●● ●
●●●●
●
●●
● ●●●
●
●
●
●●●●●●●●
●
●
●●●
●●●
●●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
● ● ●
●
●●
● ● ●
●●●
●
● ●
●
●
●
●
●
●
●●
●● ●●
●●
● ●
●● ●
●●●
●
●●
●●
●
●●●●
● ●● ●
● ● ●● ●●
●● ● ●● ●●●
●● ●● ●
●
●●●●
● ●
●●●●●
●
●●
●● ●
● ●●
●●●●
● ● ●●●● ●
● ● ● ● ●
●● ●
●
●●●●●●
● ● ●●●●●●●●●●●
● ●●
●● ●●●● ●
●●●
●
●●
●●
●●●
● ●
●●
●
●●
●●
●●●●●
●●●
●● ●
●●
● ●●●●
●●
●●● ●● ● ●
●●●●● ● ● ●
● ●●● ● ●●●●●●●
●●●
●●
●●●●●●●●
●●
●●●
●
●●
●
●
●●
●●●● ●
●●
●●
●●●
●
●●
●
●●
● ●
●
●●
●●●
●
●
●●●
●
● ●
●
●●
●
●●
●●
●●
●●●●
●
● ●●
●
●●●●
● ●●●●●
●●●
●● ●●●●
●●●● ● ●● ●
● ●●
● ●●
●● ●●● ●
●●●
●●
●●
●
●●
●
●
●
●
●
●●● ●
●●
●
●
●●●●
●●●
●
● ●
●
●●●
●
●
●●
●
●●
●
●
●
●●
●●●
●
●●
●●
●
●●
●●
●
●●
●
●
●●
●
●
●
●
●
●
●
●●
●●
●
●
●●●
●
●
●
●
●
●
●
●
● ●
●
●
●●●
●
●●●
●
●●●
●●●●● ●
●● ●●●●●
●● ●● ● ●●
●●● ● ● ●
●●●● ● ●● ● ● ●● ● ●● ● ● ●● ●
● ● ● ●● ●
0.00
● ●
● ●● ● ● ●● ● ●●
● ●●●
●
●●●●●●●
●
●●●●
●● ●
●●
● ●●
●●
●
●●
●
●●●●
●●
●
●
●
●●
●●●
●
●●
●
●●
●
●
●●
●●●●
●
●● ●
●●
●●
●●
●
●●
●●
●
●●●
●
●
●●
●
● ● ●
● ●
●●
● ●
●●
●●● ●
●●● ● ●
●
● ● ●●● ● ● ● ●● ●● ●●●● ●●●●●
●●●●● ●● ●●●●
● ● ●
● ●
●● ●●●●●
● ●
●●●●● ●
●●● ● ●
●● ● ●
●
●● ●●● ●
●●●
●● ● ●●
● ●
●●
●
●●
●●
●●
●●●
●●
●●
●
●●
●
●
●●
●
●●●
●
●●
●● ●
●●●
●
●●●
●
●●
●
●●
●
●●●
●
●●
●●
●
●●●
●
●●
●
●
●●
●
●●
●
●●
●●
●●
●●
●●
●
●●●
●●●
● ●
●
●●●●
●
●●
●●●
● ●●
●● ●●●● ●●●●● ● ● ●
●
●● ●
● ●●●
●
●●●●●●● ●●●●
●● ●●
●
●●●● ●●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
● ●
●
●
●
●
●
●
●
●●
●●
●
●
●
●●
●
●
●
●
●●
●
●●
●●
●
●
●
●
●
●
●
●
●
●●●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●●●
●
●
●
●
●●
●
●●
●●
●
●●
●●
●
●●
●
●●
●●
●
●
●●
●●● ●
●●●
●
●
●●
●
●
●●
●●
●
●
●●●
●
●●●● ●
●●●●●● ●●
●● ●
● ●
●
● ● ●●●●●
●
●
●●
●
●●
●
●●●
●
●
●
●
●
●●
●
●●●●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●●
●●
●●●
●
●
●●●
●●
●
●
●●●
●●
●
●
●●
●●
●
●
●
●
●● ●
●●● ●
●●
●●●
●●●
●● ●●
● ●
● ● ●● ●●●
●●●●
●●●●
●●
●
●●
●
●●
●●
●●
●●
●
●●
●●●
●
●
●●
●
●●
●
●
● ●
●
●●●
●
●●●
●
●
●●
●
●●
●●
●●●
●
●
●●
●●
●●●
●
●●
●●
●●●
●
●●
●
●
●●●
●●
●●
●
●●
●●
●
●●●
●
●●●
●
●
●
●●●●●●
●●●●●
●●
●●
● ●●●●
●
●●
● ● ●
● ●●
● ● ● ●
● ●● ● ● ●●
●
● ●●
●● ●●
●● ●●●●●
● ●
●
●●
●●●
●●●
●
●●●
●
●●
●
●
●●
●●●●
●
● ●
●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●●●
●●
●
●
●●
●●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●●
●●●
●
●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●
●●
●●
●
●●
●
●
●
●●
●
●
●
●●●
●
●
●●
●●
●●
●
●●
●
●●●
●
●
●● ●
●
●
●●
●
●
● ●
●
●
●
●●
●
●●
●●
●
●
●
●●
●
●●
●●●
● ●●
●●●
●
●●●● ● ●●
●
●● ●● ●●●●
●●● ● ● ● ●● ●●
● ●
●● ●●●●
●●●
●●●●●
●●●
●
●●
●●●●
●●
●●
●●
●
● ●
●●
●●
●●●●
●
●
●
●●
●●●●
●
●●
●●
●●
●●
●●
●
●
●●●
●● ● ●●●
●
●●●● ●●
● ●●●
●●●
●●
●● ●●●●
● ●
●
●
●●●●● ●
●●●●
●
●●●
●●
●●
●
●
●
●●
●
●●
●
●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●●●
●
●
●
●
●
●
●●
●
●
●
●
●
●●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●●●●
●●
●
●
●
●
●●● ●
●●●●●
●●●●
● ●
●
●● ●● ●●
● ●
●● ●
● ●●●●
●●
●
● ●
●●
●●●
●
● ●●
●●
●●●●
●
●● ●
●●
●●
●
●
● ●●
●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●
●●●
●●
●
●●
●●
●
●
●
●
●
●●●
●
●
●●●●
●
●●
●
●
●●
●●
●●●
●
●●
●●
●● ● ●
●●
●●
●
●● ●
●●●●
●● ●●● ●
●●● ●
●
● ●●●●●●
● ●●● ●● ●
●●
●●●● ●●
●●●
●● ●
●
●●
●
●●●
●●
● ●
●●●
●
● ●
● ●
●
●●●
●●●
●
●●
●●●●●●●●
●●●
●
●●●● ● ●●
●●●●●●● ●●●
● ● ● ●●● ● ● ●●
● ●●● ●●● ●●● ●● ● ●●●●●●
●● ●●
●●
●
●
●●
●
●●●●
●
●●
●●
●●
●
●
●●
●
●●●●
●●
●
●
● ●
●
●●●
●
●
●
●
●
●●
●
●
●
●●
● ●
●●●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●
●
●●
●
●
●
●●
●
●●
●● ●
●
●●●●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●●
● ●●
●●
●●●
●● ●● ●● ●
●
●●●●● ●
●
●
●●●
●● ●
● ● ● ●●●●●●
●
●●
●
●●●
●●● ●
●●●
●●●
●●
●●
●
●●●●
● ● ●
● ●●●
●
●●
● ●● ●● ●●●●●●● ●
●
●●● ●●●● ●●
● ●● ●● ●●●● ●● ●● ●● ●
●●●● ●
●●● ●●● ●●● ●● ●●●●
−0.05
● ●● ● ● ●● ●● ● ● ● ● ●●●
● ● ● ● ●● ●●
● ●● ● ●●●● ● ●
●●●● ● ●●
● ●●●● ● ●●
●● ● ●●
● ● ● ● ●
● ● ● ● ● ● ●● ●●●
● ● ●
● ● ● ● ● ●
● ●
● ● ● ●●
● ●●●
● ● ● ●●● ● ●
● ●● ●
● ●●
● ● ●● ●● ●
● ●
●
●●
●
pkins[[Link](pkins)]
Figure 7.5: Scatter-plot relating pedigree and genomic kinships for erfs data
set.
As you can see, now the ”top” hit starts approaching genome-wide signif-
icance (genome-wide P − value ∼ 10%), showing the power of kinship-based
methods under high heritability model.
Finally, let us plot −log10 nominal P − values from different methods across
the genome. Let black dots correspond to GC, green to GRAMMAS and red to
FASTA (figure 7.6):
> plot(mms,df="Pc1df")
> [Link](grs,df="Pc1df",col=c("lightgreen","lightblue"),cex=1.2)
> [Link](qts)
You can see that there is a great degree of correlation between the FASTA
and GRAMMAS P − values, while plain GC really stands apart.
186CHAPTER 7. GWA IN PRESENCE OF GENETIC STRATIFICATION: PRACTICE
In the next section, you will explore a small (695 people) subset of people
from ERF, a family-based study with participants coming from a genetically
isolated population and sampled based on kinship (all living descendants of 22
couples living in the area in mid-XIXth century). The study participants were
genotyped using Illumina 6K ”linkage” array. QC was already performed. Your
trait of interest is ”qtbas”.
Explore the data set and answer the questions:
Exercise 2 Describe the trait ”qt”. Can you detect significant outliers at visual
inspection? Is trait distributed normally? What are significant covariates?
Exercise 3 Explore relations between genomic and pedigree kinship (these are
provided in data as gkin and pkin data objects, respectively). What are your
conclusions? Which matrix would you use later on?
Exercise 4 What is the heritability of the trait (take care: polygenic analysis
may rung for a long while)? Based on heritability analysis, how would you rank
different methods of GWA analysis for this trait (and why)?
Exercise 5 Do GWA analysis using simple score test with genomic control.
Estimate genome-wide significance. What are your conclusions?
Run GWA analysis using the ”best” method and model as you have decided
in previous exercises. Estimate genome-wide significance. What are your con-
clusions? Did they change compared to simple analysis?
Exercise 6 Repeat the last ”best” analysis using pedigree kinship. How your
results change?
Exercise 7 If you have any time left – repeat analysis using ”qt” trait. This
one is much more fun, but also more laborous to analyse.
Residuals:
Min 1Q Median 3Q Max
-21.3585 -4.9637 0.0959 4.7896 22.4212
Coefficients:
7.5. ANSWERS TO EXERCISES 187
Deviance Residuals:
Min 1Q Median 3Q Max
-1.3318 -1.1169 -0.8151 1.1907 1.5775
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -3.1234742 0.9295943 -3.360 0.000779 ***
sex 0.4913847 0.1424384 3.450 0.000561 ***
age 0.0976423 0.0373181 2.616 0.008884 **
age2 -0.0007977 0.0003623 -2.202 0.027697 *
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Answer (Ex. 2) — How many SNPs and IDs are presented in the data set?
> nsnps(strdat)
[1] 7374
> nids(strdat)
[1] 822
no X/Y/mtDNA-errors to fix
RUN 1
7374 markers and 822 people in total
0 (0%) markers excluded as having low (<0.3041363%) minor allele frequency
32 (0.4339571%) markers excluded because of low (<98%) call rate
0 (0%) markers excluded because they are out of HWE (P <0)
0 (0%) people excluded because of low (<98%) call rate
Mean autosomal HET is 0.2564845 (s.e. 0.01498989)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7899338 (s.e. 0.01170803), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 7342 (99.56604%) markers passed all criteria
In total, 822 (100%) people passed all criteria
RUN 2
7342 markers and 822 people in total
0 (0%) markers excluded as having low (<0.3041363%) minor allele frequency
0 (0%) markers excluded because of low (<98%) call rate
0 (0%) markers excluded because they are out of HWE (P <0)
0 (0%) people excluded because of low (<98%) call rate
Mean autosomal HET is 0.2564845 (s.e. 0.01498989)
0 people excluded because too high autosomal heterozygosity (FDR <1%)
Mean IBS is 0.7888525 (s.e. 0.01175626), as based on 2000 autosomal markers
0 (0%) people excluded because of too high IBS (>=0.95)
In total, 7342 (100%) markers passed all criteria
In total, 822 (100%) people passed all criteria
> strdat1 <- strdat[qc$idok,qc$snpok]
The number of IDs and SNPs passing are
> nsnps(strdat1)
[1] 7342
> nids(strdat1)
7.5. ANSWERS TO EXERCISES 189
[1] 822
$se
[1] 0.005757743
$se
[1] 0.0011015
mmscore(h2, erfs)
− log10(P − value)
●
4
●
● ●
● ●
●
● ●
●●
3
● ● ● ●
● ● ●● ● ●
● ● ● ●● ● ● ●●● ● ● ●
●
● ●● ● ●● ●● ●
● ● ● ● ●● ●● ● ●● ●● ● ● ●
2
● ●● ● ●● ●● ●● ● ●●●● ●● ●
●● ● ●●●●
● ●● ●● ●●● ● ● ●●●●●● ●●● ●● ●● ●● ● ●● ● ●●● ●● ● ●●
●●●● ●●●● ● ●● ●●●
●
● ●●●
●
●● ●● ●●● ●●●●● ●
●●●●●●● ●● ● ●
● ●●● ●●●● ● ●●● ●●●
●
● ● ● ●● ●●●● ●● ●● ●●● ● ●
●
●
●●
● ●●
●●
●
●
●
●
● ●●●
●
●
●
●
● ●●
●● ● ●●●
● ●●
●
●
●
●●
●
●●●●●
●
●
●●●
● ●●● ●
●●
●●●●
●●
●
●
●
●●
●
● ●
●
●
●
●
●
●
● ● ●
●●●
●
●●
●●●●
●●●●●
●● ●
●
●
●
●●●
●
●
●
●●
●●
●
●
●
●
●
●
●
●● ●● ●● ●
● ●
●●●●● ●●● ●●
●
●●●
●
●
●
●● ●
●
●●●●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●●●●●●●
●
●●
●
●●
●●●
●●●●
●●●●●●●
●●
●● ●●●●
●●
●
●
●
● ●●
● ● ● ●●● ● ●●
●●●
●●
● ●●●
● ●●●●●●● ●●●
● ●
●●●●●●
● ●
●●●● ● ●●●●
●● ●
●●●● ●●●●
●●●
●●●
● ●● ●● ●
●● ●●●
●● ●●
● ●●●
● ● ●
●● ●● ●
●●●
● ● ● ●● ● ●● ●● ●●
1
●
●
●●
●
●
●
●
●●●
●●●
●
●
●●
●●●
● ●
●●
●●
●
●●●●●
●
●●
●
●●
●
●●
●●●
●● ●
●●●●
●●
●
●●
●
●●●●
● ●
●
●●●
● ●
●●
● ●
●●
●●●●
●●
●●●
●
●
●
●●
●●
●●
● ●
● ●
●
●●
●●
●●
●
● ●
●●
●
●●
●●
● ●
●
● ●
●
● ●
●●
● ●
●●
●●●
●
●●
●
●●
●●
●●●
●●●●●●
●
●●●
●●
●
●●●
●●
●
●●
●●●●
●●
●
●●●
● ●
●●●
●●
●●
● ●●
●
●●
●
●●
●●
●●
●●
●● ●●●●
● ●
●
●
●
●●●●
●●
●
●●
●●
●●
●
●● ●
●●●
● ●
● ●
●●
●
●●
● ●
● ●●
●●
●●
●●
●
●●●●
●●
●
●●
●●
●●
●●
●
●●●●
●
●
●●
●
●
●●
●●
●●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●●●●●
●●
●
●
●●
●●●
●
●●
●●
●●
● ●
●●
●●●
●
● ●
●
●
●●●●●
●
●
●
●●●●
●
●
●●
●
●●
●●
●
●●
●
●
●●
●●
●●
●
●●●
●●
●●
●●
●
●
● ●● ●
●●
●
●●●
●
● ●
●●
●
●
●
● ●
●
●●
●●
●
●
●●●●
●
●●
●
●●●
●
●●
● ●
●
●●●●
●●
●●
●
●●●
●
●
●●
●●
●●●
●
●
●●
●
●●
●
●●
●
●●
●●
●●
●
●●
●●
●●
●●
●
●●●
●
●●
●
●●
●
●
● ●
●
●●
●●
●
●●
●●●●●
●●
●●●●
●
●
●
●●
●●
●●
●●●●
●●
●
●
●●●
●●
●
●●
●
●●
●●
●●
●●●●
● ●●●
●
●
●●
●●
●
●●
●●
●
●●●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●
●●
●
●
●●●
●
●●
●●
●
●●
●●●
●
●●
●●
●●
●●
●
●
●
●●●
●●
●●
●
●●
●●
●
●
●
●●
●●●
●
●
●
●
● ●
●
●●
●
●
●●
●●
●
●
●●
●
●●
●●●
●
●
●●
●
●●
●
●
●
●●
●●
●●
● ●
●
●●
● ●●
●●
●
●
●●
●●
●
●
●●
●
●●●
●
●●
●
●
●●●
●
●
●●
●●
●
●
●●
●
●●
●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●
●●
●
●
●
● ●
● ●
●●
●
●●
●
●●
●
●
●
●●
●
●
●●
●●
●
●
●
●
●●
●●●
●●
●
●●
●
●●
●
●
●●
●●
●
●
●●
●●
●●
●
●●
●
●●
●●
●●
●
●●
●
●●
●●
●
●●
●●
●
●●
●●
●●●
●
●
● ●
●
●●
●●
●
●●
●
●
●●●
●
●●
●
●●
●●
●
● ●
●●
●
●●
●
●●
●
●●
●●
●●●●●
●
●●
●●
●●
●
●
●
●●
●●
●
●●
●●
●
●●●
●
●●
●
● ●
●
●
●
●●
●●
●
●●
●●
●
●
●●●● ●
●●
●
●
●●
●
●●
●
●
●
●●
●●
●
●●●●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●●
●
●●
●
●
●
●●
●
●
●●
●
●●
●●
●●
●●
●●
●
●
●●
●●
●●
●●
●
●●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●●
●
●
●
●●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●●
●●
●
●
●●
●
●
●●
●●●●
●
●
●●
●
●●
●●
●●
●
●
●●
●
●●
●
●
●●
●●●
●
●
●●
●
●●
●
●●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●●
● ●
●
●
●
●●
●
●
●●
●
●
●●
●●
●
●●
●●
●
●
●●
●
●●
●
●●
●●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●
●
●●
●●
●
●●
●
●●
●
●●
●
●●●
●
●
●●
●
●
●●
●●
●
●
●●
●●
●
●
●
●●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●●
●●
●
●●
●
●●
●
●
●
●●
● ●
●
●
●
●●
●
●●●
●
●
●
●●
●
●
●●
●
●
●
●●●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●●
●
●●
●
●
●●
●
●
●
●
●●●
●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●●
●
●
●
●●
●● ●
●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●●
●
●●
●
●
●
●●
●●
●
●●
●
●
●●
●
●
●
●●
●●
●
●
●
●●
●
●
●●
●●
●
●
●●
●
●
●●
●
●●
●
●
●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●●
●●
●
●●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●●
●●
●
●
●
●●
●
●●
●
●●
●
●
●
●
●●
●●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●
●
●●
●
●
●●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●●
●
● ●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●
●
●●
●
●●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●●
●
●●
●●
●
●
●
●
●
●●
●
●
●●
●●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
● ●
●
●
●
●
●●●
●
●
●
●●
●
●
●●
●●
●
●
●
●●
●●●
●
●
●
●
●●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●●●
●
●
●
●●
●
●●
●
●
●● ●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●
●
● ●
●●
●
●
●
●●
●
●
●●
●
●●●
●●●●●
●●
●
●●● ●●●
●
●●●
●
●●●
●●●
●●
●●
●
●●
● ●
● ●●●●
●●
●●●●
●●
●●●●
●●● ●
●● ●
●●● ●● ●
●
●●
● ●
●●●
●●
●● ●
●●●
● ●
● ●
●
●●●●
●● ● ●
●●●
●
●●●●
●●
●●●
●●●
●●●
●
● ●●
●●●
●●
● ●
●●
●●●
●
● ●
●
●●●●
●
● ●●
● ●
●
●●
●●
●
●●
●
●●●
● ●●●
●●
●●
●●
●●
●●●
● ●
●● ●●
●●
●
●●
●●
●●●●● ●
●●
●●
●●
●●
●●
●●●●
●
●●
●
0
1 2 3 X
Chromosome
●
0 1 2 3 4
● ●
● ●
● ●
● ● ●
● ● ● ●
● ●● ● ● ●
● ● ●● ● ●
● ● ● ●● ●● ● ● ● ●●
● ●●● ● ●● ●● ●● ● ●●● ● ● ●●●●
● ● ●●●● ●●● ● ● ●● ●
●
● ●● ●● ● ● ●●●●●●● ● ●● ●●● ●● ●●● ● ● ●● ●● ● ● ●● ●●● ●
●
●●
●●
●●●●
●● ●
●
●● ● ●●
●
● ●●
●
●●
●
●
●●●
●
●
●
●●●
● ●●
● ●●●
● ●
●● ● ●
●●●
●●●
●
●●●
● ●●●●
●
● ●●●
●● ●
●
●●
●
●
●
●
●●
●
●
●
●● ●●
● ●●
●●●● ●●●●●●●●●●
● ●●●
● ●●●●●
●
● ●●
● ●●
●●
●●
●
●
●●
● ●●
●
●
●
●
●
●● ●●
●
●
●●
● ●
●●●
●
●●
●●
●
●●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
● ●●
●●
●
●
●
●
●
●
●
●●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●●
●
●
●
●
●
●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●●
●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●●●
●
●
●
●
●
●
●
●
●
● ●
●
●●
●●●
●
●
●●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●●
●●
●
●●
●
●●●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●
●
●●
●
●●
●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●
●
●●●●
●
●●
●●●
●
●●
●
●
●
●●●●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
● ●
●●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●●
●
●●
●●
●
●●
●●
●
●
●●
●
●●
●
●
●
●●
●
●●
●●
●
●
●●
●●
●
●
●
●
●●
●
●●
●●
●
●●
●
●
●
●●
●
●●●
●
●
●
●●
●
●
●●
●
●●
●●
●●●
●
●●●
●
●●
●
●●
●
●●
●
●●
●●●
●
●
●
●●
●
●●●
●
●
●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●●●●●
●
●
●●
●●
● ●
●
●●
●
●●
● ●
●
●●
●
● ●
●●
●●
●●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●
●●●
●
●●●
●
●●
●●
●
●
●
●●
●
●
●●
●●
●
●
●●
●
●●
●●
●●
●
●●
●
●
●●
●
●●
●
●●●
●
●●
●
●
●●
●
●●
● ●
●
●●
●●
●
●●
●●
●●
●
●
●
●●
●●
●
●●
●
●●
●●
●●
●●
●
●●
●●
●
●
●●
●
●●
●
●
●●
●●●
●
●●● ●
●
●
●●
●
●
●●
●●
●
●●
●
●●
●
●
●●
●
●●
●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●
●●
●
●●●
●
●
●
●●
●●
●
●
●
●●
●●
●
●●
●●
●●
●●
●●
●●
●●
●
●
●●●
●●
●
●
●
●
●●
●●
●
●
●●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●●
●
●
●
●
●●
●
●●
●
● ●
●
●
●●●
●
●●
●
●●
●
●
●
●
●●
●
●●
●
●
●●●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●●
●
●●
●
●●●
●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
● ●
●
●●
●●
●
●
●
●
●●
●
●
●
●●
●●
●
●
●
●●
●
●
●
●●
● ●
●
●●
●
●
●●
●
●
●●
●
●●●
●
●
●●
●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●●
●
●
●
●●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●●
●
● ●
●
●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●●
●
●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●
●●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
● ●
●
●
●
●●
●
●●●
●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●●
●
●
●●
●
●
●●
●
●
●●
●●
●
●●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
● ●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●●
●
●
●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●● ●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●●
●●
●
●●
●●
●
●
●●
●
●●
●
●●
●●
●
●●
●
●●
●
●
●●
●●
●
●●
●●
●
●●●
●
●●
●
●●
●
●●
●●
●
●
●●
●●
● ●
●
●●
●●
●●
●●
●●
●●
●
●●
●●
●
●
●●
●
●●
●●
●
●
●
●●
●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●
●●
●●
●
●●
● ●
●●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●
●●
●●
●
●
●●
●
●●
●
●●
●
●●
●●
●
●
●●
●
●●
●
●●
●
●●
●
●● ●
●
●
●
●●
●
●●
●
●
●
●●
●●
●
●●
●
●●
●
●●
●
●
1 2 3 X
Chromosome
qtscore(qtbas, erfs)
− log10(P − value)
●
4
●
● ●●
● ● ● ●
● ●
3
●
● ● ● ● ●● ●
●● ●● ● ●● ●
● ●
● ●● ● ●● ● ●●● ● ● ●● ●
●● ●● ● ● ● ●● ●
● ●●
●● ● ●●
2
●
●● ● ●●● ●●●
●●●
● ●●
●
● ●
●●
● ●●
●● ● ● ●
●●● ●
●●
● ●● ●●
● ●●●● ● ●
● ●● ●●●
● ●●●● ●
●
● ● ● ●●
●●●
●● ●● ● ●
●● ●● ● ●●
● ●● ● ●
●● ●
● ●●●●●
●●●●●● ●
● ●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●●
●
●
●
● ●
●
●
●
●
●●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●●
●●
●
●
●
●
●
●
●
●●
●●
●
●
●● ●
●
●
●
●
●
●
●●
●
●
●
●
●
●● ●
●
●●
●
●
●●
●
●●
●
●●●●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●
●●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●●
●
●
● ●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●●
●
●
●●
●●
●
●
●●
●●
●
●●
●●
●
●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●●
●●●
●
●
●●
●
●
●
●
●●●
●●
●●●
●●
●
●●
●
●
●●
●
●●
●●
●●●
●
●●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●●
●
●●
●
●
●
●●
●
●●
●●
●
●●
●
●
●●
●
●●
●●
●
●
●●
●●
●
●
●●
●
●●
●●
●●
●●
●●
●
●●
●
●●
●
●
●●
●●
●
●●
●
●
●●
●●
●●
●
●●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
● ●
●● ●●
●
●
●
●●
●
●●
●
●
●
●●
●●
● ●
●
●●
●
●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●● ●●
●●
●
●●
●
●
●●
●
●●
●●
●
●●
●
●●
●●
●
●
●●
●●
●
●
●
●●
●●
●
●
●●
●
●●
●●
●●
●●
●●
●
●●
●●●
●
●
●
●● ●
●
●●●
●●
●
●
●●
●●●
●
●
●●
●
●●
●●
●●
●
●●
●
●
●
●●
●●
●
●
●
●
●●
●
●●
●●●
●●
●
●●
●●
●●
●
●●
●
●
●●
●●
●
●
●
●●
●
●
●●
●
●●
●
●●
● ●
●
●●
●●
●
●●●
●
●●
●
●
●
●
●●
●
●●
●
●●
●
●●
●
●●
●
●
●
●●
●
●
●●●
●
●
●
●●
●●
●●
●
●●
●●
●
●●
●
●
●●
●
●●
●
●●
●
●
●
●●
●
●●●
●
●
●
●●
●●
●
●
●●
●●
●
●
●●
●
●●
●
●●
●●
●●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●●
●●
●
●●
●
●
●
●●
●
●
●
●●
●●
●
●
●●
●
●●
●
●●
●●
●
●●
●
●
●
●●
●●
●
●●
●
●●●
●●
●
●●
●
●●
●
●
●
●●●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
● ●
●●
●
●
●
●●
●
●●
●●
●
●●
●
●●
●●
●
●
●
●●
●
●
●●●
●
●
●
●
●●
●
●●
●●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●●
●●
●
●●
●●
●●
●●
●
●●
●
●
●
●●
●●
●●
●
●
●●
●●
●
●●
●
●
●●●
●
●●
●
●●
●
●●
●●
●
●
●
●
●●
●●
●
●
●
●●
●
●●
●
●●
●
●● ●
●
●
●●
●●
●
●
●
●●
●●
●
●
●●
●●
●
●●
●
●
●
●●
●●
●●
●
●
●●
●●●
●
●●
●
●
●●
●
●
●●●
●
●
●
●
●●
●●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
● ●
●
●●
●
●
●●
●
●
●●
●
●●
●●
●
●
●●
●
●
●●
●●
●
●
●
●●
●
●●
●
●
●
●
●●
●
●
●●●
●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●●●
●●
●
●
●●
●
●●
●
●
●
●
●
●●
●
●●
●
●
●
●
●●
●●
●
●
●●
●
●
●●
●
●●
●
●
●●
●●
●
●
●
●
●●
●
●●
●
●●
●
●●
●
●
●
●
●●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●●
●●
●●
●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●
●●
●
●●
●
●●
●
●
●●
●
●
●
●●
●
●
●
●● ●
●●
●
●
●●
●
●
●●
●●
●
●
●●●
●
●
●●
●
●●
●
●●●
●
●
●●●
●●
●●
●
●
●
●●
●●
●
●
●●●
●
●
●●
●
●
●
●●
●
●
●
●●●
●
●
●
●●●
●
●
●●
●●
●
●●
●
●●
● ●
●
●
●●●
●
●
●
●●
●
●
●
●●
●●
●
●●●●
●
●●●●
●
●
●●
●●
●
●
●
●●
● ●
●
●
●
●●
●
●
●
●●●
●●
●●
●●
●
●
●
●●●
●
●●●
●
●
●●
● ●
●
●
●
●
●●
●●
●
●
●
●●
●●
●
●
●●
● ●●
●
●
●●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●●
●
●●
● ●●
●●●
●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●●
●
● ●
●
●●
●
●
●●
●
●
●
●●
●●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●
●
●
●●
●
●
●
●
●
●●
●
●
●
0
1 2 3 X
Chromosome
$estimate
[1] 168.305955085 12.169348264 -0.042230533 -0.001535005 0.100481616
[6] 51.749954932
$gradient
[1] 0.018562837 0.441838116 0.225665709 5.919720007 0.009112349 0.090638959
$code
[1] 4
$iterations
[1] 100
> mm <- mmscore(h2an,strdat1)
> lambda(mm)$est
[1] 1.120987
Answer (Ex. 10) — The best results are achieved with mmscore:
> summary(mm)
Summary for top 10 results, sorted by P1df
Chromosome Position Strand A1 A2 N effB se_effB chi2.1df
192CHAPTER 7. GWA IN PRESENCE OF GENETIC STRATIFICATION: PRACTICE
8.1 Motivation
Many statistical and experimental techniques, such as imputations and high-
throughput sequencing, generate data which are informative for genome-wide
association analysis and are probabilistic in the nature.
When we work with directly genotyped markers using such techniques as
SNP or microsatellite typing, we would normally know the genotype of a par-
ticular person at a particular locus with very high degree of confidence, and, in
case of biallelic marker, can state whether genotype is AA, AB or BB.
On the contrary, when dealing with imputed or high-throughput sequencing
data, for many of the genomic loci we are quite uncertain about the genotypic
status of the person. Instead of dealing with known genotypes we work with
a probability distribution that is based on observed information, and we have
estimates that true underlying genotype is either AA, AB or BB. The degree
of confidence about the real status is measured with the probability distribution
{P (AA), P (AB), P (BB)}.
Several techniques may be applied to analyse such data. The most sim-
plistic approach would be to pick up the genotype with highest probability,
i.e. maxg [P (g = AA), P (g = AB), P (g = BB)] and then analyse the data as
if directly typed markers were used. The disadvantage of this approach is that
it does not take into account the probability distribution – i.e. the uncertainty
about the true genotypic status. Such analysis is statistically wrong: the esti-
mates of association parameters (regression coefficients, odds or hazard ratios,
etc.) are biased, and the bias becomes more pronounced with greater probability
distribution uncertainty (entropy).
One of the solutions that generate unbiased estimates of association param-
eters and takes the probability distribution into account is achieved by perform-
1 The ProbABEL-package manual can be found at [Link]
193
194 CHAPTER 8. IMPERFECT KNOWLEDGE ABOUT GENOTYPES
An example of the few first lines of an MLDOSE file for five SNPs described
in SNP information file follows here (also to be found in the file ProbABEL/examples/[Link])
The order of SNPs in the SNP information file and DOSE-file must
be the same. This should be the case if you just used MACH outputs.
Therefore, by all means, the number of columns in the genomic predictor file
must be the same as the number of lines in the SNP information file plus one.
The dose/probability file may be supplied in filevector format (.fvi and
.fvd files) in which case ProbABEL will operate much faster, and in low-RAM
mode (approx. 128 MB). On the command line simply specify the .fvi file as
argument for the --dose option (cf. section 8.3 for more information on the
options accepted by ProbABEL). See the R libraries GenABEL and DatABEL
on how to convert MACH and IMPUTE files to filevector format (functions:
mach2databel() and impute2databel(), respectively).
the Cox proportional hazards model analysis follow here (also to be found in
ProbABEL/examples/coxph [Link])
You can see that for the first ten people, the event occurs for three of them,
while for the other seven there is no event during the follow-up time, as indicated
by the “chd” column. Follow-up time is specified in the preceding column. The
covariates included into the model are age (presumably at baseline), sex and
“othercov”; thus the model, in terms of R/survival is
Surv(fuptime chd, chd) ∼ sex + age + othercov.
Options:
--pheno : phenotype file name
--info : information (e.g. MLINFO) file name
--dose : predictor (e.g. MLDOSE/MLPROB) file name
--map : [optional] map file name
--nids : [optional] number of people to analyse
--chrom : [optional] chromosome (to be passed to output)
--out : [optional] output file name (default is [Link])
--skipd : [optional] how many columns to skip in predictor
(dose/prob) file (default 2)
--ntraits : [optional] how many traits are analysed (default 1)
--ngpreds : [optional] how many predictor columns per marker
(default 1 = MLDOSE; else use 2 for MLPROB)
--separat : [optional] character to separate fields (default is space)
--score : use score test
--no-head : do not report header line
--allcov : report estimates for all covariates (large outputs!)
8.3. RUNNING AN ANALYSIS 197
Please have a look at the shell script files example [Link], example [Link]
and example [Link] to have a better overview of the analysis options.
To run an analysis with MLPROB files, you need specify the MLPROB file
with the -d option and also specify that there are two genetic predictors per
SNP, e.g. you can run linear model with
The option --robust allows you to compute so-called “robust” (a.k.a. “sand-
wich”, a.k.a. Hubert-White) standard errors (cf. section 8.7 “Methodology” for
details).
With the option --mmscore a score test for association between a trait and
genetic polymorphisms in samples of related individuals is performed. A file with
the inverse of the variance-covarince matrix goes as input parameter with that
option, e.g. --mmscore <filename>. The file has to contain the first column
with id names exactly like in phenotype file, BUT OMITTING people with
no measured phenotype. The rest is a matrix. The phenotype file in case of
using the --mmscore argument may contain any amount of covariates (this is
different from previous versions). The first column contains id names, the second
the trait. The others are covariates.
An example of how a polygenic object estimated by GenABEL-package can
be used with ProbABEL is provided in ProbABEL/examples/mmscore.R
Though technically --mmscore allows for inclusion of multiple covariates,
these should be kept to minimum as this is a score test. We suggest that any
covariates explaining an essential proportion of variance should be fit as part of
GenABEL-package’s polygenic procedure.
In contrast, starting with the next column, named n, the output concerns the
data analysed. Column 8 (n) tells the number of subjects for whom complete
phenotypic information was available. At this point, unless you have complete
measurements on all subjects, you should feel alarmed if the number here is
exactly the number of people in the file – this may indicate you did not code
missing values according to ProbABEL-package format (’NA’, ’NaN’, or ’N’).
The next column, nine (“Mean predictor allele”), gives the estimated fre-
quency of the predictor allele (A1) in subjects with complete phenotypic data.
If the --chrom option was used, in the next column you will find the value
specified by this option. If --map option was used, in the subsequent column
you will find map location taken from the map-file. The subsequent columns
provide coefficients of regression of the phenotype onto genotype, corresponding
standard errors, and Wald χ2 test value.
8.7 Methodology
8.7.1 Analysis of population-based data
Linear regression assuming normal distribution
Standard linear regression theory is used to estimate coefficients of regression
and their standard errors. We assume a linear model with expectation
E[Y] = X β (8.1)
200 CHAPTER 8. IMPERFECT KNOWLEDGE ABOUT GENOTYPES
V = σ 2 I,
For the j-the element β̂(j) of the vector of estimates the standard error
under the alternative hypothesis is given by the square root of the corresponding
diagonal element of the above matrix, varβ̂ (jj), and the Wald test can be
computed with
β̂(j)2
T 2 (j) = ,
varβ̂ (jj)
which asymptotically follows the χ2 distribution with one degree of freedom
under the null hypothesis.
When testing significance for more than one parameter simultaneously, sev-
eral alternatives are available. Let us first partition the vector of parameters
into two components, β = (βg , βx ), and our interest is testing the parameters
contained in βg (SNP effects), while βx (e.g. effects of sex, age, etc.) are consid-
ered nuisance parameters. Let us define the vector of the parameters of interest
which are fixed to certain values under the null hypothesis as βg,0 .
Firstly, the likelihood ratio test can be obtained with
LRT = 2 logLik(β̂g , β̂x ) − logLik(βg,0 , β̂x ) ,
where var−1
β̂
(a, b) correspond to sub-matrices of the inverse of the variance-
covariance matrix of β̂, involving either only parameters of interest (g, g), nui-
sance parameters (x, x) or combination of these (x, g), (g, x).
The Wald test statistics is then computed as
Logistic regression
For logistic regression, the procedure to obtain parameters estimates, their
variance-covariance matrix, and tests are similar to these outlined above with
several modifications.
The expectation of the binary trait is defined as the expected probability of
the event as defined by the logistic function
1
E[Y] = π = .
1 + e−(Xβ)
The estimates of the parameters are obtained not in one step, as is the case of
the linear model, but using an iterative procedure (iteratively re-weighted least
squares). This procedure is not described here for the sake of brevity.
The log-likelihood of the data is computed using the binomial probability
formula:
logLik(β) = YT loge π + (1 − Y)T loge (1 − π),
where loge π is a vector obtained by taking the natural logarithm of every value
contained in the vector π.
where 1 is the vector of ones and W is the diagonal matrix of ”weights” used
in logistic regression.
202 CHAPTER 8. IMPERFECT KNOWLEDGE ABOUT GENOTYPES
where Vσ−12 ,h2 is the inverse and |Vσ 2 ,h2 | is the determinant of the variance-
covariance matrix.
At the second step, the unbiased estimates of the fixed effects of the terms
involving SNP are obtained with
where Vσ̂−1
2 ,ĥ2
is the variance-covariance matrix at the point of the MLE esti-
mates of ĥ2x and σ̂x2 and Rβ̂x = Y− β̂x Xx is the vector of residuals obtained from
the base regression model. Under the null model, the inverse variance-covariance
matrix of the parameter’s estimates is defined as
Thus the score test for joint significance of the terms involving SNP can be
obtained with
T 2 = (β̂g − βg,0 )T var−1
β̂
(β̂g − βg,0 ),
g
where βg,0 are the values of parameters fixed under the null model. This test
statistics under the null hypothesis asymptotically follows the χ2 distribution
with the number of degrees of freedom equal to the number of parameters tested.
The significance of an individual j-the elements of the vector β̂g can be tested
with
Tj2 = β̂g2 (j) varβ̂−1 (jj),
g
where β̂g2 (j) is the square of the j-th element of the vector of estimates β̂g ,
and var−1
β̂
(jj) corresponds to the j-th diagonal element of varβ̂−1 . The latter
g g
where L is the number of loci, pl is the allelic frequency at l-th locus and
gl,j is the genotype of j-th person at the l-th locus, coded as 0, 1/2, and 1,
corresponding to the homozygous, heterozygous, and other type of homozygous
genotype. The frequency is computed for the allele which, when homozygous,
corresponds to the genotype coded as “1”.
[Link]
If you have used the Cox proportional hazard model, please mention the
R package survival by Thomas Lumley. Additionally to the above citation,
please tell that
The Cox proportional hazards model implemented in ProbABEL-package
makes use of the source code of the R package ”survival” as imple-
mented by T. Lumley.
Chapter 9
In this chapter, you will perform an analysis of imputed data set. In this set of
120 individuals, 4500 SNPs are imputed based on information on 500 directly
typed SNPs. You will first analyse 500 directly typed SNPs and then proceed
to the analysis of imputed data. Finally, you will have a possibility to compare
your results to the results of analysis in case all 5000 SNPs were directly typed.
Here, df500 contains the data including 500 directly typed SNPs, and rcT
is the vector containing the value of the trait of interest:
> nids(df500)
[1] 120
> nsnps(df500)
[1] 500
> length(rcT)
[1] 120
> rcT[1:10]
205
206 CHAPTER 9. ANALYSIS OF IMPUTED DATA: AN EXAMPLE
In all analysis that follow, do disregard the Genomic Control and GC-
corrected results: as we will analyse a small region with strong association,
the GC can not be applied.
Let us start with analysis of directly typed SNPs. For that, we will use
mlreg function of GenABEL-package. This function implements ML-regression
and Wald test of significance1 . This will later on allow us direct comparison with
the results of ProbABEL-package, which implements the same testing procedure.
We can run regression of rcT on SNPs region-wise using
The summary for the SNPs, which show most significant association can be
produced with
> bestHits500
mlreg(rcT 1, df500)
14
●
12
●
10
− log10(P − value)
●
6
●
● ●
●
● ●
●●●
4
● ● ●
● ●
● ●● ●
● ●
● ● ● ● ● ●
● ● ● ●
● ●
● ● ● ● ●
● ●
●
● ● ●● ●● ●● ● ●● ● ●
●
●●
2
● ●● ● ● ● ● ●● ●● ●●● ● ● ●
●●
●
● ● ●
●
●● ● ●● ● ●● ● ● ● ● ● ●
●
● ●● ● ●● ●● ● ● ●
●●● ●
●
● ● ●● ● ● ●●●●● ● ● ● ●● ● ●● ● ●● ● ● ● ● ●●
● ● ● ● ● ● ● ● ●● ● ● ● ●● ●
● ● ●● ●● ● ● ●●
● ● ●
● ●
●
●●●●
● ●●●●●
●●
● ●●●
● ●●
● ●
● ●
● ●● ● ● ●●
●●
●
●●●
● ●
●
●● ●
●
● ●●● ● ●●
● ●● ● ●●● ●●●
● ● ●
● ●●● ●●● ●
●●● ● ● ●
●●● ●● ●● ●●● ● ● ● ● ● ●●
●●
●●
●
●● ●●●
●● ●
●●● ●
●
●
●●
●●
●●●● ●● ● ●
●●●
● ●●●●
●●
●
●● ● ●●
●●●●●●
● ●●●
●
● ●
●●
● ● ●●●●●
●●
●●
●●
●● ● ●● ● ●
●●
● ●●
●
●
0
Map position
> plot(qts500)
> abline(h=-log10(5e-8))
Exercise 1.
It is known that rare variation in the presence of outliers can generate spurious
associations. Do you believe this is a true association in this particular case?
What you can do to check whether this is a true association or not?
next, try the command ’system("head [Link]")’ to check the few first lines
of the file.
At this moment, leave R (or, rather, start new console!), copy the mach-files
to the working directory with
yourname@server> cp RData/mach1* .
Do not forget to check that you start the analysis in right directory, i.e. all files
([Link], [Link], [Link], [Link]) are present
in the working directory (use the ’ls’ command from the console).
Now, you can return to R and load the analysis results:
> qtsPal[order(qtsPal$Chisq,decreasing=T)[1:20],]
> plot(map5k,-log10(qtsPal[,"P-value"]))
> abline(h=-log10(5e-8))
> points(map(qts500),-log10(qts500[,"P1df"]),col="red",pch=19,cex=0.5)
14
●
●
●
●
●
12
●
● ●
●
● ●
●
●
● ●
−log10(qtsPal[, "P−value"])
10
●
8
●
●
●
●
●● ● ●
●
●
● ●
● ●
●
● ●
6
●●●
● ●● ●
●
● ●●
● ●
●
●
●●
● ●
●● ●
● ● ●
●
● ●
●
●
●
●
●● ●
● ●● ●● ●●
●
● ●● ● ●
● ● ●●● ●● ●
● ● ●●
● ●
●
●● ●●●
●● ● ● ● ●
● ● ●●● ● ● ●
● ● ● ●●
● ●
4
● ● ●●
●
● ● ● ● ●● ●
● ● ● ●
● ●
●●●● ●
● ●● ● ● ●● ●●● ● ●● ●
● ●
●● ●
● ●
● ●●●● ●●● ●●● ●
●
●
●●● ● ●
● ● ● ●● ●● ● ●●
● ●● ●
● ●
●●
●● ●
● ● ●
●● ● ● ● ●●●
●
●● ● ●
● ● ●
●
●●● ● ●●● ●
● ●●●●
●
●●
● ● ●●
●●
●●● ● ●●● ● ● ● ●●●
●● ●●●●
●
●● ● ●
●
●● ● ●
● ●●● ●●● ●
●●
● ● ● ●●
● ●●●
● ● ●● ●
●● ●● ●
●
●
●●● ● ●●●● ● ●● ● ●●
● ●
●●●●
●●
● ● ● ● ●
●
● ● ●● ● ● ● ● ●
● ●●
●
●
●
● ●● ● ●● ● ●
●
●●●
●●●
● ●
●● ●●●
●
●●●
● ●
●
●● ● ● ●●
●●●● ● ● ●● ● ● ●● ●●
●
● ●
● ●
●●● ● ●●● ● ●●●
● ●● ●●
●●
● ● ● ●
● ●● ●● ● ● ● ●
● ● ● ● ●●●
●
● ●● ● ●
●
●
● ●● ● ● ●● ● ● ● ● ●
●● ● ● ●
2
●
● ● ●● ● ● ●
●●
● ●● ●●
● ●
●
●●●
●
●●●
● ●●●●●
● ●●
● ●●
● ●● ● ● ● ● ● ● ● ● ●● ●● ●
● ● ●● ● ●
● ●●●●● ●● ● ● ●● ●● ●●●● ●●●
●●●● ● ●● ●
●
●●
●● ●●
●●● ●●
●●●
●● ●
●● ● ● ●● ●●● ●
●
●●
●
●
●
●
● ●●
●●●● ●● ●●● ●● ●●●
●●
●●● ●● ●● ●●● ●●●
●●●
● ●
●●
●
●●● ●● ●● ●● ●
● ● ● ●● ● ● ● ● ●●●
●●●● ●● ● ●
●
●
●
●●● ●● ● ●
●●
● ● ● ●● ● ● ●● ● ●
●
● ● ●● ● ● ●● ● ● ●
●● ●
●
● ●● ● ●●● ●
●
●
● ● ●●●●
● ●● ● ● ● ● ●●● ●● ● ●● ● ●●
● ●● ●●
● ● ● ● ●●● ● ●● ● ●●
●
● ● ●● ●
●
● ●● ●●●
● ●●●●●●
●
●
● ● ●●
●●
●●●
●● ● ●
●●●●
●
●●
● ● ●
●●●
●
●
●
●●●●● ●
● ●
●
●
●
●●●● ●●●
●
●
●
●●● ●●● ●●●● ●
● ●
●●●
●
●●● ●● ● ●
●●●
● ● ● ● ● ●●●
●●●
●
●
●●●
●●
● ●●● ●● ●●● ●
●●●●●●
●
●●●● ● ●●
●
●●
●
●●
●● ●
●●
●
●
●●
●
●
●●
●● ●
●
●●● ●
●
●●●●
● ●
●●
● ●
●
●
●●
● ●● ●●
●●●
● ●●● ●
● ●●
●
●●●
●
●●● ●
●
● ●●
●
●●
●
●●●● ●●●
●●
●●● ●
●●
●● ●● ● ●●
● ● ● ●
● ●
●
●
●●●● ●
● ●●
●
●
●●
●
●
● ● ●
●
●●
● ●
●
●
● ●●
●●
●
●●
● ●
● ●●●●●●●●● ●● ●●
● ● ● ●●● ●
● ●
● ●●
● ●
●●●
●● ●●●
●●
●●●● ● ● ● ● ● ● ● ● ●
●●
●
●●
● ●●●
● ● ●● ●● ● ●● ●●
●●●
●
●
●●● ● ● ● ●
●
●●●● ●●
●●●
●
● ●
●●●● ● ● ●●
● ●● ● ● ●● ●
●
●
●●●●
●●●●●
●
●●●
● ● ●
●
● ●● ●●
●● ●●●
●
●●
● ●
●
●●●
●●
●●●
●
●
●
●●●
●
● ●
●●
● ●●
● ●
●●●
●
●
●● ●●● ●
● ●
● ●
●●
●
●●
●
●●● ●
●●●● ●
●●
●●
●●● ●●
●
●●
●●●● ●
●● ● ●
●●
●●●●
●●
●●
●
●●● ●
●
● ●● ● ●
●
●
●●● ●● ●
● ●●● ●●●
●
●
●
●
●●●
●
● ●● ●●●● ●
●●●● ●●
●●
●
●●
●●
●
●●●
●
● ●●
●
●
● ●●●
●
●●●●●
●
● ●●●●
● ●●
●
●●● ● ●
●
●
●
●
●●●●
●
●●
●●
●
●●
●●
●
●●
●●●
● ●
●●●●
●
●
●●●
●●● ●●● ●
●●● ●
●●●
●● ●● ●
● ●
●
●
● ●● ● ●
●●
●● ●●●●
●●
●
●●●●
●●
●●●●●●
● ●●
●
●●
●
●●
●●●
●
●●
●●
●
●●
●
●●●●
●
●
●●
●●
●
●●● ●
●●●
●
●
●●● ●●● ●● ●●
●●●●
●
● ●
●●●●●●
● ●
● ●
●● ●●● ●● ●●●
●● ● ●●●
● ●
●●
●●
●●●●●●
● ● ●
●●
●
● ●●
●
● ● ● ● ● ● ● ●● ●● ●
● ●
●●●
●●●
●●●●●
●●●●●
●
●
●●●●
●●●●
●●●
●●
●
●
●
●●●
●●● ●
●●
●● ●
● ●●●●
●
●●●●
●
●●
●
●
●
●
●
● ●
●●
●
●●
●
●●
●
●
●
●
●●●
●
●●●
●●
●●
● ●● ●●●
●●●
●
●● ●
●●●
●
●●
●●
●
●●●
●● ●●
●
●●
●
●
●●
●
●
●
●●
●
●●●●
●●●
●●●
●●
●
● ●
●
●
●
●●●
●
●
●●●●
●●●
●●
● ●●●●
●●
●
●
●●●
●
●
●●●
●
●●
●
●
●●●
●
●
●●●
●
●●●
● ●
●●
●● ●● ●●
●●●
●
● ● ● ●
●●● ●
●●
●
●
●●●●
●●
●
●●
●
●
●
●
●● ● ● ●
●● ●●●
●●●
●
●●
●● ●
●
●●
●
●
● ●
● ●
●●●
●●●
●●●
●
●●●
●
●●
●●●
●
●●
● ●
●●●
●
●●●●
●
●● ●
●●
●
●●
●
●●
● ●
●●
●●
●
● ●
●
●
●●●
●●●
●● ●●●
●●
●
●●
●
●●●●
●
●
●
●●
●●
●
●●
●●
●
● ●
●
●●
●●● ●
●● ●
●● ●
●
●●● ●●●● ●
● ●●
● ● ●
●●
●
●
●●●
●
●
●●
●●●
●
● ●
●●●●●●●●● ●●
●
●●●●●●●●
●●
●●
● ●
●
●● ● ●
●
●
●
●●●●●●
●
●●●●
●
●
●
●
●
●●●●●● ● ● ●
●●●
● ●●●
●●
●
●
●●
● ●
●
●●
●
●●
● ●
●
●●●
●●●
● ●●
●●
●●
●●●
●●●● ●
●
●●
●
●●
●
●
●●●
●●
● ●●
●
●●●●
●
●
●
●●
●●
●
●●●●
● ●
●
●●●
●
●
●
●
●●●●
●●●● ● ●
●
● ●●
●
●●●●●●●
●
●●●●
●
●
●●
●
●●
●
●●
●
●
●
●
●
●
●
●●
●
●●●●●
● ● ●
●●●
●
●●
●●
●●
●●
●●
●●
●
● ●●
●●● ●●●
●●
● ●●
●●
●●●●
●●●
●
●
●
●●
●
●●
●
●
●●
●
●
●
●●
●
●
●● ●
●
●●
●●
● ●●
● ●●● ●
●●
●●●
●●
●
●
●
●●
●
●●
●●
●
●
●
●●●
●
● ●
●●●
●
●
●●
●●●●
● ●
●●
●
●
●
●
●
●
●
●●
●●
●
●
●● ●
●●●
●● ●●
●●
●
●●
●
●
●●
●
●●●
●
●●
●●●
●●
●
●●
●
●
●●
●
●
●●
●
●●●
●
●
●
●
●
●●●
●
●●
●●
●●
●
●●
●●●
●●
●●
●●
●
●
●
●●
●
●
●●● ●●●
●
● ●
●
●
●●
●
●●
●
●●●
●●
0
● ●
●● ● ●● ●●● ● ● ● ● ● ●●
●● ●● ● ● ● ● ● ● ●
●● ● ● ●
map5k
Figure 9.2: Manhattan plot for imputed (black empty circles) and 500 directly
typed (red solid circles) SNPs
Exercise 2.
Please classify the associations obtained into ’true’ and ’false’ (meaning ’I
believe it’ and ’I do not believe’). Of cause ultimate answer is replications.
Still, the object df5k provides genotypes for all 5000 SNPs, directly typed! So,
212 CHAPTER 9. ANALYSIS OF IMPUTED DATA: AN EXAMPLE
14
●
●
●
12
● ● ●
● ●
●
● ●
−log10(qtsPal[, "P−value"])
10
●
8
●
●
●
●
● ● ●
●
●
● ●
● ●
6
●
● ●
●
●
●
●●
●●●●
●● ●
● ● ●● ●●
● ● ● ●●
●●● ● ● ●● ● ●
● ● ● ●●
● ●●
● ● ●●
●●●● ● ● ●● ●
●● ●
●● ● ●● ● ●
●●
●
● ●●
●● ●● ●●●●
4
● ●● ● ● ●●
●●●
●
●
●●
●●●
● ●●
●
●●●● ●
●● ● ●●●● ●● ●
●● ●
●
●
●
●●●
●●●
●
●
●●
●●●●● ● ●● ● ●
●● ●●
●●
● ●
●●
●●
● ●
● ● ●● ● ● ●● ●
●●
●
●
●
●●●
●●● ● ●
● ● ●● ●●
●●●
● ●● ● ●
●
●
●
●
●●
●●
●●●
●
●●● ●
●
●●
●●
●●
●
●
●
●
●●●●
●●
●
●
●
●
●●
●
●
●
●
●●●
●● ●● ● ●
● ●●
● ●●
●●●●●●●
●●● ●
●●
●
● ●
●●●●●● ● ●●
●●
● ●●●●●
●●● ●●
●
● ●●
●●●
●
●
●● ●
●●●
●
●●
●●●
●●●●
● ●
● ●
●
●
●●
● ●●
●
●
●●●
●●
● ●● ● ●●
2
● ●● ●●
● ●●
●●
●●
●●
●●
●
●
●●
●●●
●●●
● ●
●●● ● ● ● ●
● ●●
●●●
●●●●●
●
●●
●
●●
●●
●●●●●●●
●
●
●
●
●
●
●
●
●
●
●●●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●●
●
●
●
●
●
●●
●●●●●●
●●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●●
●
● ●
●
●
●
●
●●●
●
● ●●●●●●
● ● ●● ● ●
●
●
●●
●
●
●●
●
●●
●
●
●●
●
●
●
●
●●
●●
●
●●
●
●
●●
●●
●
●
●
●●
●
●
●
●●
●
●●
●●
●●
●
●
●●●●●●
● ●
●● ● ● ●
●
●
●
●●
●
●
●●
●
●●
●
●●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
●●
●●
●
●●●●●
● ● ●●●●●
●
●
●●●
●●
●
●
●●
●
●●
●●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●●
●●
●●●
●
●
● ● ● ● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●●●
●
●●
●
●
●
●
●
●●
●●●
●
●
●●●●●●
● ● ● ●
●
●
●●
●●
●●
●
●●●
●●
●
●●
●●
●●
●
●●●
●●●●●● ●●●●● ● ●●●●●
●
●
●
●
●
●●
●
●
●
●●
●
●●●
●
●
●
●●
●
●
●●
●
●
●●
●
●
●
●●
●
●
●●
●
●
●●
●
●●
●
●●
●
●
●●●
●
●
●●
●●
●●
●
● ●
●
0
0 5 10 15
−log10(qts5k[, "P1df"])
Figure 9.3: Cross-plot of the results from analysis of imputed and directly typed
data (see answers to exercises).
you can run analysis, and cross-check which SNPs are confirmed as significant.
Make a cross table: SNPs you thought were truly associated vs. SNPs indeed
associated in directly typed data set.
time-till-event traits
9.4. ANSWERS TO EXERCISES 213
> #plot(map5k,-log10(qtsImp[,"P-value"]))
> #abline(h=-log10(5e-8))
> gwsSnpsImp <- rownames(qtsImp)[which(qtsImp[,"P-value"]<=6e-8)]
> mlinfo <- [Link]("[Link]",head=T,strings=F)
> mlinfo[mlinfo$SNP %in% gwsSnpsImp,]
Answer (Ex. 1) — Firstly, you can check (by producing a cross-plot of geno-
type vs. phenotype) if association is indeed due to extreme phenotypic out-
liers. A related question is whether the distribution is skewed. Additionally,
214 CHAPTER 9. ANALYSIS OF IMPUTED DATA: AN EXAMPLE
a permutation-based test can help establishing correct p-value, taking into ac-
count the nature of the data in question.
However, to give an ultimate answer, a replication study is needed, in which
these rare SNPs are to be typed in a large independent sample.
Answer (Ex. 2) — Here is the sequence of commands leading you to the an-
swer:
> qts5k <- mlreg(rcT~1,df5k)
> bestHits5k <- [Link](qts5k,top=20)
Summary for top 20 results, sorted by P1df
> bestHits5k
Chromosome Position Strand A1 A2 N effB se_effB chi2.1df
rs566570 20 2965113 + T C 120 1.341584 0.1585342 71.61267
rs6039167 20 846271 + G A 120 -5.945198 0.7731855 59.12420
rs6037443 20 2909408 + G A 120 1.194178 0.1628897 53.74655
rs7261762 20 853448 + A G 120 -6.733516 0.9748760 47.70732
rs554362 20 850002 + A G 120 -5.431215 0.8045925 45.56613
rs2104741 20 787070 + G A 120 -9.203756 1.3888630 43.91485
rs7273309 20 853154 + C T 120 -9.203756 1.3888630 43.91485
rs7267882 20 853785 + G A 120 -9.203756 1.3888630 43.91485
rs8123328 20 855045 + G T 120 -9.203756 1.3888630 43.91485
rs7265788 20 855426 + A G 120 -9.203756 1.3888630 43.91485
rs7263171 20 855655 + C T 120 -9.203756 1.3888630 43.91485
rs6110342 20 1458950 + T G 120 -9.203756 1.3888630 43.91485
rs6105340 20 1493635 + G A 120 -9.203756 1.3888630 43.91485
rs11905071 20 1557640 + T C 120 -9.203756 1.3888630 43.91485
rs6080013 20 1590861 + G A 120 -9.203756 1.3888630 43.91485
rs6074978 20 1595216 + T C 120 -9.203756 1.3888630 43.91485
rs2325971 20 2774477 + T C 120 -1.055991 0.1697536 38.69752
rs873711 20 2775468 + A G 120 -1.055991 0.1697536 38.69752
rs6037425 20 2785379 + G C 120 -1.055991 0.1697536 38.69752
rs6051434 20 2781237 + T G 120 0.938854 0.1769196 28.16076
P1df Pc1df effAB effBB chi2.2df P2df
rs566570 2.618695e-17 5.551496e-06 NA NA NA NA
rs6039167 1.480274e-14 3.663781e-05 NA NA NA NA
rs6037443 2.280947e-13 8.301445e-05 NA NA NA NA
rs7261762 4.948399e-12 2.090409e-04 NA NA NA NA
rs554362 1.475718e-11 2.904523e-04 NA NA NA NA
rs2104741 3.429767e-11 3.745369e-04 NA NA NA NA
rs7273309 3.429767e-11 3.745369e-04 NA NA NA NA
rs7267882 3.429767e-11 3.745369e-04 NA NA NA NA
rs8123328 3.429767e-11 3.745369e-04 NA NA NA NA
rs7265788 3.429767e-11 3.745369e-04 NA NA NA NA
rs7263171 3.429767e-11 3.745369e-04 NA NA NA NA
rs6110342 3.429767e-11 3.745369e-04 NA NA NA NA
rs6105340 3.429767e-11 3.745369e-04 NA NA NA NA
rs11905071 3.429767e-11 3.745369e-04 NA NA NA NA
rs6080013 3.429767e-11 3.745369e-04 NA NA NA NA
rs6074978 3.429767e-11 3.745369e-04 NA NA NA NA
9.4. ANSWERS TO EXERCISES 215
> abline(h=-log10(5e-8))
> abline(v=-log10(5e-8))
> directNotImp <- gwsSnps5k[!(gwsSnps5k %in% gwsSnpsImp)]
> directNotImp
[1] "rs2104741" "rs7263171" "rs6110342" "rs6105340" "rs11905071"
[6] "rs6080013" "rs6074978"
> imputeNotDir <- gwsSnpsImp[!(gwsSnpsImp %in% gwsSnps5k)]
> imputeNotDir
[1] "rs553378" "rs6047425" "rs6035871" "rs6051434" "rs6076466" "rs2326056"
> inBoth <- gwsSnps5k[gwsSnps5k %in% gwsSnpsImp]
> inBoth
[1] "rs566570" "rs6039167" "rs6037443" "rs7261762" "rs554362" "rs7273309"
[7] "rs7267882" "rs8123328" "rs7265788" "rs2325971" "rs873711" "rs6037425"
> summary(gtdata(df5k[,directNotImp]))
Chromosome Position Strand A1 A2 NoMeasured CallRate Q.2
rs2104741 20 787070 + G A 120 1 0.004166667
rs7263171 20 855655 + C T 120 1 0.004166667
rs6110342 20 1458950 + T G 120 1 0.004166667
rs6105340 20 1493635 + G A 120 1 0.004166667
rs11905071 20 1557640 + T C 120 1 0.004166667
rs6080013 20 1590861 + G A 120 1 0.004166667
rs6074978 20 1595216 + T C 120 1 0.004166667
P.11 P.12 P.22 Pexact Fmax Plrt
rs2104741 119 1 0 1 -0.0041841 0.948425
rs7263171 119 1 0 1 -0.0041841 0.948425
rs6110342 119 1 0 1 -0.0041841 0.948425
rs6105340 119 1 0 1 -0.0041841 0.948425
rs11905071 119 1 0 1 -0.0041841 0.948425
rs6080013 119 1 0 1 -0.0041841 0.948425
rs6074978 119 1 0 1 -0.0041841 0.948425
> mlinfo[which(mlinfo$SNP %in% directNotImp),]
SNP Al1 Al2 Freq1 MAF Quality Rsq
871 rs2104741 G A 0.9562 0.0438 0.9145 0.0679
1027 rs7263171 C T 0.8639 0.1361 0.9246 0.7898
1978 rs6110342 T G 0.9160 0.0840 0.8472 0.1967
2028 rs6105340 G A 0.8790 0.1210 0.7849 0.2076
2064 rs11905071 T C 0.8846 0.1154 0.7989 0.1890
2111 rs6080013 G A 0.9577 0.0423 0.9342 0.3869
2118 rs6074978 T C 0.9576 0.0424 0.9340 0.3851
> summary(gtdata(df5k[,imputeNotDir]))
Chromosome Position Strand A1 A2 NoMeasured CallRate Q.2 P.11
rs553378 20 849882 + G A 120 1 0.02500000 114
rs6047425 20 2141014 + A G 120 1 0.07083333 104
rs6035871 20 2143364 + A G 120 1 0.07083333 104
rs6051434 20 2781237 + T G 120 1 0.47500000 37
rs6076466 20 2982048 + T C 120 1 0.22916667 71
9.4. ANSWERS TO EXERCISES 217
Meta-analysis of GWA
scans
219
220 CHAPTER 10. META-ANALYSIS OF GWA SCANS
As you can see, the weights have straightforward interpretation: the bigger
the weight of the study (meaning the small is the standard error in the study),
the larger is the contribution from this study onto the pooled estimate.
The standard error of the pooled estimate is computed as
1
s 2 = PN
i=1 wi
Let us try to access the joint significance of the association using these data.
First, let us define a vector of regression coefficients and squared standard errors:
> beta <- c(0.16,0.091,0.072,-0.03)
> s <- c(0.07,0.042,0.048,0.12)
> s2 <- s*s
> s2
[1] 0.08898527
[1] 0.0007846539
[1] 10.09155
[1] 0.001489504
[1] 0.07544522
[1] 0.0009342602
222 CHAPTER 10. META-ANALYSIS OF GWA SCANS
[1] 6.092501
[1] 0.01357568
Indeed, when the first ”champion” report is excluded, the overall evidence is
decreased and results become less significant, though still pointing to the same
direction.
When binary traits are studied, and results are reported as Odds Ratios with
P − values, it is also possible to apply inverse variance method. For this, you
need to transform your Odds Ratios using natural logarithm, and, on this scale,
estimate the standard error. Generic inverse variance pooling may be applied
to the data transformed this way; the final results are back-transformed onto
Odds Ratio scale using exponentiation.
Let us consider a simple example. Let Odds Ratios and χ2 test statistics
values coming from four studies of a binary phenotype are as following: θ1 = 1.5
(χ2 = 5.1), θ2 = 1.3 (χ2 = 2.2), θ3 = 0.9 (χ2 = 0.5), θ4 = 1.2 (χ2 = 3.1).
Let us first transform the Odds Ratio to the logarithmic scale with
> or <- c(1.5,1.3,0.9,1.2)
> lnor <- log(or)
> lnor
To compute standard errors from known χ2 values, one can use simple relation
β2
χ2 =
s2
and thus
β2
s2 =
χ2
Thus to compute the square standard errors corresponding to the log-Odds
Ratio, we can use
> chi2or <- c(5.1,2.2,0.5,3.1)
> s2lnor <- lnor*lnor/chi2or
> s2lnor
[1] 0.1650462
> ps2 <- 1/sum(w)
> ps2
[1] 0.004968165
> pchi2 <- plnor*plnor/ps2
> pchi2
[1] 5.482958
> ppval <- 1.-pchisq(pchi2,1)
> ppval
[1] 0.01920274
And the corresponding estimate of pooled Odds Ratio is
> exp(plnor)
[1] 1.179448
and 95% confidence interval is
> exp(plnor-1.96*sqrt(ps2))
[1] 1.02726
> exp(plnor+1.96*sqrt(ps2))
[1] 1.354181
Some times, effects are reported on different scales, and/or there may be
suspect that these effects are not translatable across studies because of the
differences in experimental design or for some other reasons. In this case, it may
be better to poll the data without use of the effect estimate in exact manner,
based only on the sign of association and its significance. This can be done by
pooling Z-score values. Z-score refers to the test statistics, which has standard
normal distribution under the null and can be derived e.g. by dividing estimate
of the regression coefficient onto its standard error:
βi
Zi =
si
The Z-score pooling methods can be derived from the inverse variance pool-
ing by exploiting
√ the fact that generally standard error of the estimate is pro-
portional to 1/ n, where n is the number of observations used for estimation.
Therefore individual scores are assigned weights which are proportional to the
square root of number of independent observations used in individual study,
√
wi = ni . The pooled Z-score statistics is computed as
PN
i=0 wi Zi
Z= P q
N 2
i=0 wi
We can now repeat the analysis of our first data set using Z-score pooling
method. First, our data from table 10.1 are
224 CHAPTER 10. META-ANALYSIS OF GWA SCANS
[1] 3.163875
[1] 0.001556839
which is almost the same P − value we have obtained previously using the
inverse variance method. Note, however, that now we do not know the ”pooled”
estimate of the regression coefficient.
Other important aspects of meta-analysis, such as heterogeneity, and a wide
range of methods different from the inverse variance and Z-score based methods
are not covered here, and we refer the reader to more epidemiologically-oriented
literature for a better review.
Table 10.2: Summary of six studies of association between T2D and Pro12Ala
polymorphism of the PPAR-GenABEL-packagemma gene. n: number of sub-
jects; effective allele: the allele for which the OR was estimated.
Study Effective allele n ORE P − value
1 Ala 221 0.67 0.013
2 Pro 306 0.93 0.60
3 Pro 71 1.08 0.84
4 Ala 164 0.83 0.40
5 Pro 242 1.22 0.25
6 Pro 471 1.23 0.07
and only than the effect estimate, standard error of the effect, and number of
observations used to do estimation.
Other characteristics which are also recommended for reporting because they
describe the quality characteristics of the sample and/or provide redundant in-
formation, which is good for double checks. Such characteristics include: fre-
quency of the effective or reference allele, call rate, P-value for Hardy-Weinberg
equlibrium and may be some parameter describing what is the direction of de-
viation from HWE (e.g. Fmax ). When reporting results for imputed SNPs,
more quality control characteristics should be included, suh as average maximal
posterior probability, R2 , etc.
Let us start with arranging two data sets which could then be used for meta-
analysis. Basically, we will use cleaned data from the GWA exercise you did in
section 5 (”Genome-wide association analysis”, page 103), and split that is two
parts.
If you did not do this yet, start R and load GenABEL-package library, which
you will need it to work with GWA-data
> library(GenABEL)
> load("[Link]")
> nids(data2)
[1] 124
We will analyse body mass index. If you pooling results of analysis of stud-
ies which are designed in approximately the same manner, you may think of
reporting the effect estimates on the same scale and use of the inverse variance
method for meta-analysis.
However, in meta-analysis of multiple data sets different individual studies
are likely to assess different population, will use different designs, measure dif-
ferent covariates, and so on. Therefore you should think of some standardisation
of the outcome variable (or apply Z-score method).
Therefore for the purpose of future meta-analysis, it becomes conventional
to analyse pre-adjusted data which are scaled to Standard Normal (mean of zero
and variance of unity). Note that this argument applies only to meta-analysis –
you may and should report effects on the original scale (e.g. in centimeters and
grams) in analysis of individual studies, in order to have better interpretability.
desirable. Note that transformation to Standard Normal does not improve the
fit to normality; to do that other transformation should be applied. Probably
the most famous transformations are log- and square root ones, then one may
think of Box-Cox transformation. At the same time there is a transformation,
called a Rank Transformation ro Normality which guarantees perfect fit to Nor-
mal in absence of heavy ties2 . We advocate the use of Rank Transformation to
Normal for meta-analysis purposes.
GenABEL-package implements the ztransform function for the purposes of
Z-transformation. This function takes two (actually three – see help for details)
arguments: formula (or just the variable name) and data. ztransform function
will perform (generalised) linear regression using the specified formula, and will
transform the residuals from analysis onto Z-scale by subtracting the mean and
division by the standard deviation.
Let us consider what this function does practically. Let us first transform
BMI from the first set without using covariates:
> zbmi0 <- ztransform(bmi,mdta1)
The histogram of the transformed variable and scatter-plot of raw against trans-
formed BMI is given at figure 10.1, column 1. Note that the fit to Normality
is not improved by this transformation; with the original BMI, the Shapiro test
for deviation from normality gives
> [Link](phdata(mdta1)$bmi)
data: phdata(mdta1)$bmi
W = 0.9328, p-value = 0.0199
data: zbmi0
W = 0.9328, p-value = 0.0199
This is quite natural: as you can note from scatter-plot in column 1 of figure
10.1, only the centering and the spread of the scales are different for X (original
BMI) and Y (x0), otherwise there is an exact linear correspondence between the
two.
We can also do transformation using sex and age-adjusted residuals with
> zbmi1 <- ztransform(bmi~sex+age,mdta1)
The scatter-plot of raw against transformed BMI is given at figure 10.1, column
2. Note that this transformation may slightly change the fit to Normal, which
happens because we factor out the effects of sex and age:
> [Link](zbmi1)
2 Ties are generated by the subjects with exactly the same trait values
228 CHAPTER 10. META-ANALYSIS OF GWA SCANS
data: zbmi1
W = 0.9263, p-value = 0.01224
From the scatter-plot in column 2 of figure 10.1, it is quite clear what happens:
the residuals from linear regression are not corresponding to the original BMI
in exact linear manner.
A similar function, which performs rank-transformation to normality, is
named rntransform. For example if we want to adjust BMI for sex and age
and rank-transform the residuals to Normal, we can use
> rnbmi1 <- rntransform(bmi~sex+age,mdta1)
This transformation, however, indeed improves the fit to Normal:
> [Link](rnbmi1)
data: rnbmi1
W = 0.999, p-value = 1
In essence, the P − value of 1 means perfect fit to Normal – and this is what
should have occurred when this transformation is used on the data without ties.
Perfectly Normal distribution of the transformed trait may be enjoyed at the
histogram presented at column 3 of figure 10.1.
Let us analyse Rank-Normal-transformed, sex and age-adjusted BMI in the
two data sets, using qtscore function. Analysis of the first study is done with
> qts1 <- qtscore(rnbmi1,mdta1)
and analysis of the second study is done with
> zbmi2 <- ztransform(bmi~sex+age,mdta2)
> qts2 <- qtscore(zbmi2,mdta2)
The analysis looks very simple – is not it? However, the real difficulty did
not start yet: now we need to extract coding, reference allele, strand, etc. –
otherwise we can not do right meta-analysis later on!
Let us assume that you want to summarise the GW results from additive 1
d.f. test using following variables (as, e.g., requested by consortium):
• name: SNP name
• chromosome: chromosome number
• position: physical position of the SNP
• refallele: reference allele
• codedallele: coded (effect) allele
• strand: strand
• refallfreq: frequency of the reference allele
10.3. REPORTING GWA RESULTS FOR FUTURE META-ANALYSIS 229
10
8
8
8
6
6
Frequency
Frequency
Frequency
6
4
4
4
2
2
2
0
0
−2 0 1 2 3 −1 0 1 2 3 −2 0 1 2
● ● ●
3
2
3
●
●
●
● ●
● ●
2
1
●
2
●
● ●● ●
●●
●●
● rnbmi1 ●
zbmi0
zbmi1
● ● ●●
1
● ●●●
1
0
● ●● ●
● ●
●● ●
●
●
●●
● ●●
●
●●
● ●● ●
●
●●
● ●
● ● ●● ●●
0
● ●
0
●
−1
● ●● ●
●
● ●
●
● ● ●
●
●
● ●●
● ●
● ●
●
●● ●
●
● ●●●●
−1
−1
●● ●
●
−2
● ●●
●● ●
● ●
20 30 40 50 60 20 30 40 50 60 20 30 40 50 60
Figure 10.1: Histogram of transformed BMI and scatter-plots of the raw BMI
against transformed BMI. Column 1: Z-transformation without covariates. Col-
umn 2: Z-transformation with adjustment for age and sex. Column 3: Rank-
transformation to normality, after adjustment for sex and age.
You can see that most infromation is already present in the output, though
called using names which are different from these requested. However, we miss
reference allele frequency, SNP call rate and P -value from the Hardy-Weinberg
equilibrium test. These however can be computed using the summary function:
> # for data part 1:
> sum1 <- summary(gtdata(mdta1))
> sum1[1:2,]
Note, however, that we now got frequency of the effective (or coded) allele,
not the frequency of the reference allele! The quantity we need can be easily
computed, though:
> # for data part 1
> refallfreq1 <- 1 - sum1[,"Q.2"]
> # ... and for data part 2
> refallfreq2 <- 1 - sum2[,"Q.2"]
At this moment we can arrange the required data frame:
> mdf1 <- [Link](name=snpnames(qts1),chromosome=chromosome(qts1),
+ position=map(qts1),refallele=refallele(qts1),
+ codedallele=effallele(qts1),strand = strand(qts1),
+ refallelefreq = refallfreq1,n=qts1[,"N"],
+ beta=qts1[,"effB"],
+ se_beta=qts1[,"se_effB"],p=qts1[,"P1df"],
+ p_corr=qts1[,"Pc1df"],call = sum1[,"CallRate"],
+ phwe = sum1[,"Pexact"], stringsAsFactors = FALSE)
note the last argument – stringsAsFactors = FALSE. I suggest you use that
by default when constructing a new data frame – unless you are sure that you
can work out your way later on with strings saved as factors.
Let us inspect the first 5 raws of the resulting output:
> mdf1[1:5,]
10.3. REPORTING GWA RESULTS FOR FUTURE META-ANALYSIS 231
> mdf1[1:5,]
To write all the data to a file, we can use standard R [Link] function:
> [Link](mdf1,file="RData/[Link]",[Link]=F)
Similar analysis is applied to the second data set:
> mdf2 <- formetascore(bmi~sex+age,mdta2,transform=rntransform, verbosity = 2 )
We can inspect the first five lines of the output with
> mdf2[1:5,]
name chromosome position strand allele1 allele2 build
rs1646456 rs1646456 1 653 + C G unknown
rs4435802 rs4435802 1 5291 + C A unknown
rs946364 rs946364 1 8533 - T C unknown
rs299251 rs299251 1 10737 + A G unknown
rs2456488 rs2456488 1 11779 + G C unknown
effallele effallelefreq n beta sebeta p
rs1646456 G 0.32926829 82 -0.04879397 0.1663650 0.76929696
rs4435802 A 0.08024691 81 0.37724197 0.2984226 0.20618701
rs946364 C 0.25903614 83 -0.14414880 0.1790329 0.42073156
rs299251 G 0.04216867 83 -0.69920378 0.3919648 0.07444912
rs2456488 C 0.34146341 82 -0.23105805 0.1520352 0.12856957
pgc [Link] [Link] pexhwe call
rs1646456 0.77676571 1.070017 0.0009650323 0.8038996 0.9879518
rs4435802 0.22168453 1.070017 0.0009650323 1.0000000 0.9759036
rs946364 0.43635427 1.070017 0.0009650323 1.0000000 1.0000000
rs299251 0.08461892 1.070017 0.0009650323 1.0000000 1.0000000
rs2456488 0.14177789 1.070017 0.0009650323 0.4685397 0.9879518
Let us write the data to a file:
> [Link](mdf2,file="RData/[Link]",[Link]=F)
Finally let us analyse and save results for another data set, ge03d2c:
> data(ge03d2c)
> mdf3 <- formetascore(bmi~sex+age,ge03d2c,transform=rntransform, verbosity = 2 )
> [Link](mdf3,file="RData/[Link]",[Link]=F)
analysing ...
Lambda Part1 = 0.9499903
Lambda Part2 = 1.098705
Corrected Lambda Part1 = 0.9499903
Corrected Lambda Part2 = 1
Lambda POOLED data = 1.023276
... DONE
The pooled data frame contains results of meta-analysis and essential details
of the original studies:
> pooled[1:5,]
If one needs to pool more studies, this data frame should be used as the first
argument of the [Link], and name.x argument should take special
value ”POOLED”:
> pooled <- [Link](pooled,mdf3,name.x="POOLED",name.y="mdf3")
> pooled[1:5,]
extra arguments regulate the SNP exclusion criteria: maf=0.01 tells to exclude
SNPs with minor allele frequency less then 0.5%, call=0.95 tells to drop SNPs
with call rate less than 95%, and phwe=1.e-8 instructs to exclude SNPs with
HWE P -value ≤ 10−8 .
Now we can read and inspect the results of meta-analysis with:
interval? Do analysis using at least two methods. Which method is better (best)
in this situation? Why?
We first need to unify Odds Ratios by using the same effective allele. Let that
be the ”risk” allele, as may be guessed from a glance to the data, namely ”Pro”.
When the effects are reported for the other, ”Ala” allele, the corresponding ORs
for the ”Pro” allele can be found using simple relation ORP ro = 1/ORAla .
Thus, the vector of Odds Ratios for ”Pro” allele is
> [Link] <- c(1./.67,0.93,1.08,1./.83,1.22,1.23)
> [Link]
[1] 0.1686548
[1] 0.06622101
Thus the pooled estimate of Odds Ratio from association between type 2
diabetes and ”Pro” allele is
> exp([Link])
10.5. ANSWERS TO THE EXERCISE 237
[1] 1.183711
and the 95% confidence interval is
> exp([Link]-1.96*p.s)
[1] 1.039627
> exp([Link]+1.96*p.s)
[1] 1.347765
The χ2 test for association and corresponding P − value are
> p.chi2 <- ([Link]/p.s)^2
> p.chi2
[1] 6.486429
> [Link] <- 1-pchisq(p.chi2,1)
> [Link]
[1] 0.01087011
Z-score pooling though may be more appropriate method for such differen-
tially designed studies (e.g. control groups are very different). To get Z-score
pooling working, we need first find Z-scores from P-values
> p <- c(0.013,0.6,0.84,0.40,0.25,0.07)
> z <- sqrt(qchisq(1-p,1))
> z
[1] 2.4837693 0.5244005 0.2018935 0.8416212 1.1503494 1.8119107
and assign the right sign (let ”+” is for the risk effect of ”Pro”).
> effsig <- c(1,-1,1,1,1,1)
> z <- z*effsig
> z
[1] 2.4837693 -0.5244005 0.2018935 0.8416212 1.1503494 1.8119107
Now, we need to assign weights to the studies as
> n <- c(221,306,71,164,242,471)
> w <- sqrt(n)
ane the pooled estimate of Z and corresponding P − value are
> zpoo <- sum(w*z)/sqrt(sum(w^2))
> zpoo
[1] 2.537333
> 1-pchisq(zpoo*zpoo,1)
[1] 0.01117008
As you can see the results are almost identical to the previous obtained with
inverse variance pooling.
238 CHAPTER 10. META-ANALYSIS OF GWA SCANS
10.5.1 Exercise 9:
Perform meta-analsys excluding the original report (study 1). Is there still
significant association between Pro12Ala and diabetes?
The answer to this exercise can be obtained in exactly the same manner, as
for the previous one, limiting our consideration to the last five studies.
Thus, the vector of Odds Ratios for ”Pro” allele is
> [Link] <- c(0.93,1.08,1./.83,1.22,1.23)
> [Link]
[1] 0.1216172
[1] 0.07262917
Thus the pooled estimate of Odds Ratio from association between type 2
diabetes and ”Ala” allele is
> exp([Link])
10.5. ANSWERS TO THE EXERCISE 239
[1] 1.129322
and the 95% confidence interval is
> exp([Link]-1.96*p.s)
[1] 0.9794776
> exp([Link]+1.96*p.s)
[1] 1.30209
The χ2 test for association and corresponding P − value are
> p.chi2 <- ([Link]/p.s)^2
> p.chi2
[1] 2.803937
> [Link] <- 1-pchisq(p.chi2,1)
> [Link]
[1] 0.09403318
Z-score pooling though may be more appropriate method for such differen-
tially designed studies (e.g. control groups are very different). To get Z-score
pooling working, we need first find Z-scores from P-values
> p <- c(0.6,0.84,0.40,0.25,0.07)
> z <- sqrt(qchisq(1-p,1))
> z
[1] 0.5244005 0.2018935 0.8416212 1.1503494 1.8119107
and assign the right sign (let ”+” is for the risk effect of ”Pro”).
> effsig <- c(-1,1,1,1,1)
> z <- z*effsig
> z
[1] -0.5244005 0.2018935 0.8416212 1.1503494 1.8119107
Now, we need to assign weights to the studies as
> n <- c(306,71,164,242,471)
> w <- sqrt(n)
ane the pooled estimate of Z and corresponding P − value are
> zpoo <- sum(w*z)/sqrt(sum(w^2))
> zpoo
[1] 1.709151
> 1-pchisq(zpoo*zpoo,1)
[1] 0.08742297
As you can see the results are almost identical to the previous obtained with
inverse variance pooling.
240 CHAPTER 10. META-ANALYSIS OF GWA SCANS
Chapter 11
Small data set ’srdta’, which is part of the GenABEL-package library, will be
used in this section. Start R and load the GenABEL-package and the data with
> library(GenABEL)
> data(srdta)
241
242 CHAPTER 11. ANALYSIS OF SELECTED REGION
Appendix A
Importing data to
GenABEL-package
This section is outdated. By far the most used way is through the
TPED
As described in section 4.1, the GenABEL-package [Link]-class consists
of phenotypic data frame and an object of [Link]-class, which contains all
genetic data. To import data to GenABEL-package, you need to prepare two
files: one containing the phenotypic, and the other containing genotypic data.
The phenotype file relates study subject IDs with values of covariates and
outcomes. In the phenotypic data file, the first line gives a description (variable
name) of the data contained in a particular column; the names should better
be unique, otherwise R will change them.
The first column of the phenotype file must contain the subjects’ unique
ID, named ”id”. The IDs listed here, and in the genotypic data file, must be
the same. It is recommended that the id names are given in quotation marks
(see example below), which will save you a possible troubles with e.g. leading
zeros.
There also should also be a column named ”sex” and giving sex information
(0 = female, 1 = male). Other columns in the file should contain phenotypic
information.
Missing values should be coded with ”NA”; binary traits should have values
0 or 1.
All subjects present in the genotypic files must be listed in the phenotypic
file as well, because sex information provided by the phenotypic file is an essen-
tial part of the genotypic QC procedure.
An example of few first lines of a phenotype file is as follows:
This file tells us that, for example, person 325286 is female (0 in second
243
244 APPENDIX A. IMPORTING DATA TO GENABEL-PACKAGE
column), and she has ”1” (usually this means a ”case”) value for the trait
”bt1”, so on. Person 289982 has measurements only for sex, age and qt1, while
the other measurements are missing (NA, Not Available).
If you need to add phenotypes to an already created [Link]-class, you
can use the [Link] function. This function allows you to add variables
contained in some data frame to the existing data@phdata object. The data
frame to be added should contain an ”id” variable, identical to that existing in
the object, and should not contain any other variables with names identical
to those that already exist.
The second file you need should contains genotypic data. As described in sec-
tion 4.1 (”General description of [Link]-class”, page 79), GenABEL-package
[Link]-class contains different types of information. For every SNP, informa-
tion on map position, chromosome, and strand should be provided. For every
person, every SNP genotype should be provided. GenABEL-package provides a
number of function to convert these data from different formats to the inter-
nal GenABEL-package raw format. We will first consider our preferred format,
which we informally call ”Illumina”-like.
> [Link](inf="RData/[Link]",
+ out="RData/[Link]",
+ strand="file")
Here is the content of the converted file ”[Link]” – internal raw data
representation:
Note the option strand="file" – it is telling GenABEL-package that strand
information is provided in the file.
At this moment, you can load the data into GenABEL-package. Assume
that the phenotypic file described above is called ”[Link]” and the converted
genotypic file in the raw GenABEL-package format is called ”[Link]”. You
can load the data using the command
> df <- [Link](phe="RData/[Link]",
+ gen="RData/[Link]",
+ force=TRUE)
ids loaded...
marker names loaded...
chromosome data loaded...
map data loaded...
allele coding data loaded...
strand data loaded...
genotype data loaded...
[Link] object created...
assignment of [Link] object FORCED; X-errors were not checked!
The option ”force=TRUE” tells that GenABEL-package should load the data
even if it fins sex errors.
You can inspect the loaded data; let us first look into phenotypic data by by
> df@phdata
> [Link](df@gtdata@strand)
> [Link](df@gtdata@coding)
In a real Illumina file, a coding on the TOP strand is supplied. Then, the
file will normally look like
name chr pos "cd289982" "cd325285" "cd357273" "cd872422" "cd1005389"
rs1001 1 1235 AA AG AG AA GG
rs6679 9 2344 GT GG GG TG GG
rs2401 22 3455 AA CC CC CC AC
rs123 X 32535 TT GT TT TT TT
rs6679 XY 2344 GT GG GG TG GG
rs876 Y 23556 00 00 TT GG TT
mitoA1 mt 24245 AA CC 00 00 00
and the conversion command will be
> [Link](inf="RData/[Link]",
+ out="RData/[Link]",
+ strand="+")
In this particular data set, after conversion, the ”+” strand will actually mean
not ”forward”, but TOP – something you should remember for this particular
data. The resulting file will look like this:
You can load the data with
> df <- [Link](phe="RData/[Link]",
+ gen="RData/[Link]",
+ force=TRUE)
ids loaded...
marker names loaded...
chromosome data loaded...
map data loaded...
allele coding data loaded...
A.2. CONVERTING PLINK TPED FILES 247
> [Link](df@gtdata@strand)
> [Link](df@gtdata@coding)
We can see that the genotypes are identical to ones we imported previously,
as should be the case:
> g0 == g1
1 rs1001 0 1235 A A A G A G A A G G
9 rs6679 0 2344 G T G G G G T G G G
22 rs2401 0 3455 A A C C C C C C A C
X rs123 0 32535 T T G T T T T T T T
XY rs6679 0 2344 G T G G G G T G G G
Y rs876 0 23556 0 0 0 0 T T G G T T
mt mitoA1 0 24245 A A C C 0 0 0 0 0 0
Obviously, a separate file is needed to keep correspondence between geno-
types and IDs. This file emulated standard pedigree file without a header line.
The file, conventionally called a TFAM-file, should contain six columns, cor-
responding to pedigree ID, ID, father, mother, sex, and affection. Only the
second column is used by GenABEL-package – please make sure you use unique
IDs. Consequently, it does not matter what pedigree ID, father/mother, sex, or
affection status you assign in the file – the real information is coming from the
phenotypic data file. The TFAM file for our data will look like this:
1 cd289982 0 0 1 0
1 cd325285 0 0 1 0
1 cd357273 0 0 1 0
1 cd872422 0 0 1 0
1 cd1005389 0 0 1 0
You can convert the data from PLINK TPED format to the GenABEL-package
format using command [Link]:
> [Link](tped="RData/[Link]",
+ tfam="RData/[Link]",
+ out="RData/[Link]",
+ strand="+")
ids loaded...
marker names loaded...
chromosome data loaded...
map data loaded...
allele coding data loaded...
strand data loaded...
genotype data loaded...
[Link] object created...
assignment of [Link] object FORCED; X-errors were not checked!
A.3. CONVERTING LINKAGE-LIKE FILES 249
> [Link](df@gtdata@strand)
> [Link](df@gtdata@coding)
We can see that the genotypes are identical to ones we imported previously,
as should be the case:
> g0 == g1
As you can see, this file misses header line, and information what are the SNP
names, position, etc. should be provided in a separate MAP-file. GenABEL-package
accepts map in Merlin format, and an extended format. A map in Merlin format
consist of header line, giving column names, and three columns with chromo-
some, name and position information, for example:
> [Link](pedfile="RData/[Link]",
+ mapfile="RData/[Link]",
+ out="RData/[Link]",
+ strand="+")
ids loaded...
marker names loaded...
chromosome data loaded...
map data loaded...
allele coding data loaded...
strand data loaded...
genotype data loaded...
[Link] object created...
assignment of [Link] object FORCED; X-errors were not checked!
We can inspect the genotypic data and check that conversion results are
identical to previous runs with
> [Link](df@gtdata@strand)
> [Link](df@gtdata@coding)
> g0 == g1
If you are willing to import strand information, you can make use of the
extended map format. In this format the strand information is added to the
map-file:
chr name pos strand coding
1 rs1001 1235 + AG
9 rs6679 2344 + TG
22 rs2401 3455 + AC
X rs123 32535 - GT
XY rs6679 2344 - GT
Y rs876 23556 + GT
mt mitoA1 24245 - AC
The data can be converted to the internal GenABEL-package format with
> [Link](pedfile="RData/[Link]",
+ mapfile="RData/[Link]",
+ out="RData/[Link]",
+ strand="file")
Note that option strand==file was used to specify that the extended map
format should be used. The data can be loaded with
ids loaded...
marker names loaded...
chromosome data loaded...
map data loaded...
allele coding data loaded...
strand data loaded...
genotype data loaded...
[Link] object created...
assignment of [Link] object FORCED; X-errors were not checked!
We can inspect the genotypic data and check that conversion results are
identical to previous runs with
> [Link](df@gtdata@strand)
> [Link](df@gtdata@coding)
> g0 == g1
GenABEL internals
> library(GenABEL)
255
256 APPENDIX B. GENABEL INTERNALS
object
[Link]-class
All GWA data
object@phdata
[Link]-class
Phenotypic data
object@gtdata@nsnps
integer
# of SNPs in study
object@gtdata@nids
integer
# of people in study object@gtdata@snpnames
object@gtdata vector of character
[Link]-class IDs of study SNPs
object@gtdata@idnames All genetic data
vector of character
IDs of study participants
object@gtdata@chromosome
vector of character
object@gtdata@male Chromosome label (1, 2, ... X)
vector of integer
Sex (1=male, 0=female)
object@gtdata@map
object@gtdata@coding vector of double
[Link]-class SNPs map positions
SNP allele coding (”AG”, “AC”, ...)
object@gtdata@gtps object@gtdata@strand
[Link]-class [Link]-class
Genotypic data in compressed format SNP allele strand (”+”, “-”)
Figure B.1: Structure of [Link]-class. In every box, first line contains the
object and slot names, second line describes the class of this object, and third
line describes what information is contained.
B.1. INTERNAL STRUCTURE OF [Link]-CLASS 257
> srdta@gtdata@nsnps
[1] 833
Thus, 833 SNPs were typed in the study. You can access information stored in
any slot in this manner.
You may want to read the general GenABEL-package man page using help(GenABEL).
To see help on [Link]-class, you can use help("[Link]-class") (mind
the quotation marks!).
258 APPENDIX B. GENABEL INTERNALS
Summary:
• An object of some class has ”slots” which may contain actual data or
objects of other classes. The information stored at a particular slot of
an object can be accessed by command object@slot.
• GenABEL-package uses special data class, [Link]-class, to store
GWA data.
Bibliography
259
260 BIBLIOGRAPHY
Ruiz-Narvez, E., 2005 Is the ala12 variant of the pparg gene an ”unthrifty
allele”? J Med Genet 42: 547–550.
Sasieni, P. D., 1997 From genotypes to genes: doubling the sample size. Bio-
metrics 53: 1253–1261.