Introduction

This workshop uses data from a gene-level RNA-seq experiment involving airway smooth muscle cells; details are provided in the vignette accompanying the airway package. The original data is from Himes et al., “RNA-Seq Transcriptome Profiling Identifies CRISPLD2 as a Glucocorticoid Responsive Gene that Modulates Cytokine Function in Airway Smooth Muscle Cells.” PLoS One. 2014 Jun 13;9(6):e99625. PMID: 24926665 GEO: GSE52778. From the Abstract: “Using RNA-Seq […] we characterized transcriptomic changes in four primary human ASM cell lines that were treated with dexamethasone - a potent synthetic glucocorticoid (1 micromolar for 18 hours).”

We join the analysis after the sequencing, read aligment, and summary of aligned reads to a table of counts of reads overlapping regions of interest (genes) in each sample. We focus on a subset of the experiment, with 4 cell lines each treated with dexamethasone or a control.

Setup (not necessary during the workshop)

We’ll use two packages from Bioconductor. These depend in turn on several other packages. The packages and their dependencies are already installed on the Amazon Machine Instance (AMI) used in the course. For your own computers after the course, install packages with

source("https://bioconductor.org/biocLite.R")
biocLite(c("DESeq2", "org.Hs.eg.db"))

Installation needs to be performed once per computer, not every time the packages are used.

We use two data files in the analysis. The data files are in the Sydney2016 github repository. Install the github repository with

biocLite("Bioconductor/Syndey2016")

Once the package is installed, the location of the files (to be used in file.choose(), below) is given by

system.file(package="Sydney2016", "extdata")

Data input

The first challenge is to input the data. We start with the ‘phenotypic’ data, describing the samples used in the experiment. The data is a simple table of 8 rows and several columns; it could be created in Excel and exported as a tab-delimited file. Find the location of the file on your Amazon machine instance

colDataFile <- file.chooose()    # find 'airway-colData.tab'

and read the data in to R using the read.table() function. The data is small enough to be viewed in the R session by typing the name of the variable) or in RStudio (by using View() or double-clicking on the variable in the ‘Environment’ tab).

colData <- read.table(colDataFile)
colData
##            SampleName    cell   dex albut        Run avgLength Experiment
## SRR1039508 GSM1275862  N61311 untrt untrt SRR1039508       126  SRX384345
## SRR1039509 GSM1275863  N61311   trt untrt SRR1039509       126  SRX384346
## SRR1039512 GSM1275866 N052611 untrt untrt SRR1039512       126  SRX384349
## SRR1039513 GSM1275867 N052611   trt untrt SRR1039513        87  SRX384350
## SRR1039516 GSM1275870 N080611 untrt untrt SRR1039516       120  SRX384353
## SRR1039517 GSM1275871 N080611   trt untrt SRR1039517       126  SRX384354
## SRR1039520 GSM1275874 N061011 untrt untrt SRR1039520       101  SRX384357
## SRR1039521 GSM1275875 N061011   trt untrt SRR1039521        98  SRX384358
##               Sample    BioSample
## SRR1039508 SRS508568 SAMN02422669
## SRR1039509 SRS508567 SAMN02422675
## SRR1039512 SRS508571 SAMN02422678
## SRR1039513 SRS508572 SAMN02422670
## SRR1039516 SRS508575 SAMN02422682
## SRR1039517 SRS508576 SAMN02422673
## SRR1039520 SRS508579 SAMN02422683
## SRR1039521 SRS508580 SAMN02422677

This should go smoothly; with real data one often needs to spend considerable time adjusting arguments to read.table() to account for the presence of a header, row names, comments, etc.

The next challenge is to input the expression estimates. This is a matrix of rows representing regions of interest (genes) and columns representing samples. Entries in the matrix are the number of reads overlapping each region in each sample. It is important that the values are raw counts, rather than scaled measures such as FPKM. Find the file

assayFile <- file.chooose()    # find 'airway-assay.tab'

Input the data and use head() to view the first few rows of the data.

