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

93 ratings

Johns Hopkins University

93 ratings

Course 7 of 8 in the Specialization Genomic Data Science

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 1

This course is structured to hit the key conceptual ideas of normalization, exploratory analysis, linear modeling, testing, and multiple testing that arise over and over in genomic studies.

- Jeff Leek, PhDAssociate Professor, Biostatistics

Bloomberg School of Public Health

So this is the second lecture on exploratory data analysis.Â And so I'm going to go through a little bit more quickly this time the set up justÂ to get up and going.Â But I'm going to set up the colors like I did in the previous lecture.Â I'm going to set the parameter forÂ the plotting parameter so that it looks like I'd want it to as well.Â And then I'm going to load all the packages that we need to load.Â And then after I do that I'm going to load in the data set and get us up to speed.Â Okay.Â So if you want to see more about how I did all that and what I'm doing there,Â you can watch the first lecture on exploratory data analysis.Â So, after we check sort of to make sure that all the certain dimensions match, andÂ that we're not missing any values or anything like that,Â the next thing I do is I make lots of plots.Â So the first kind of plot that you can make is a box plot.Â And so if I make a box plot of say the first set of values, I'm going to look atÂ the expression data, the first column of that data set and I make a box plot.Â You can see that most of the values are down here at zero, soÂ I might do some kind of transform to the data.Â I might try to take the log transform of the data.Â

And then here I'm going to add one so that the values won't be messed up.Â And so it didn't really help me this time, but you, in general,Â can sort of make different transforms to try to see if the data look good.Â You can also plot more than one value at once, so here I'm going to do thatÂ same box plot, but now instead of just selecting out the first column,Â I'm going to box plot apply to the entire matrix.Â And so when I do that, I actually get one box plot per sample, soÂ one box plot per column of that data set.Â And then I can set the color to be a color that I like.Â And then, in order to not have all those outlying points,Â I can set range equal to zero, and so then it will make this sort of whisker extendÂ all the way out to the most extreme outlying point.Â So here I can already see again that the data is pretty skewed forÂ all these different samples.Â And you can see it because most of the values are squished down here near zero.Â The other thing that you can do is you can make histograms.Â So I'm actually going to show two histograms.Â And if I want to show plot side by side, I can use the par(mfrow=c(1,2)).Â This is basically saying set up the screen soÂ that it has one row and two columns of plots.Â So it's side by side plots.Â So I can make a histogram of the values from the first sample.Â So again I'm going to do this transform here because IÂ think it makes it a little easier to see.Â And then I'm going to set the color equal to two, soÂ this is going to make this nice blue histogram.Â And so you can see here right away that almost all the values are equal to zero.Â And then you see some values out to the right there.Â And so, then, I can make that same plot.Â But for the second sample, and so, when I do that,Â

you can see that it has a very similar distribution.Â It also has many zero values, and then some values out the side, there.Â So, that's one way you can start looking sample by sample, butÂ sometimes it's hard to see a lot of samples that way.Â So if you wanted to see a bunch of samples,Â you want to be able to overlay the plots on top of each other.Â So here I'm going to set it to be back to just a one by one plot soÂ it's a little bit easier to see.Â And so, the first thing I could do, is I could make a density plot.Â And so the density plot is going to basically show the distribution ofÂ values sort of similar to a histogram but with a line plot.Â And so one way that I can do that is I'm going toÂ

apply the density function to that first sample.Â So here I've got the first sample, I'm going to take the log transform ofÂ the first sample, then I'm going to calculate a density of that sample.Â And then I'm going to make the color to here.Â So here I can see that density so it looks a little bit likeÂ the histogram I've got the X values here and then I've got like how frequentlyÂ they appear on the Y axis and so you can kind of see this distribution here.Â And so the next thing that you could do is you could add on top of that andÂ you could start layering other values on top so if I just plotted the next value,Â like if I just typed plot the same plot.Â So I pressed up to get the command back and I pressed plot.Â

The second column of that data set it would just overwrite the plot.Â So instead of doing that,Â what I'm going to do is I'm going to use the lines command.Â So the lines command will let me overlayÂ

another plot on top of the plot that I just had there.Â So I'm going to do the second sample now, andÂ I'm going to give it a different color.Â

