Standard RNA-seq processing

This tutorial assumes that the reader is familiar with the limma/voom workflow for RNA-seq. Process raw count data using limma/voom.

Limma Analysis

Limma has a built-in approach for analyzing repeated measures data using duplicateCorrelation. The model can handle a single random effect, and forces the magnitude of the random effect to be the same across all genes.

Dream Analysis

The dream model operates directly on the results of voom. The only change compared to the standard limma workflow is to replace lmFit with dream.

## Projected memory usage: > 557.3 Mb 
## 
## Finished...
## Total: 461 s
##                                    logFC  AveExpr        t      P.Value    adj.P.Val        B
## ENST00000283033.5 gene=TXNDC11  1.555819 3.567624 38.95633 6.095309e-23 1.180296e-18 37.34041
## ENST00000257181.9 gene=PRPF38A  1.382756 4.398270 27.97235 1.294078e-19 1.252927e-15 32.37189
## ENST00000525790.1 gene=TDRKH    1.496308 3.184931 21.74514 3.993164e-17 2.577454e-13 27.93310
## ENST00000264485.5 gene=SLC4A4   1.415366 4.476664 21.06020 8.205843e-17 3.179977e-13 27.33874
## ENST00000421974.2 gene=ATP6V0E2 1.372569 3.478030 21.05961 8.211054e-17 3.179977e-13 27.33822
## ENST00000373277.4 gene=SH2D3C   1.383826 3.509569 20.86911 1.007020e-16 3.249990e-13 27.16846
## ENST00000295633.3 gene=FSTL1    1.387415 4.625435 20.11319 2.301911e-16 6.367744e-13 26.47499
## ENST00000339861.4 gene=SEMA4D   1.396601 4.186466 19.27069 5.980850e-16 1.447665e-12 25.66285
## ENST00000231454.1 gene=IL5      1.493454 1.789759 18.88682 9.355308e-16 2.012846e-12 25.27835
## ENST00000577031.1 gene=PAM16    1.460190 1.137609 18.72486 1.132609e-15 2.193183e-12 25.11330

Note that if random effect is not specified, dream() automatically uses lmFit().

Small-sample method

For small datasets, the Kenward-Roger method can be more powerful. But it is substantially more computationally intensive.

Advanced use of contrasts

You can also perform a hypothesis test between two levels. Make sure to inspect your contrast matrix to confirm it is testing what you intend.

Multiple contrasts can be evaluated at the same time, in order to save computation time:

## Projected memory usage: > 318.5 Kb 
## 
## Finished...
## Total: 0 s
##                                       logFC  AveExpr          t   P.Value adj.P.Val         B
## ENST00000570099.1 gene=YPEL3   -0.218126111 2.063331 -1.2954793 0.1845801 0.9236780 -4.512697
## ENST00000317802.7 gene=TSPYL6   0.297858912 4.321189  1.2817361 0.1894144 0.9236780 -4.541292
## ENST00000360314.3 gene=CASS4    0.320138025 4.633301  1.0661312 0.2771034 0.9236780 -4.587269
## ENST00000589123.1 gene=NFIC    -0.162496650 5.855335 -0.8359895 0.4072782 0.9788791 -4.653490
## ENST00000263773.5 gene=FNBP4   -0.007552407 5.290530 -0.0262386 0.9788791 0.9788791 -4.660241
## ENST00000456159.1 gene=MET     -0.068849295 2.458926 -0.4254374 0.6724077 0.9788791 -4.720647
## ENST00000555834.1 gene=RPS6KL1  0.043986323 5.272063  0.2723696 0.7864990 0.9788791 -4.734654
## ENST00000248564.5 gene=GNG11   -0.044878081 4.511181 -0.2415549 0.8101478 0.9788791 -4.736735
## ENST00000418210.2 gene=TMEM64  -0.019000581 4.715367 -0.1162156 0.9066433 0.9788791 -4.736882
## ENST00000337859.6 gene=ZC3H15   0.040055495 4.169523  0.1952654 0.8460044 0.9788791 -4.739395

variancePartition plot

Dream and variancePartition share the same underlying linear mixed model framework. A variancePartition analysis can indicate important variables that should be included as fixed or random effects in the dream analysis.