assay <- read.table(assayFile)
head(assay)
##                 SRR1039508 SRR1039509 SRR1039512 SRR1039513 SRR1039516
## ENSG00000000003        679        448        873        408       1138
## ENSG00000000419        467        515        621        365        587
## ENSG00000000457        260        211        263        164        245
## ENSG00000000460         60         55         40         35         78
## ENSG00000000938          0          0          2          0          1
## ENSG00000000971       3251       3679       6177       4252       6721
##                 SRR1039517 SRR1039520 SRR1039521
## ENSG00000000003       1047        770        572
## ENSG00000000419        799        417        508
## ENSG00000000457        331        233        229
## ENSG00000000460         63         76         60
## ENSG00000000938          0          0          0
## ENSG00000000971      11027       5176       7995

Exploration

Calculate the ‘library size’ (total number of mapped reads) of each sample using colSums()

colSums(assay)
## SRR1039508 SRR1039509 SRR1039512 SRR1039513 SRR1039516 SRR1039517 
##   20637971   18809481   25348649   15163415   24448408   30818215 
## SRR1039520 SRR1039521 
##   19126151   21164133

Create a density plot of the average asinh-transformed (asinh is log-like, expect near zero) read counts of each gene using the following series of commands.

plot(density(rowMeans(asinh(assay))))

Multi-dimensional scaling (MDS) is a dimensionality reduction method that takes vectors in n-space and projects them into two (or more) dimensions. Use the dist() function to calculate the (Euclidean) distance bewteen each sample, and the base R function cmdscale() to perform MDS on the distance matrix. We can use plot() to visualize the results and see the approximate location of each of the 8 samples. Use the argument col to color the points based on cell line (colData$cell) or experimental treatment colData$dex.

d <- dist(t(asinh(assay)))
plot(cmdscale(d), pch=19, cex=2)

plot(cmdscale(d), pch=19, cex=2, col=colData$cell)

plot(cmdscale(d), pch=19, cex=2, col=colData$dex)

Note that cell lines are relatively similar to one another. This suggests that cell line should be used as a covariate in subsequent analysis.

Differential expression

We will use the DESeq2 package for differential expression analysis; other choices are possible, notably edgeR and limma.

The analysis starts by providing the expression count data, a description of the experiment, and a ‘model’ that describes the statistical relationship we’d like to estimate. For our model and based in part on the exploratory analysis of the previous section, we suppose that count is determined cell line and dexamethasone treatment. We include cell line primarily as a covariate; our primary interest is in dexamethasone.

library(DESeq2)
dds <- DESeqDataSetFromMatrix(assay, colData, ~ cell + dex)

The analysis is extremely straight-forward to invoke, but the calculations involve a number of sophisticated statistical issues, including:

The code is invoked as:

dds <- DESeq(dds)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## final dispersion estimates
## fitting model and testing
dds
## class: DESeqDataSet 
## dim: 33469 8 
## metadata(1): version
## assays(3): counts mu cooks
## rownames(33469): ENSG00000000003 ENSG00000000419 ...
##   ENSG00000273492 ENSG00000273493
## rowData names(46): baseMean baseVar ... deviance maxCooks
## colnames(8): SRR1039508 SRR1039509 ... SRR1039520 SRR1039521
## colData names(10): SampleName cell ... BioSample sizeFactor

The DESeq() function returns an object that can be used as a starting point for further analysis, for instance generating a ‘top table’ of differentially expressed genes, orderd by adjusted (for multiple comparison) P values.

