1. Home
  2. Explore
  3. Statistics
  4. Introduction to Statistics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Introduction to Statistics

Transcript

Welcome everybody to this series of lectures on statistics . Everything you always wanted to know about statistics bu were afraid to ask To answer the first question that popped up. Yes. All these lectures will be recorded I'm recoding it right now. And there'll be shared via DAG website. We'll put them here at this URL here. When the recording is ready, together with handouts, lecture slides. Let me introduce myself. My name is Mark Gierlinski I'm part of a data analysis group at

University of Dundee School of Life Sciences. The other members of this group is James Abbott . And we collaborate on various types of projects with people across SLS and also outside. Sometimes it maybe various types of projects include RNA-seq, proteomics, various other types of data analysis or even modelling. If in future you need help with data analysis with statistics, we are here to help. And I mentioned this already, that lecture slides and videos will be available at this address.

There will be maths in this lecture. Don't feel intimidated. You can't do statistics without maths. I will try to keep maths accessible. But there will be some complicated concepts introduced in lectures. And it would require some effort to understand them. Please do not run away after the first lecture, I promise it will be worth sitting through all of them. This is the outline of all the lectures. There will be 14 of them. I'm not sure whether it's 13 here. 14 lectures.

The first few, the first four lectures we will focus on the uncertainties and error analysis in biology. And I will tell you something about how to make a good plot about data presentation. And the rest is broadly covering statistical testing, various types of tests like t -test or ANOVA . I will also talk about statistical power, which is an important topic, and multiple test corrections which are often forgotten. And then linear models and a closing lecture about what's wrong.

We've p-values. Today, probability distributions. And I will start with this quote from Stephen Jay Gould. Misunderstanding of probability might be the greatest of all general impediments to scientific literacy. Take this to heart. Understanding of probability and statistics is quite important, not only in science but also in everyday life. Understanding COVID data that is flooding us through the media. Without basic understanding of statistics,

you might misinterpret things as some journalists do. For example. Consider this very simple example. You, you estimate bacterial concentration using a spectrophotometer. You put your sample here, in this vial, you place it in the instrument. And recent instrument measures OD600 , which is the optical density at 600 nanometers, which is proportional to the concentration of bacteria in this sample. And now you do this experiment in six replicats. That means you take

a sample or aliquot from your culture. You put it in a vial and you measure it, and you do it again, again and again. And every time you repeat your experiment, you get a slightly different value. You measure the same thing. You repeat the experiment under the same conditions several times. And every time you do this, you get a different result. This is natural. This is nothing to be worried about this is everyday life, everyday practice in biology and all experimental sciences.

Experimental result is a random variable and it follows a certain probability distribution. These two concepts: random variable and the probability distribution. Random variable is something that gives you random numbers, which is a bit of a tautological definition. Random variable is a very strict mathematical concept, very well-defined in mathematics, but I'm not going there. In real life. It is related to experiments and measurements. Before you do an experiment.

And in this case is a very simple experimental throwing two dice, you don't know what sort of outcome it's going to be there. But you know what, what possible outcomes are that are all numbers. If you calculate the sum of these two dice, the outcome is a number between 2 and 12 and lots of possibilities. After you have done your experiment, all this sea of possibilities collapses to just one number, let's say number four. Experiment is a realization of a random variable.

Random variable gives you a possibilities in experiment. From all possible values, one is chosen. And now by repeating the experiment multiple times, you can probe this distribution of possibilities. And you can reconstruct it empirically and infer about uncertainty of your result. So you can think of an experiment is a random number generator. Generally speaking, there are two types of random variables, discrete and continuous. Discrete variables give you, well, a certain set of

finite set of outcomes could be a number, like from dice, could be a categorical outcome. For example, small, medium, large. Could be number of mice, for example, five. You might argue that this is not a random number because once you have five mice, you measure them, you count for 1-2-3-4-5. Okay? It's not going to change if you count it again. But in some experiments, for example, survival experiments. You see after certain treatment how many mice, for example, survived after treat meant.

And that will be a random number in a way that if you repeat your experiment under the same conditions, you might get a different number, five, maybe four, maybe six at a different realization of this experiment. Continuous variable as something like a weight of a mouse or height of a person is just a real number without any specific values, fluorescent marker luminosity or protein abundance, but many other possibilities. So what is probability distribution? Coming back to our dice,