So now I can see, you know, plot one is in blue.Â Sorry, sample one is in blue, sample two is in pink, andÂ I can overlay a bunch of samples this way so I can see if the distributions are allÂ similar or if I see any kind of bulk changes in the distributions.Â That can be a sign that there's an artifact going on.Â So that's a plot that I usually make to check.Â The other thing that I do to check to make sure the samples are sortÂ of consistent is, I make what's called a q-q plot.Â So, if I do a qq plot of the first sample, so here, doing this transform again.Â I'm going to do the same thing for the second sample.Â

I can see a bunch of data points here and so one thing to keep in mind is thatÂ when you make it this plot now, this q-q plot is making one dot for every gene.Â And so, or, sorry, for every quantile of these two distributions.Â And soÂ it depends on the number of quantiles that it has to calculate how long that'll take.Â

And so for example this dot right here this says this is say the 5th percentileÂ so this is the 5th percentile for the second sample is on the Y axis.Â And the fifth percentile for first samples on the x axis.Â So we can see that it's above the 45 degree line here and soÂ you can see that the second sample has a higher fifth percentileÂ than the first sample so it has higher values for low values.Â If you want to be able to see that a little more clearly you canÂ add a 45 degree line.Â And one way you can do that is with this abline command, abline.Â And you can tell it, you use this intercept and this slope andÂ so you can see here this has an intercept of zero and a slope of one.Â That's the 45 degree line.Â And so, if I add that on top so there's the 45 degree line,Â you can see here the quantiles are a little bit larger forÂ the second sample down low and they're a little bit lower up high.Â And so you can kind of see how the two distributions compare to each other.Â The other thing you can do when comparing samples,Â is you can make what's called an MA or a Bland-Altman plot.Â So here I'm going to take the difference between the two samples andÂ I'm going to make that the Y axis soÂ I'm going to take the difference between sample one and sample two andÂ then I'm going to add the two samples up.Â

I'm going to make that the X axis.Â So I'll explain that in a minute.Â So now if I plot on the X axis the sum of the two samples andÂ on the Y axis the difference of the two samples.Â

So on the X axis we have the sum of the two samples.Â So basically moving from left to right you get lower expression orÂ lower counts to higher counts.Â And on that Y axis, you're to take the difference.Â So if it's at zero, that means there's no difference between the two samples.Â So you can see for example trends here.Â You can see as you get higher and higher accounts there's sort of a trend thatÂ appears to be that the samples get closer and closer together soÂ each dot here is one gene and soÂ I'm just taking the difference between the two samples for that gene.Â So this MA kind of plot people make very often you want to see that it's,Â especially for technical replicates,Â there's some kind of replicates that should be similar.Â You want to see it centered on the zero line, andÂ you'd like to see it with low variability andÂ no trends that are dependent on the total number of counts for those samples.Â And so, that's a way that you can sort of make those plots to compare them.Â Now, the next thing that you can do is,Â is if you want to be able to make the plots for.Â We saw these sort of box plots, and many of these plots are very skewed.Â And so, one thing that you can often do to make the plots a little bit better,Â especially for count-based data.Â You often need to remove the low expression or the low countÂ features to be able to really be able to see the distribution of the data.Â So to do that I'm going to make the data set a data frame soÂ that I can use the dplyr filtering commands.Â And I'm going to filter the data set.Â So I'm going to take that data print here,Â I'm going to apply the filter command to it, and I'm going to say filter out,Â

keep only the rows that have a mean greater than one.Â So what is this doing?Â It's taking the mean for each row of the data set.Â It's going to say is that mean greater than one.Â If it is greater than one it's going to keep it after I filter it here, soÂ now the dimensions of this new data set are smaller.Â I've removed a large number of the features.Â I only have about 12,000 left, andÂ now I can make that same box plot that I did before.Â

So again, I converted it to a data frame so I could do the filtering.Â Now I have to convert it back to a matrix so I can do the plotting,Â there's a little bit of a difficulty with this filtering approach.Â

What did I do here?Â Oh, I've got edata here instead of a data, there we go.Â So now I've got the box plot one for every sample and soÂ you can see the distribution a lot better now, so basically I removedÂ all those like they were a ton of values that were just equal to zero.Â I removed all of those, and said this is the distribution of the remaining values.Â The values that for the genes that have an average greater than one on this scale.Â And so you can do these sorts of transforms and these sorts of filtering toÂ basically get an idea of what the real distribution of the data will look like.Â

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