result <- results(dds)
result
## log2 fold change (MAP): dex untrt vs trt 
## Wald test p-value: dex untrt vs trt 
## DataFrame with 33469 rows and 6 columns
##                    baseMean log2FoldChange      lfcSE       stat
##                   <numeric>      <numeric>  <numeric>  <numeric>
## ENSG00000000003 708.6021697     0.37415246 0.09884435  3.7852692
## ENSG00000000419 520.2979006    -0.20206175 0.10974241 -1.8412367
## ENSG00000000457 237.1630368    -0.03616686 0.13834540 -0.2614244
## ENSG00000000460  57.9326331     0.08445399 0.24990709  0.3379415
## ENSG00000000938   0.3180984     0.08413901 0.15133424  0.5559813
## ...                     ...            ...        ...        ...
## ENSG00000273487   8.1632350    -0.55007238  0.3725061 -1.4766803
## ENSG00000273488   8.5844790    -0.10513006  0.3683837 -0.2853820
## ENSG00000273489   0.2758994    -0.06947899  0.1512520 -0.4593591
## ENSG00000273492   0.1059784     0.02314357  0.1512520  0.1530133
## ENSG00000273493   0.1061417     0.02314357  0.1512520  0.1530133
##                       pvalue        padj
##                    <numeric>   <numeric>
## ENSG00000000003 0.0001535423 0.001279829
## ENSG00000000419 0.0655868795 0.196015831
## ENSG00000000457 0.7937652416 0.912936622
## ENSG00000000460 0.7354072415 0.883203048
## ENSG00000000938 0.5782236287          NA
## ...                      ...         ...
## ENSG00000273487    0.1397614   0.3376252
## ENSG00000273488    0.7753515   0.9032267
## ENSG00000273489    0.6459763          NA
## ENSG00000273492    0.8783878          NA
## ENSG00000273493    0.8783878          NA
ridx <- head(order(result$padj), 10)
top = result[ridx,]
top
## log2 fold change (MAP): dex untrt vs trt 
## Wald test p-value: dex untrt vs trt 
## DataFrame with 10 rows and 6 columns
##                   baseMean log2FoldChange      lfcSE      stat
##                  <numeric>      <numeric>  <numeric> <numeric>
## ENSG00000152583   997.4398      -4.313962 0.17213733 -25.06116
## ENSG00000165995   495.0929      -3.186823 0.12815654 -24.86664
## ENSG00000101347 12703.3871      -3.618734 0.14894336 -24.29604
## ENSG00000120129  3409.0294      -2.871488 0.11824908 -24.28338
## ENSG00000189221  2341.7673      -3.230395 0.13667447 -23.63569
## ENSG00000211445 12285.6151      -3.553360 0.15798211 -22.49217
## ENSG00000157214  3009.2632      -1.948723 0.08867432 -21.97618
## ENSG00000162614  5393.1017      -2.003487 0.09269629 -21.61345
## ENSG00000125148  3656.2528      -2.167122 0.10354724 -20.92882
## ENSG00000154734 30315.1355      -2.286778 0.11308412 -20.22192
##                        pvalue          padj
##                     <numeric>     <numeric>
## ENSG00000152583 1.319237e-138 2.360906e-134
## ENSG00000165995 1.708565e-136 1.528824e-132
## ENSG00000101347 2.158637e-130 1.287699e-126
## ENSG00000120129 2.937247e-130 1.314124e-126
## ENSG00000189221 1.656535e-123 5.929070e-120
## ENSG00000211445 4.952260e-112 1.477094e-108
## ENSG00000157214 4.867315e-107 1.244364e-103
## ENSG00000162614 1.342345e-103 3.002826e-100
## ENSG00000125148  2.926277e-97  5.818739e-94
## ENSG00000154734  6.278709e-91  1.123638e-87

Comprehension

There are many opportunities to place the statistical results into biological context. An initial step is to map the cryptic Ensembl gene identifiers used to label regions of interest to more famliar HGNC gene symbols. For this we use the org.Hs.eg.db package, an example of a Bioconductor ‘annotation’ package containing curated data derived from public-domain resources and updated semi-annually. The mapId() function maps between identifier types, in our case to SYMBOL gene ids from ENSEMBL ids. We add these to the top table results so that they can be processed together with the statistical results.