there are ten possible outcomes, but each outcome, each sum, can be obtained by different combinations of two dice. To obtain two outcome of two very recently one possibility, one plus one. But to obtain four, there are three possibilities. 1 + 3, 2 + 2, 3 + 1 . You can see that some of the outcomes have more possible, more combinations available from dice then others. And it's shown in this plot. This is the outcome of this is number of combinations that lead to this particular outcome.

We have 36 combinations possible. This is all, all over him here. And the probability of a given outcome of a given outcome is the number of combinations that leads to this divided by 36. That's the probability . The more combinations lead to a given outcome, the more likely the outcome is. And you can see that outcome of seven is six times more likely than the outcome of two. And you can assign a probability. So this is what the probability distribution is.

It takes all outcomes into account and assigns a probability of a given outcome to it. This is the notation I'm going to use for a discrete random variable. The plot shows a probability distribution slightly different from what I showed you before. But again this is a discrete outcome, which is a number here between 0 and 12 and there are various probabilities. And the notation I'm going to use throughout these lectures is like this. P means probability that X equals k .

X is a random variable, is just a name. It's a variable name. It's not a number, it's just a symbol. I'm going to use. k is the possible outcomes. So k is a number. And we can write like this probability that X equals six is 0.1 because you can see it from this distribution and this is probability of X being six. Probability of X being between 5 and 7 is 0.32. This is the sum of these three numbers or area under these three bars. As you can see, probabilities are additive.

So you simply add these three probabilities. For a continuous random variable, it's a little bit more complicated. We don't have individual probabilities. We have so-called density function. This density function describes how probability changes with the value. And we don't consider probability of X being equal to something because it's 0. I will show you in a moment. Typically we consider a limit, a probability of some variable being greater or less than a given limit.

And it's simply, it's an integral of this density function from the limit to infinity. And as you know, integral is simply area under the curve. So this dark area here, this area, this is the probability that our variable X is greater than ten. In this particular probability distribution. We could calculate the probability of X being exactly ten, it will be probability of an infinitely narrow area between 10 and 10, which simply is 0, so that it is not in use but doesn't make much sense

from a statistical point of view. We typically look at tail probability, probabilities. And you will see this tail probability through the entire lecture series. We'll come back to this again and again. Again. The total probability is one. Normal distribution is probably the most commonly used, and hence its name, normal because it's normally seen in nature. It appears in nature quite often. Sometimes it is called Gaussian because Gauss, Carl Friedrich Gauss, German

mathematician studied this a lot and is given by this formula. I don't want you to remember it. I'm just showing this for for completeness. The parameters of a density function over a two parameters, mean and standard deviation mean is mu, standard deviation is sigma. Sigma square is called variance. And in this particular case, what you see here is a normal distribution with mean of 10 and standard deviation of 1.5. So mean is right in the middle of a distribution.

A distribution is symmetric and it's ten, and this is mean plus and minus sigma. This is this range plus minus one standard deviation. And in statistics, in error analysis, in statistical testing, we usually ask about tail probabilities or probabilities within a certain range. For example, if you cut off the area, this dark shaded area here, within plus minus one standard deviation from the mean, it will contain about 68.3% about two-thirds crude approximation of probability of 68.3%.

And then it cutting off at various limits will give you different, different numbers. So this table kind of summarizes numbers that are occasionally used your kind of course calculated using software like R. But it's good to remember some of them. One sigma, two sigma is about 95%. If you want to exactly 95%, which is 1.96 times sigma, which is sort of a magic number. It will reappear again through lecture course. 1.96. It is very close to this line.

It's minus 1.96 times sigma plus 1.96 times sigma. And inside this you have exactly 95%, or 5% outside, and odds of being out are 1 in 20. Now, as I will tell you and explain in details later, statistical testing is about these odds. If you set a limit, your p-value limit at 5%, then you have one in 20 odds or probability of being wrong when you do your experiment. Physicists, for example, quite often have a 3 sigma limit where odds are one in 400. So if you

if you did your biological experiment and came to a physicist and told them you have a p-value of 5% they would probably laugh at you. But that just shows the difference has been in physics where experiments are often much more precise and accurate than in biology where biological subjects are so variable, So noisy that is very hard hard to obtain better results. But remember, 1.96 corresponds to 95% inside and 5% outside. This is a real life example of the normal distribution.

This is height of 1034 major league baseball players in the United States. It's taken from this website. You can, you can check it yourself. And each bar corresponds to the count of players at a given height. The height is a continuous variable, but for our purposes it was rounded up to the nearest inch. That's why it looks a bit weird. But you can see here very well that, that the real distribution of heights is very well approximated by a normal distribution which is

