Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

q value calculations in a comparison of two mouse strains

KTH JupyterHub Open In Colab Binder

Differential expression analysis with multiple testing

This chapter applies the methods of the previous chapter to the analysis of the chapter on differential expression in two mouse strains.

We again compare the striatum of the two inbred mouse strains C57BL/6J (B6, 10 mice) and DBA/2J (D2, 11 mice), from the RNA-seq experiment of Bottomly et al. (2011), using the gene count table prepared by the ReCount project.

We first recreate the steps of that chapter. Since we will repeat the testing several times in this chapter, we write the tt test in a vectorised form that tests all genes in a single call, rather than looping over the rows of the table.

Notebook Cell

When plotting the pp value distribution below, we see an enrichment of low pp values. Most of these come from genes that follow the alternative hypothesis. We also see a uniform distribution of the pp values in the higher end of the distribution, i.e. pp values of 0.5–1.0. These are likely stemming from genes that follow H0H_0.

<Figure size 1200x800 with 1 Axes>

qq value estimation

We define a function for the calculation of π0\pi_0. Here we use a different method than the spline described by Storey & Tibshirani, namely the bootstrap method of Storey (2002), which is outlined in a note in the previous chapter. As the method is based on random resampling, we fix the seed of the random number generator, so that the estimate is the same every time we run the analysis.

Following Storey & Tibshirani, we first calculate

FDR^(t)=π^0mt∣{pi≤t}∣,\hat{\rm FDR}(t) = \frac{\hat{\pi}_0 m t}{|\{p_i\le t\}|},

and then make the FDR^(t)\hat{\rm FDR}(t) estimates monotone by taking the minimum over all thresholds at least as large as pip_i,

q^(pi)=min⁡t≥piFDR^(t).\hat{q}(p_i)=\min_{t \ge p_i}\hat{\rm FDR}(t).
pi_0 estimated to 0.544

The estimated π0\pi_0 of about 0.5 says that roughly half of the expressed genes differ in their expression between the two strains. Given that the strains differ at millions of positions in their genomes, many of them in sequences that regulate gene expression, that is not unreasonable. One might worry that some of the differences are technical: the reads were aligned to the reference genome, which is a B6 genome, so reads from D2 genes carrying many sequence differences could align less well and make those genes look lower expressed in D2. Bottomly et al. tested this by realigning the D2 reads to a D2 version of the genome, and found that the effect on their results was minimal.

Note that π0\pi_0 and the qq values answer different questions. π0\pi_0 estimates how many genes are differentially expressed in total, while a qq value tells us which genes we can single out with a controlled error rate. Many of the expression differences are too small to be pinned down gene by gene with ten mice per strain, even though their combined effect on the pp value distribution is clearly visible. (Bottomly et al. used a test designed for count data, and reported 1,727 differentially expressed genes at q<0.01q<0.01 out of the 16,183 genes they tested.)

The table lists the genes in descending order of significance, together with their qq values.

Loading...

Displaying number of findings as a function of qq value

A plot of the number of differentially expressed genes as a function of the qq value threshold shows how many genes we can report at each FDR level.

<Figure size 640x480 with 1 Axes>

Volcano plots revisited

We often see that Volcano plots are complemented with FDR thresholds. Here we complement the volcano plot of the mouse strain chapter with coloring indicating if genes are significantly differentially expressed at an FDR threshold of 0.01.

395 of 6995 genes have q < 0.01
<Figure size 1051.33x600 with 1 Axes>

A ground truth null experiment

A pp value histogram that is enriched near zero, and a π0\pi_0 well below one, are easy to produce. The harder question is whether we should believe them: how do we know that the machinery above is not manufacturing findings out of technical artefacts?

Most data sets cannot answer that question, because we never know which genes are truly differentially expressed. This data set lets us construct such a case. The ten B6 mice are inbred, i.e. genetically almost identical, and were all treated the same way. If we split them into two groups of five, we have built an experiment in which the null hypothesis is true for every single gene. Any finding is by construction a false positive.

The B6 mice were sequenced on three different flow cells (the experiment column of the sample table in the mouse strain chapter). To keep the comparison fair, we alternate the mice of each flow cell between the two groups, so that both groups contain mice from all three flow cells.

<Figure size 1300x450 with 2 Axes>

The difference is striking. The B6 against B6 comparison has no spike at all near zero, so the test does not manufacture findings out of nothing. The histogram is, however, not perfectly flat either: small pp values are rarer than the uniform distribution predicts (the dashed line marks the height m/20m/20 of a uniform distribution), and intermediate ones more common. The reason is the flow cells. Each of our two groups contains mice from all three flow cells, so the differences between flow cells inflate the variance within each group, while they largely cancel out in the difference between the group means (the split is 2/2/1 against 1/2/2 mice from the three flow cells, so the cancellation is not perfect). The tt statistics therefore come out smaller than they should, and the pp values larger. In other words, the test becomes conservative. The same applies to the comparison between the strains, as Bottomly et al. spread the mice of both strains over all three flow cells, so we lose some power there too.

