An introduction to the statistics behind the most popular genomic data science projects. This is the sixth course in the Genomic Big Data Science Specialization from Johns Hopkins University.

Loading...

From the course by Johns Hopkins University

Statistics for Genomic Data Science

115 ratings

An introduction to the statistics behind the most popular genomic data science projects. This is the sixth course in the Genomic Big Data Science Specialization from Johns Hopkins University.

From the lesson

Module 3

This week we will cover modeling non-continuous outcomes (like binary or count data), hypothesis testing, and multiple hypothesis testing.

- Jeff Leek, PhDAssociate Professor, Biostatistics

Bloomberg School of Public Health

>> This lecture is how you calculate p-values and correct for

Â multiple testing in R.

Â So the first thing I'm going to do is I'm going to set up my plotting parameters,

Â just like I do in all the other lectures.

Â And then I'm going to load the packages that we need here.

Â The main ones we're going to be looking at are the limma, edge, gene filter,

Â and q-value packages.

Â So the data set I'm going to be using is the bottomly expression data set.

Â And so when I do that, I'm going to take out the expression data,

Â the phenotype data and the feature data so that I can model them individually.

Â And then I'm going to filter out the lowly express genes.

Â I'm going to perform a log transform.

Â So now what I can do is I can calculate p-values in a couple of different ways.

Â One is If you're using the gene filter package and

Â I just calculate f stats, using the real f stats function.

Â It automatically calculates parametric p-values for you.

Â So I can just look at the p-values directly.

Â So here we see a set of p-values.

Â One thing that you should expect to see is a spike of p-values near zero and

Â then flat out to the right.

Â So this isn't quite that, so that leads us to suspect that our model is wrong

Â somehow, maybe we missed an adjustment variable or something like that.

Â But overall, that's a very quick way to calculate p-values.

Â Another way that you can do that, is you

Â can do use the edge package to calculate the p-values for the not moderated model.

Â And so here, what I have to do is I build this study.

Â Using the express passing of the expression data,

Â telling you what group variable we want, strain in this case.

Â And then in this case let's say, we also want to adjust for the lane number.

Â So it builds the study then we can perform the differential expression analysis

Â using the likelihood ratio test on that study and calculate q values.

Â So then, we can look at the p-values that come out of that analysis by

Â looking in the q value object at the p-value argument.

Â And so here we see even more sort of strongly conservative p-value.

Â So you got after adjusting, so

Â that we still haven't probably gotten the model quite right.

Â They suggest that very little signal in the data set and that the confounding

Â due to the lane is not necessarily being enough to take that into account.

Â If we want the moderated p-values from the moderated statistics, the way that we

Â can do that is we can build the model matrix with the strain the lane number.

Â And then we can adjust here or fit the model

Â from limma, using the lmfit command.

Â And then we can shrink the model using the eBayes command.

Â To get the p-values again, you're going to use the top table function.

Â So to get the limma p-values, we're going to use the top table and

Â we're going to tell it to apply the top table to that eBayes limma object.

Â We're going to tell we want every single one of the p-values out,

Â there's numbers it's like the number of things through top things to report.

Â We're going to say the same is the dimension of data set and

Â then the element that we want out of there is the p-value.

Â So we're going to extract that part out and

Â then we can look at a histogram of the limma p-values as well.

Â And you can see they also have this sort of strange distribution.

Â To this case it seems to be regardless of the method that we use,

Â we see to get a little bit of a strange p-value.

Â So this suggests that like we might be missing a variable or

Â our modeling strategy might not quite be right.

Â Another way that you can calculate p-values is empirically.

Â So again if we're going to do some randomization we need to set a seed.

Â And then let's say we're going to do 1000 random simulations.

Â You can calculate the t stats using the gene filter,

Â rowttests function by passing at the data matrix and the strain.

Â And then you can create a matrix here, null t statistics.

Â So here, that matrix is NA to start, so these are the permuted statistics and

Â we haven't gotten yet.

Â So we're going to just say, let's make it full of missing values.

Â And it's going to have the number of rows equal to the number of rows of the data

Â set and the number of columns equal to the number of times you're going to permute.

Â So now we have our t stat, and our permuted t stats and

Â just to make it easier, I'm going to define.

Â The strain variable to be the strain from the p data.

Â So then what I'm going to do is I'm going to take this code which basically

Â loops over these 1,000 loops.

Â Every time on every one of the 1000 loops,

Â it assigns a strain zero variable to be a sample of the strain variable.

Â So what does that mean?

Â Every time it loops through.

Â it resamples, it rescrambles, or repermutes the strained data.

Â Then it recalculates the t statistics by applying the strained zero, so

Â it's basically using the permuted labels when it's calculating the null statistics.

Â So that's going to take a second cause the answer is round to a 1000.

Â Then you can use the Mp valve function from the q value package to calculate

Â the imperial p-values, which are basically the p-values from permutation.

Â So I pass it the original observed statistics and

Â I pass it the matrix of the statistics, and you can do one of two things.

Â You can either have each gene be compared to only the permuted statistics for

Â that same gene or you can pull the statistics for all the genes

Â together when you're calculating the sort of the permutation distribution.

Â So once I have the empirical p-values, I can make their distribution as well.

Â So it's the same sort of thing,

Â it's very conservative that we've been seeing over and over again.

Â So, then the next thing that I want to do is after I calculate those p-values.

Â I want to adjust for multiple testing.

Â So, that'll be the next video.

Â Coursera provides universal access to the worldâ€™s best education,
partnering with top universities and organizations to offer courses online.