presented here by the red curve. And the mean in this case is 187.2 centimeters. Why do we call it Gaussian distribution? Well, it comes back to Carl Friedrich Gauss, who was a brilliant German mathematician, he did lots of things that his name appears in mathematics all over the place. Is famous for building a regular heptadecagon which is a polygon with 17 sites using a ruler and a compass. So this is, this is an old ancient Greek task. Gauss, using just ruler and compass

Came up with this idea, very elegant idea how to build it. And I he requested that the regular heptadecagon would be inscribed on his tombstone and the stonemason Looked at this and said, "no way guv, I can't do it" "It will look like a circle." It was just beyond his abilities to carve such a subtle shape. It's not Gauss really, it was Abraham de Moivre Who formulated this normal distribution or something which we call Gaussian long ago, before Gauss was born.

But the name Gaussian stuck to it because he developed it and analyzed it in details. Another distribution I want you to know is log-normal distribution. It's quite simple. Actually. It's a probability distribution of a random variable whose logarithm is normally distributed. Look at this example. This is again a real life examples from proteomics is a distribution of a certain quantity here. And it looks very asymmetric, very skewed. If you take a logarithm of this value and plot

the distribution of it. It looks this way. This one looks much more like a normal distribution. Not perfectly, it's a bit skewed, but it resembles a Normal distribution. Better than this Anyway. When we talk about things in nature, hardly ever a distribution is actually very close to normal It's only an approximation. Important thing to remember about this is that certain rules in statistics simply don't apply to distributions like this. If you plot the mean and mean,

standard deviation and the mean minus standard deviation, it turns out that 96% of values here are within plus minus one sigma. And in normal distribution, I told you it's about two-thirds . And after taking a logarithm of this, it looks much better. This is mean plus minus one sigma and about 67% of data or measurements are within. Once sigma one standard deviation from the mean, that's why And for many other reasons, if you have data which is distributed like this, you want to log transform it. You learn to take a logarithm of this and then proceed with your analysis. The thing you want to do is always plot the distribution of your data before you do analysis.

Why is log normal or taking a logarithm important? Well, for various reasons. First of all, there are lots of types of measurements. Usually high-throughput experiments, line RNA-seq microarrays mass spectrometry or drug potency IC 50. All these numbers are typically log-normally distributed. So first of all, you want to plot them in the logarithmic scale. This is the reason for this is the same data in the top and bottom panel, but this is direct intensity, this is actually

from RNA-seq, so it is gene expression. And it's times ten to the sixth its' 300,000, 200,000 and so on. And you can see a few data points, but for bulk of data are concentrated here you can't really see it. Because how it is distributed, if you plot logarithm of I1 versus logarithm of I2 (this is just a comparison of two replicates) You see much better how these things behave. Even see that at lower values for individual counts come to one of two and so on.

So when you have data that are log-normally distributed, you should plot it in a logarithmic scale. And it doesn't matter whether you use logarithm to base two, ten or a natural logarithm as long as you are consistent. However, in a presentation, it's worth using log to base ten for a simple reason, because it's easy to interpret. If you see 5 this is log, 4, 5 would be here. You immediately know five corresponds to a 100 thousand. But if we did it in a log2 scale, for example, ten would correspond to what? anybody knows on top of their head? Well, it's 1024. So log2 scale is not that easy to interpret as log ten scale.

Speaking of logarithms, I have to mention John Napier, Scottish mathematician and astronomer. He invented logarithms and first published tables of natural logarithms. He also created Napier's bones, was for first practical calculator, made of wood, like this one And he was born in Murchiston castle in Edinburgh, which now is right in the center of John Napier University, named after him. He had interest in theology, he calculated that date of the end of the world,

somewhere between 1688 and 1700, He was also also involved in alchemy and necromancy. Okay? So very universal scientist. The next distribution I want to discuss with you is Poisson distribution. Counting distribution. That pertains to a thing that you actually count. Like this plate where you have bacterial colonies around. This is a 100 microlitre

ten to minus seven dilution with OD 600 of 2. So. This is from a particular experiment. And we have ten bacterial colonies here. So this is account. And if you repeat this experiment, the same plating again and again and again. We'll notice that every time we have a different count. And this is again to be expected this is statistical variability. Because every time you take an aliquots from, from the solution, there'll be a certain number of individual bacteria in it.