## 
## Finished...
## Total: 300 s

Compare p-values from dream and duplicateCorrelation

In order to understand the empircal difference between dream and duplication correlation, we can plot the \(-\log_{10}\) p-values from both methods.

The duplicateCorrelation method estimates a single variance term genome-wide even though the donor contribution of a particular gene can vary substantially from the genome-wide trend. Using a single value genome-wide for the within-donor variance can reduce power and increase the false positive rate in a particular, reproducible way. Let \(\tau^2_g\) be the value of the donor component for gene \(g\) and \(\bar{\tau}^2\) be the genome-wide mean. For genes where \(\tau^2_g>\bar{\tau}^2\), using \(\bar{\tau}^2\) under-corrects for the donor component so that it increases the false positive rate compared to using \(\tau^2_g\). Conversely, for genes where \(\tau^2_g<\bar{\tau}^2\), using \(\bar{\tau}^2\) over-corrects for the donor component so that it decreases power. Increasing sample size does not overcome this issue. The dream method overcomes this issue by using a \(\tau^2_g\).

Here, the \(-\log_{10}\) p-values from both methods are plotted and colored by the donor contribution estiamted by variancePartition. The green value indicates \(\bar{\tau}^2\), while red and blue indicate higher and lower values, respectively. When only one variance component is used and the contrast matrix is simple, the effect of using dream versus duplicateCorrelation is determined by the comparison of \(\tau^2_g\) to \(\bar{\tau}^2\):

dream can increase the \(-\log_{10}\) p-value for genes with a lower donor component (i.e. \(\tau^2_g<\bar{\tau}^2\)) and decrease \(-\log_{10}\) p-value for genes with a higher donor component (i.e. \(\tau^2_g>\bar{\tau}^2\))

Note that using more variance components or a more complicated contrast matrix can make the relationship more complicated.

Session info

## R version 3.6.0 (2019-04-26)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.2 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.9-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.9-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
##  [4] LC_COLLATE=C               LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
## [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] doParallel_1.0.14        iterators_1.0.10         edgeR_3.26.0            
##  [4] variancePartition_1.14.0 Biobase_2.44.0           BiocGenerics_0.30.0     
##  [7] scales_1.0.0             foreach_1.4.4            limma_3.40.0            
## [10] ggplot2_3.1.1            pander_0.6.3            
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.1         locfit_1.5-9.1     lattice_0.20-38    prettyunits_1.0.2  gtools_3.8.1      
##  [6] assertthat_0.2.1   digest_0.6.18      R6_2.4.0           plyr_1.8.4         evaluate_0.13     
## [11] pillar_1.3.1       gplots_3.0.1.1     rlang_0.3.4        progress_1.2.0     lazyeval_0.2.2    
## [16] minqa_1.2.4        gdata_2.18.0       nloptr_1.2.1       Matrix_1.2-17      rmarkdown_1.12    
## [21] labeling_0.3       splines_3.6.0      lme4_1.1-21        statmod_1.4.30     stringr_1.4.0     
## [26] munsell_0.5.0      numDeriv_2016.8-1  compiler_3.6.0     xfun_0.6           pkgconfig_2.0.2   
## [31] lmerTest_3.1-0     htmltools_0.3.6    tidyselect_0.2.5   tibble_2.1.1       codetools_0.2-16  
## [36] crayon_1.3.4       dplyr_0.8.0.1      withr_2.1.2        MASS_7.3-51.4      bitops_1.0-6      
## [41] grid_3.6.0         nlme_3.1-139       gtable_0.3.0       magrittr_1.5       KernSmooth_2.23-15
## [46] stringi_1.4.3      reshape2_1.4.3     colorRamps_2.3     boot_1.3-22        tools_3.6.0       
## [51] glue_1.3.1         purrr_0.3.2        hms_0.4.2          pbkrtest_0.4-7     yaml_2.2.0        
## [56] colorspace_1.4-1   caTools_1.17.1.2   knitr_1.22

References

Law, C. W., Y. Chen, W. Shi, and G. K. Smyth. 2014. “Voom: precision weights unlock linear model analysis tools for RNA-seq read counts.” Genome Biology 15 (2):R29. https://doi.org/10.1186/gb-2014-15-2-r29.