library(org.Hs.eg.db)
top$Symbol <- mapIds(org.Hs.eg.db, rownames(top), "SYMBOL", "ENSEMBL")
## 'select()' returned 1:1 mapping between keys and columns
top
## log2 fold change (MAP): dex untrt vs trt 
## Wald test p-value: dex untrt vs trt 
## DataFrame with 10 rows and 7 columns
##                   baseMean log2FoldChange      lfcSE      stat
##                  <numeric>      <numeric>  <numeric> <numeric>
## ENSG00000152583   997.4398      -4.313962 0.17213733 -25.06116
## ENSG00000165995   495.0929      -3.186823 0.12815654 -24.86664
## ENSG00000101347 12703.3871      -3.618734 0.14894336 -24.29604
## ENSG00000120129  3409.0294      -2.871488 0.11824908 -24.28338
## ENSG00000189221  2341.7673      -3.230395 0.13667447 -23.63569
## ENSG00000211445 12285.6151      -3.553360 0.15798211 -22.49217
## ENSG00000157214  3009.2632      -1.948723 0.08867432 -21.97618
## ENSG00000162614  5393.1017      -2.003487 0.09269629 -21.61345
## ENSG00000125148  3656.2528      -2.167122 0.10354724 -20.92882
## ENSG00000154734 30315.1355      -2.286778 0.11308412 -20.22192
##                        pvalue          padj      Symbol
##                     <numeric>     <numeric> <character>
## ENSG00000152583 1.319237e-138 2.360906e-134     SPARCL1
## ENSG00000165995 1.708565e-136 1.528824e-132      CACNB2
## ENSG00000101347 2.158637e-130 1.287699e-126      SAMHD1
## ENSG00000120129 2.937247e-130 1.314124e-126       DUSP1
## ENSG00000189221 1.656535e-123 5.929070e-120        MAOA
## ENSG00000211445 4.952260e-112 1.477094e-108        GPX3
## ENSG00000157214 4.867315e-107 1.244364e-103      STEAP2
## ENSG00000162614 1.342345e-103 3.002826e-100        NEXN
## ENSG00000125148  2.926277e-97  5.818739e-94        MT2A
## ENSG00000154734  6.278709e-91  1.123638e-87     ADAMTS1

Reproducibility

The calculations here are made more reproducible by reporting the version of software used in the analysis, as follows:

sessionInfo()
## R version 3.3.1 Patched (2016-10-12 r71512)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.1 LTS
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] org.Hs.eg.db_3.4.0          AnnotationDbi_1.35.5       
##  [3] DESeq2_1.13.16              SummarizedExperiment_1.3.82
##  [5] Biobase_2.33.4              GenomicRanges_1.26.1       
##  [7] GenomeInfoDb_1.10.0         IRanges_2.8.0              
##  [9] S4Vectors_0.12.0            BiocGenerics_0.20.0        
## [11] BiocInstaller_1.24.0       
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.7         formatR_1.4         RColorBrewer_1.1-2 
##  [4] plyr_1.8.4          XVector_0.14.0      bitops_1.0-6       
##  [7] tools_3.3.1         zlibbioc_1.20.0     rpart_4.1-10       
## [10] digest_0.6.10       RSQLite_1.0.0       annotate_1.51.1    
## [13] evaluate_0.10       tibble_1.2          gtable_0.2.0       
## [16] lattice_0.20-34     Matrix_1.2-7.1      DBI_0.5-1          
## [19] yaml_2.1.13         gridExtra_2.2.1     genefilter_1.55.2  
## [22] stringr_1.1.0       knitr_1.14          cluster_2.0.5      
## [25] locfit_1.5-9.1      nnet_7.3-12         grid_3.3.1         
## [28] data.table_1.9.6    XML_3.98-1.4        survival_2.39-5    
## [31] BiocParallel_1.8.1  foreign_0.8-67      rmarkdown_1.1      
## [34] latticeExtra_0.6-28 Formula_1.2-1       geneplotter_1.51.0 
## [37] ggplot2_2.1.0       magrittr_1.5        Hmisc_3.17-4       
## [40] scales_0.4.0        htmltools_0.3.5     splines_3.3.1      
## [43] assertthat_0.1      xtable_1.8-2        colorspace_1.2-7   
## [46] stringi_1.1.2       acepack_1.3-3.3     RCurl_1.95-4.8     
## [49] munsell_0.4.3       chron_2.3-47