And depending where we take, this number will vary. It's just a random number. And this applies, this Poisson distribution applies to any counts in time or space like radioactive decays per second. Number of deaths in a population, or number of cells in a counting chamber, or number of mutations in your DNA fragment. So it's always something per bin and bin could be, as I said, time or space or time-space or some other things. This is an example of Poisson distribution.

If you measure this over many, many, many plates like thousands, and then built a distribution of counts. This is what you're going to obtain. So this is a Poisson distribution when mean is seven. Poisson distribution arises naturally from random and independent events. Two things are important: random variables, nothing driving these numbers. And independent means, each number is obtained completely independently of another If you try to take aliquots from bacterial solution where

bacteria tend to clump together. If they are not uniformly distributed the measured count will not follow Poisson distribution because we are no longer independent. And the probability of observing exactly k events in our count series is given by this formula. What is important here is that k is the number of how many counts you are looking for. But it's only one parameter here, mu - mean. If you remember in Gaussian distribution or normal distribution, there are two parameters,

mean and standard deviation. The mean tells you where the distribution was you could shift it to the left and right of the scale or standard deviation will tell you how wide the distribution is. Here. There is only one parameter, mean and sigma, the standard deviation is simply square root of the mean. Variance is mean. This is the property of the Poisson distribution. And you can see a few Poisson distributions here with these lollipop plots for different means. 0.3, 1, 4 and 10.

And on top of this is plotted a Gaussian distribution with the same mean and standard deviation. So as you can see, with higher numbers, Poisson distribution begins to look like a Gaussian distribution, like a normal distribution. Worthwhile for reasons is quote, normal, it comes from the central limit theorem. Essentially everything tends to normal distribution. Have a look at this example because it's quite interesting. I think it's a very old classical example. It comes from the book

"Das Gesetz der kleinen Zahlen" which means " the law of small numbers" and statistician of Polish origin who lived and worked in Germany. Like a typical postdoc. And he studied data from, he was giving data from a Prussian army about soldiers being killed by horse kicks. And he collected data from 14 army corps over 20 years of data. So what you have here, it's again count per bin, deaths per year per army corps. So this is, this is a bin one band contains one year and one army corps.

It's kind of a spacetime bin. This is the original data in a paper he wrote, a book he published. And what's what the Prussian army officers were worried about there is a number four here in one particular year and one particular army corps. And they suspected some foul play. Why do we have suddenly for deaths in one unit, while other numbers are much smaller? And Bortkiewicz analyzed these data, and showed that it follows a Poisson distribution very nicely.

And it's illustrated in this diagram here, the data and uncertainties. And I will explain later when I talk about confidence intervals as shown by points and error bars. So if this is real data and the shaded boxes show the theoretical Poisson distribution with this mean, 0.7 deaths per corps per year. And this, you can see data follow a Poisson distribution very nicely. And also using this Poisson distribution with this mean, you can calculate the probability of

having four deaths in one corps-year. And this probability is 0.078 in 14 corps. So. It's just expected to happen from time to time. Even a rare event will happen if you, if you wait long enough and if you do calculations here, it should happen on average once in 13 years. So Bortkiewicz showed that, OK, it's just a fluke. And it happens. And it, it's because we, this count follows Poisson distribution. And the last distribution for today is binomial distribution. It's probably a bit more

abstract and seems to be detached from biology, but actually it is important in biological sciences in error estimation in error of proportion, error of the median What we have here is a series of n so-called trials. And each trial, it's an event. There is a probability of either a success, which we'll call p, or a failure, one minus p . There is a series of events and it could be either success or failure. And we ask what is the probability of having exactly k successes in n trials?

And this shows a binomial probability distribution of this is k number of successes. There is eight trials in total services. This is the probability. And the example is when you toss a coin, this is binomial distribution. What do you obtain from multiple coins tossed. If you say that "heads" is a success and probability is 0.5, then "tails" is a failure and probability is one minus p, It is also 0.5. So this is the probability of getting a given number of

heads when you throw a coin eight times. The mean is np , that the standard deviation is given by this formula. We actually come back to this, but I will remind you later when it comes to errors. error analysis. Again, for large numbers and probabilities, kind of somewhere in the middle. Binomial distribution looks pretty much like normal. The lollipops. Binomial distribution, and the red line shows normal distribution. Conversely, for a very small probability and large numbers,

