Hey guys, in this video I'm going to go over how you can do a GWAS study in plink. For this video,
I'm going to use a public data set and kind of walk through how I would analyze it and that
public data set is available to download here and I will put a link to this Google Drive link
in the description box below. And as many articles and code as I go over as possible,
I'll try to put everything in the description box below. This data comes from this Webster et al.
paper and this paper was basically doing an analysis on Alzheimer's disease and specifically
something that's called late-onset Alzheimer's disease, which is the most common type of
Alzheimer's disease. And this paper did multiple types of analyses. It did GWAS and it did some
transcriptome stuff that I'm not going to go over in this video but if you download the data set,
it comes with a readme file that has a description of all the files that the folder comes with. For
GWAS, you want to use a dot map and a dot ped file as the inputs and plink can read that just
as normal standard inputs. It can read in some other type of files as inputs as well but this
is a very common type of input for doing GWAS. And optionally you can also read in a dot covar
file. ln this case, this study came with a dot covar file that has basically other variables,
which are mostly just phenotypes that you could also do association testing with. I'm not going to
really use this dot covar file in this video. What we're doing instead is basically what's called a
case-control study. I'm going to have a response variable of someone either having the diagnosis,
so having Alzheimer's disease and being therefore a case, or being a healthy control. That's my
phenotype and then I'm going to do association testing between the phenotype and the SNPs in the
genotyped data that I have for all my subjects. With those inputs, I'm going to use plink to do
my actual GWAS analysis. For this video, I'm going to just walk through an analysis of this data that
I already did. I have this folder here and when I go in to this folder, this has output from plink
from a bunch of analysis and pre-processing and quality control that I already did. I had to do
this for a homework problem. And let me just walk through the basic steps of how I would analyze
this data. On my computer, I have plink version 1.9 and 1.07, the original version, downloaded
on my computer. I think I ended up not using any functions that are unique to 1.9 and I think that
I could just use 1.07 for my analyses and I liked that I downloaded 1.07 because it comes with a GUI
that is not in the 1.9 download called g-plink and I don't really use the GUI when I did the analysis
that much but I just think it's useful for looking at their results. When you first open the GUI,
it will just look like this and you have to start a project. A project is just a folder that you're
going to use for all your analysis. If you didn't have something already loaded in like I do here,
you just go to open and then basically find a folder that you want to use on your local
computer. I already have a project here that has all my previous analyses. Let me explain
basically what this window is showing you. When I opened my project, this goes to the folder that
has all my analysis already in one folder. This folder originally just had the inputs,
the Alzheimer's disease GWAS dot ped and the dot map and the dot covar file. Those were my
beginning inputs and then let me explain how I personally used the GUI. The GUI to me was not
that useful for running commands in plink because plink actually is pretty straightforward to run
in the command line window but I think it really helps with keeping everything organized with all
the analyses that you run. For example, here this shows all the files in my folder, which seems like
a lot but then here it shows me each command. Each command might produce--one command, for example,
might produce ten files as output but here it shows you just the commands that you run for
one project. And the green checkmark means that the command ran successfully. And then when you
click each one, down here in this window it will show you the log file. It will print out the log
file that shows you a little explanation of what was run and if this was a pre-processing step,
for example, it will tell you how many SNPs were removed. The first thing that I did was I tested
just inputting the data just to see if it read the file correctly. And it correctly said that there
were 364 subjects and it correctly read the cases and the controls already from the data files. That
was the first thing that I ran and it also tells you at the top what flags you ran. That to me is
the real reason why I liked using the GUI because I think it helps you see your analysis steps more
easily. Now let me go over how you actually run a command in plink. The way I did it was,
for example, I started with the ADGWAS or Alzheimer's disease GWAS dot ped and dot map
files, reading those in and also the sample covariance file. If you want to use the GUI,
you have the options to use the flags by picking them using the GUI. Or what I did
was I just would go to data management, generate file set, then I would go to standard input and I
would pick the file input that I want to use in my analysis. The first one that I wanted to use
was ADGWAS and then this area here is the name of what you want to output as. For every step,
I named it something else and I tried to give it a name that made sense to what flag I was running or
what command I was trying to run. I could run a command called test3 as output and then I'd
click OK and then here a window pops up that says plink command. This will actually give you what's
going to be run as like your command line. It gives you the file and we picked ADGWAS. Then
it automatically will output it as a set of files that are called test3. And I didn't put any flags
in here, so it's not giving me any other flags besides recoding but here is where, if I wanted
to do something, I would just add a flag and type whatever and I would give it a description here of
what I ran. And the description that you give here will come out on this side of the output. And so
all these commands were just different steps in my pre-processing, quality control, and analysis that
I did. And they're all basically just run using different flags in plink. For me I first just
tested inputting a file and it did that correctly. Then I filtered for Hardy-Weinberg equilibrium at
a p-value .05. That's just using the flag - -hwe .05. And for case-control studies it automatically
just filters--it filters for the complete data set. You can have cases and controls together
but it just does the testing of Hardy-Weinberg equilibrium only for the control cases, which
is what you want to only test on. Then I filtered for a minor allele frequencies. The geno flag and
the mind flag both test for missingness. If you have SNPs that are missing from too many subjects,
or if you have subject data that's missing, you can filter for that at a certain percentage. I
checked the gender of what they were coded as to make sure it aligned with the chromosomal data.
Then I filtered for only using autosomal SNPs using the chromosome 1 through 22 flag. Then
I filtered for cryptic relatedness using the min flag and I did that at 20%. And that was most of
the quality control filtering that I did. After I did that, I had about 34,000 SNPs remaining after
all the filtering that I did. Then, again before I did the association testing, I wanted to account
for something that's called population structure. Filtering for cryptic relatedness is one way of
accounting for a problem in GWAS that's called population structure. And population structure
is usually something that you have to check for to see if it's affecting your GWAS and to account
for. It's basically kind of trying to explain certain variance that has nothing to do with what
you're trying to study. And there are multiple ways of doing this in plink, but the way that
I'm going to show you is by doing the cryptic relatedness filtering, that's the first thing,
and then also doing a PCA. If you do a principal component analysis on your data, then you can see
what principal components seem to be important for accounting for a number of variants in your
model. And you include that as covariates in your association test. The basic analysis step
is I'm going to check for population structure to see if it's affecting my data set and to do that
I'm going to switch to R and I'm going to test what's called a genomic inflation factor. And
if that factor is above 1, that suggests that you have some population structure in your data. Then
I'm going to add a certain number of principal components as covariates to my association test.
Let me switch to R. In R, I wrote this code and I'll try to put it in the description box below
but I'm going to load in this dot eigenvec file, which is produced after you run the PCA flag in
plink. That file has a list of eigenvectors for every subject and by default it produces the first
22 eigenvectors. And then I'm just going to plot the first 5 eigenvectors using all of this code
and I'm going to plot them as pairs, basically kind of like a scatter plot matrix. This will give
you one idea of your population structure. For example, if you look at the relationship between
principal component 1 and principal component 2 for all the controls and Alzheimer's disease
patients, it looks like there's a separation. It looks like there are two clusters based on the
first principal component. It looks like there's one cluster with a value near 0.15 and it looks
like there's a second cluster near -.05. But if you look at the third cluster compared to the
second, the fourth compared to the third, and the fifth compared to the fourth, there seems to just
be one cluster. There's not really a separation. And for this particular dataset, if you go
back and read the original paper, they use just European or basically white people. In a lot of
GWAS studies, population structure might be a big deal because people could be from any ethnicity
but it's a little bit less of a deal usually if they're all European or of the same race. For my
particular analysis, I checked these plots to see what formed clusters and I came to the conclusion
that only the first principal component seems to be separating these subjects. But you can test
this more officially using a screeplot. That can also tell you how many principal components are
important for explaining variance in your model and this is a screeplot. The screeplot shows again
that the first principal component is definitely significant and the elbow seems to be here.
Sometimes people say to include the elbow. The elbow is basically where the data turns but when
I learned about screeplots, I learned that you don't include the elbow. This seems to be a steady
decrease and so this one, you could include it or you could not include. It in my case, I didn't
include it. And let me show you how I estimated the genomic inflation factor, which is maybe a
more legitimate way of deciding how many principal components to include or not include. I first ran
the analysis not using any principal components as covariates and then I wanted to test the genomic
inflation factor. I have this whole function printed out here. I didn't write this function.
This function came from a package, but when I tried to load or install the package, it said
that it was not available in this version of R. I just googled what the function was and I found
the function. This function runs just fine in my version of R but I couldn't load the whole package
for some reason. I just copied the function, which will estimate the genomic inflation factor,
which is also known as lambda. And then I'm going to run the function. The function tells me that
there's a slight inflation. There's a slight population structure problem because the value
is more than one. And a paper that I read said that if the value is less than or equal to one,
then you don't have to account for any population structure in your data, or your basically your
data is fine to run an association test on. Because there's a slight inflation to the factor,
I tested it again using just one principal component based on my screenplot and analysis of
the scatter plot matrix. And that was this file. And when I test the genomic inflation factor using
an analysis with the first principle component, it takes like a half a minute to run but now it's
telling me that the inflation factor is less than one. It's giving me a lambda estimate of
0.69. That's another way of confirming that I've accounted enough for the population structure.
If this number was still above 1--which I doubt it would be because it will already was so close
to 1--if this value was still over 1 after using just the first principal component,
then I would probably go back and include the first two principal components in my analysis.
That's dealing with population structure and now let's get into what actual association test I did.
If you want to include covariance in your analysis like the PCA principal components, then the type
of analysis that you probably should do would be a logistic regression. For the logistic regression,
you're using the phenotype or whether someone is a case. An Alzheimer's disease patient or case or
control as your response variable and you're using the SNPs that have been filtered for everything
and quality controlled plus covariates as your independent variables. Your coverts include the
principal components and all the SNPs that you want to test the association with your disease
that you're studying. Let's see, for PCA 1, this is how I ran the analysis. I adjusted--so this is
including multiple comparison correction--allow no sex. I already filtered for only having autosomal
chromosomes SNPs but this would additionally filter that way. I included this flag for
confidence intervals for 95% confidence intervals. I'm including a covariance of principal components
and I say to include only the first principal component using this flag. And then I say I want
to do a logistic regression. That's this flag and this PCA 1 will produce results. Let me find PCA
1 dot association test dot logistic dot adjusted. This will give you your final output. And the nice
thing about running the adjusted flag is that it will order all the data. Your most significant
SNPs are at the top and then it will give you a bunch of test statistics. This will give you
the unadjusted p-values and this will give you the adjusted p-values based on false discovery
rate. Really only the first two SNPs seem to be significant and this will give you that
information. If you don't adjust for multiple comparisons, then it will produce this file PCA
1 dot association test dot logistic. And if you look at it, it gives you different information
from the adjusted file but what's annoying is that it's not ordered. It doesn't order the most
significant--it's ordered but it's not ordered by significance. You have to search for the SNPs
that were considered important in this file. And if I do a google search of the first SNP
that it says is important and I go to SNPedia, this tells me not surprisingly that this SNP is
associated with Alzheimer's disease. If you have a certain polymorphism or variation of alleles,
you have a three times increased risk for Alzheimer's disease. That's not surprising
considering this is Alzheimer's data. This GWAS found an association with Alzheimer's for this
SNP and also this SNP as well. That's it for this video and thank you guys for watching.
*chiptune music*