Running the same qq value machinery on this null experiment should therefore report no findings.

pi_0 estimated to 0.848
genes with q < 0.01:     0   (out of 6995)
genes with q < 0.05:     0   (out of 6995)
genes with q < 0.10:     0   (out of 6995)
genes with q < 0.20:     0   (out of 6995)
smallest q value in the null experiment: 0.789

No gene survives any reasonable qq value threshold, whereas the real comparison produced hundreds of findings at q<0.01q<0.01. The multiple hypothesis correction is not simply throwing away everything, nor is it rubber-stamping noise. Note, though, that the estimated π0\pi_0 comes out below one, as the estimate assumes that the true nulls give a flat histogram, which they do not quite do here.

A batch effect

The care we took to balance the flow cells was not a formality. Below we instead compare the four B6 mice sequenced on flow cell 6 to the six sequenced on flow cells 4 and 7. The null hypothesis is still true for every gene in a biological sense, as all ten mice are B6, but now the two groups also differ in how they were processed.

pi_0 estimated to 0.553
genes with q < 0.05: 3
<Figure size 650x450 with 1 Axes>

Now the histogram shows a clear spike of small pp values, π0\pi_0 is estimated well below one, and the qq value machinery even reports a few significant genes, although none of them is differentially expressed in a biological sense. The tt test cannot tell a difference caused by biology from a difference caused by the processing of the samples. Batch effects thus cut both ways: when the batches are confounded with the groups they create false findings, and when they are spread over the groups they inflate the variance and cost power, as we saw above. This is why a good experimental design spreads the conditions evenly over the processing batches, as Bottomly et al. did for the two strains, and why more advanced analyses include the batch as an explanatory variable in the model, rather than leaving it in the noise.

Spline estimation of π0\pi_0

Storey and Tibshirani estimate π0\pi_0 differently from the bootstrap procedure used above: they compute π^0(λ)=∣{pi>λ}∣m(1−λ)\hat{\pi}_0(\lambda) = \frac{|\{p_i>\lambda \}|}{m(1-\lambda)} for a range of λ\lambda values and smooth these estimates with a spline.

Below, we almost follow the article’s described procedure (please try to find the difference in how we select which lambdas we evaluate). We fit a smoothing cubic spline to the π^0(λ)\hat{\pi}_0(\lambda) estimates.

We plot the estimates (blue) as well as the spline fit (red) for two different intervals of λ\lambda. You will see the need for a smoother, particularly in the region near 1.0.

<Figure size 1200x400 with 2 Axes>

We can obtain a final estimate by evaluating the spline for λ=1\lambda=1, and compare it to the bootstrapping estimate.

Spline estimate of pi_0:    0.502
Bootstrap estimate of pi_0: 0.544
What you should know after reading this chapter

You should be able to:

  1. Interpret an estimated π0\pi_0 in its biological context, and contrast what π0\pi_0 tells you (how many genes differ in total) with what qq values tell you (which individual genes can be called at a controlled error rate).

  2. Explain how a ground-truth null experiment, such as splitting genetically identical B6 mice into two groups, checks whether an analysis manufactures findings, and describe the pp value histogram and qq values you expect from it.

  3. Explain why processing batches, such as flow cells, make a tt test conservative when they are spread evenly over the groups, but create false findings when they are confounded with the groups. Identify both situations from a pp value histogram.

  4. Argue why a good experimental design spreads the conditions evenly over the processing batches, and judge whether a given design confounds batch with condition.

References
  1. Bottomly, D., Walter, N. A. R., Hunter, J. E., Darakjian, P., Kawane, S., Buck, K. J., Searles, R. P., Mooney, M., McWeeney, S. K., & Hitzemann, R. (2011). Evaluating Gene Expression in C57BL/6J and DBA/2J Mouse Striatum Using RNA-Seq and Microarrays. PLoS ONE, 6(3), e17820. 10.1371/journal.pone.0017820
  2. Frazee, A. C., Langmead, B., & Leek, J. T. (2011). ReCount: A multi-experiment resource of analysis-ready RNA-seq gene count datasets. BMC Bioinformatics, 12(1). 10.1186/1471-2105-12-449
  3. Storey, J. D. (2002). A Direct Approach to False Discovery Rates. Journal of the Royal Statistical Society Series B: Statistical Methodology, 64(3), 479–498. 10.1111/1467-9868.00346