binomial distribution looks like Poisson distribution. So depending what, what case, limiting case you have, you can replace binomial distribution either with Gaussian or Poisson distribution. Have a look at, for example, let's say we toss eight coins. Why is the probability of having heads four times much larger than the probability of having heads eight times. You see, the probability of having four heads is here. The probability of having eight heads is here,

but it's a huge difference between them. And it's actually easy to notice. It's just like with two dice we use to throw. In the beginning of the lecture. There is only one combination of coins that leads to eight heads. But there are many ways of getting four heads. There is a formula for very specific so-called binomial symbol. You can read about it. You are, maybe you're familiar with this eight over four. And if you calculate it, it's 70, there is actually 70 possible combinations of eight coins that lead to 1234. Heads, so this is 70 times more probable than this.

That was a very simple introduction just a few probability distributions. I hope it wasn't too boring. I will show you later applications of these and these should be much more interesting. I hope so. Let's now have a look at some practical part of this, how to do this in R. I recommend during our induction lecture for those who are at the University of Dundee, I recommend using R is a statistical language which is very good for solving statistical data analysis problems

and has lots of things built in Which makes some calculations very, very easy. And if you want to calculate probabilities, p-values, and stuff like this, you can do it very easily in R. So for every probability distribution in R, There are three functions starting with d, p, and q. So this is for normal distribution. We have dnorm, pnorm, qnorm. d is for density. It shows you this function. So if you calculate density of a value, let's say z here, it will give you a density here,

which is probably less useful unless you want to plot this curve. What is more useful is a cumulative distribution, p, that gives you a probability of a value of a random variable being less than Z. So you put a number Z here and it would give you the probability in this light shaded area. And you can inverse it here. You can find a quantile which is a qnorm, which simply inverses this. So for a given probability, cumulative probability, it will give you Z corresponding to this.

Let's use it. These functions. Let's use it to find a Z corresponding to the confidence interval. I will talk about confidence intervals later, but of a probability of 95% here. What we want, we want to find this Z, this value on this axis, which corresponds to this probability. We assume it's symmetric, so we have the same cut-off probability five, sorry, 2.5% on left side, 2.5% on the right side, and in the middle various ninety-five percent.

If you still remember what I told you about before, this little magical number of 1.96 that cuts off exactly 95%, we should obtain 1.96. Now how can we use this? Well, this, this gives us a probability a Z corresponding to probability from minus infinity to this point. So it's a left tail probability. But we want this so we can calculate the left de probability. Let's say from this, if this is 95% and what's in this tail is 2.5% or it's one minus beta over two. This is beta.

So the total probability here is 0.975. Okay? That's straightforward. 95% plus 2.5%. And now we can use qnorm 4.975. And we obtained this value which is approximately equal to 1.96. For one I told you earlier, this cuts off exactly 95% inside or 5% outside. This is how you can use a binomial distribution in R. There is dbinom, pbinom and qbinom dbinom is the value of this bar exactly, this is a density in discrete distribution. P would be again the light shaded cumulative probability.

And this will give you quantile. Back to our coins. Probability of obtaining exactly two heads in eight tosses of a coin. So we do this function and there are more parameters here. We are interested in the probability of having two heads. The size of our trials is eight. We have eight trials, eight coins. And the probability of one side or the other side of the coin, if it isn't honest coin is 0.5. And if I calculate it is 0.1. So it will be, that will be this bar. Or a probability of having

at least six heads is one minus this p They know which is a probability, cumulative probability up to a given point. We need to use five because we want to exclude this because we are asking at least six So that will give you this dark shaded area. There are functions for lots of distributions, binomial, log-normal, Poisson And also some I haven't discussed. I will mention some of them later, like chi-square and Student's t-distribution. And they all have the same format,

but it's a density, cumulative distribution and quantiles. And you can use these functions in R directly. It's base R, doesn't require any libraries, you can just use it straight away. This is a summary of what I told you today. Four distributions, I showed you a normal distribution is a bell-shaped curve. It's a continuous distribution and is often seen in nature. For example, human height follows normal distribution. Log-normal Well, very simple logarithm of this variable is normal.

And we typically see it in high-throughput experiments in biology. Poisson distribution is otherwise known count distribution. And its example could be a count of [cell colonies] per plate. And finally, binomial distribution is success versus failure. For example, male female distribution in the population that roughly follows a binomial distribution. But, there are some some funny departures from this I will show you later. That's everything for today.

You can find hand outs again when, not yet, but I will put them on this website very soon including the recording of this lecture. Thank you.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent