This workshop is an adapted version of a recently submitted workflow, which should soon be visible at https://f1000research.com/gateways/bioconductor and http://www.bioconductor.org/help/workflows/. It uses a smaller data set to speed up computation and reduce the required computational resources to run this code.

1 Introduction

RNA sequencing (RNA-seq) is now the most widely used high-throughput assay for measuring gene expression. In a typical RNA-seq experiment, several million reads are sequenced per sample. The reads are often aligned to the reference genome using a splice-aware aligner to identify where reads originated. Resulting alignment files are then used to compute count matrices which are used for several analyses such as identifying differentially expressed genes. The Bioconductor project (1) has many contributed packages that specialize in analyzing this type of data and previous workflows have explained how to use them (2–4). Initial steps are typically focused on generating the count matrices. Some pre-computed matrices have been made available via the ReCount project (5) or Bioconductor Experiment data packages such as the airway dataset (6). The count matrices in ReCount have helped others access RNA-seq data avoid having to run the processing pipelines required to compute these matrices. However, in the years since ReCount was published, hundreds of new RNA-seq projects have been carried out and researchers have publicly shared the data publicly.

We recently uniformly processed over 70,000 publicly available human RNA-seq samples and made the data available via the recount2 resource at jhubiostatistics.shinyapps.io/recount/ (7). Samples in recount2 are grouped by project (over 2,000) originating from the Sequence Read Archive, the Genotype-Tissue Expression study (GTEx) and the Cancer Genome Atlas (TCGA). The processed data can be accessed via the recount Bioconductor package available at bioconductor.org/packages/recount. Together, recount2 and the recount Bioconductor package should be considered a successor to ReCount.

Due to space constraints, the recount2 publication (7) did not cover how to use the recount package and other useful information for carrying out analyses with recount2 data. We describe how the count matrices in recount2 were generated. We also review the R code necessary for using the recount2 data, whose details are important because some of this code involves multiple Bioconductor packages and changing default options. We further show: a) how to augment metadata that comes with datasets with metadata learned from natural language processing of associated papers as well as expression data b) how to perform differential expression analyses, and c) how to visualize the base-pair data available from recount2.

1.1 recount2 overview

The recount2 resource provides expression data summarized at different feature levels to enable novel cross-study analyses. Generally when investigators use the term expression, they think about gene expression. But more information can be extracted from RNA-seq data. Once RNA-seq reads have been aligned to the reference genome it is possible to determine the number of aligned reads overlapping each base-pair resulting in the genome base-pair coverage curve as shown in Figure 1. In the example shown in Figure 1 most of the reads overlap known exons from a gene. Those reads can be used to compute a count matrix at the exon or gene feature levels. Some reads span exon-exon junctions (jx) and while most match the annotation, some do not (jx 3 and 4). An exon-exon junction count matrix can be used to identify differentially expressed junctions, which can show which isoforms are differentially expressed given sufficient coverage. For example, junctions 2 and 5 are unique to isoform 2, while junction 6 is unique to isoform 1. The genome base-pair coverage data can be used with derfinder (8) to identify expressed regions, some of them could be un-annotated exons and together with the exon-exon junction data uncover potential new isoforms.

Overview of the data available in recount2. Reads (pink boxes) aligned to the reference genome can be used to compute a base-pair coverage curve and identify exon-exon junctions (split reads). Gene and exon count matrices are generated using annotation information providing the gene (green boxes) and exon (blue boxes) coordinates together with the base-level coverage curve. The reads spanning exon-exon junctions (jx) are used to compute a third count matrix that might include un-annotated junctions (jx 3 and 4). Without using annotation information, expressed regions (orange box) can be determined from the base-level coverage curve to then construct data-driven count matrices.

Figure 1: Overview of the data available in recount2
Reads (pink boxes) aligned to the reference genome can be used to compute a base-pair coverage curve and identify exon-exon junctions (split reads). Gene and exon count matrices are generated using annotation information providing the gene (green boxes) and exon (blue boxes) coordinates together with the base-level coverage curve. The reads spanning exon-exon junctions (jx) are used to compute a third count matrix that might include un-annotated junctions (jx 3 and 4). Without using annotation information, expressed regions (orange box) can be determined from the base-level coverage curve to then construct data-driven count matrices.

recount2 provides gene, exon, and exon-exon junction count matrices both in text format and RangedSummarizedExperiment objects (rse) (9) as shown in Figure 2. These rse objects provide information about the expression features (for example gene ids) and the samples. In this workshop we will explain how to add metadata to the rse objects in recount2 in order to ask biological questions. recount2 also provides coverage data in the form of BigWig files. All four features can be accessed with the recount Bioconductor package (7). recount also allows sending queries to snaptron (10) to search for specific exon-exon junctions.

recount2 provides coverage count matrices in RangedSummarizedExperiment (rse) objects. Once the rse object has been downloaded and loaded into R, the feature information is accessed with rowRanges(rse) (blue box), the counts with assays(rse)\$counts (pink box) and the sample metadata with colData(rse) (green box). The sample metadata can be expanded using add\_predictions(rse) (orange box) or with custom code (brown box) matching by a unique sample identifier such as the SRA Run id. The rse object is inside the purple box and matching data is highlighted in each box.

Figure 2: recount2 provides coverage count matrices in RangedSummarizedExperiment (rse) objects
Once the rse object has been downloaded and loaded into R, the feature information is accessed with rowRanges(rse) (blue box), the counts with assays(rse)$counts (pink box) and the sample metadata with colData(rse) (green box). The sample metadata can be expanded using add_predictions(rse) (orange box) or with custom code (brown box) matching by a unique sample identifier such as the SRA Run id. The rse object is inside the purple box and matching data is highlighted in each box.

1.2 Packages used in the workshop

In this workshop we will use several Bioconductor packages. To reproduce the entirety of this workshop, install the packages using the following code after installing R 3.4.x from CRAN in order to use Bioconductor version 3.5 or newer.

## Install packages from Bioconductor
source("https://bioconductor.org/biocLite.R")
biocLite(c("recount", "GenomicRanges", "DESeq2", "ideal", "regionReport",
    "clusterProfiler", "org.Hs.eg.db", "gplots", "derfinder",
    "rtracklayer", "GenomicFeatures", "bumphunter", "derfinderPlot",
    "devtools"))

Once installed, load all of the packages with the following code.

library("recount")
library("GenomicRanges")
library("DESeq2")
library("ideal")
library("regionReport")
library("clusterProfiler")
library("org.Hs.eg.db")
library("gplots")
library("derfinder")
library("rtracklayer")
library("GenomicFeatures")
library("bumphunter")
library("derfinderPlot")
library("devtools")

2 Coverage counts provided by recount2

The most accessible features are the gene, exon and exon-exon junction count matrices. This section explains them in greater detail. Figure 3 shows 16 RNA-seq reads each 3 base-pairs long and a reference genome.

RNA-seq starting data. 16 RNA-seq un-aligned RNA-seq reads 3 base-pairs long are shown (pink boxes) along a reference genome 16 base-pairs long (white box).

Figure 3: RNA-seq starting data
16 RNA-seq un-aligned RNA-seq reads 3 base-pairs long are shown (pink boxes) along a reference genome 16 base-pairs long (white box).

Reads in the recount2 resource were aligned with Rail-RNA aligner (11) which is splice-aware and can soft clip reads. Figure 4 shows the reads aligned to the reference genome. Some of the reads are split as they span an exon-exon junction. Two of the reads were soft clipped meaning that just a portion of the reads aligned (top left in purple).

Aligned RNA-seq reads. Spice-aware RNA-seq aligners such as Rail-RNA are able to find the coordinates to which the reads map, even if they span exon-exon junctions (connected boxes). Rail-RNA soft clips some reads (purple boxes with rough edges) such that a portion of these reads align to the reference genome.

Figure 4: Aligned RNA-seq reads
Spice-aware RNA-seq aligners such as Rail-RNA are able to find the coordinates to which the reads map, even if they span exon-exon junctions (connected boxes). Rail-RNA soft clips some reads (purple boxes with rough edges) such that a portion of these reads align to the reference genome.

In order to compute the gene and exon count matrices we first have to process the annotation, which for recount2 is Gencode v25 (CHR regions) with hg38 coordinates. Although recount can generate count matrices for other annotations using hg38 coordinates. Figure 5 shows two isoforms for a gene composed of 3 different exons.

Gene annotation. A single gene with two isoforms composed by three distinct exons (blue boxes) is illustrated. Exons 1 and 3 share the first five base-pairs while exon 2 is common to both isoforms.

Figure 5: Gene annotation
A single gene with two isoforms composed by three distinct exons (blue boxes) is illustrated. Exons 1 and 3 share the first five base-pairs while exon 2 is common to both isoforms.

The coverage curve is at the base-pair resolution, so if we are interested in gene counts we have to be careful not to double count base-pairs 1 through 5 that are shared by exons 1 and 3 (Figure 5). Using the function disjoin() from GenomicRanges (12) we identified the distinct exonic sequences (disjoint exons). The following code defines the exon coordinates that match Figure 5 and the resulting disjoint exons for our example gene. The resulting disjoint exons are shown in Figure 6.

library("GenomicRanges")
exons <- GRanges("seq", IRanges(start = c(1, 1, 13), end = c(5, 8, 15)))
exons
## GRanges object with 3 ranges and 0 metadata columns:
##       seqnames    ranges strand
##          <Rle> <IRanges>  <Rle>
##   [1]      seq  [ 1,  5]      *
##   [2]      seq  [ 1,  8]      *
##   [3]      seq  [13, 15]      *
##   -------
##   seqinfo: 1 sequence from an unspecified genome; no seqlengths
disjoin(exons)
## GRanges object with 3 ranges and 0 metadata columns:
##       seqnames    ranges strand
##          <Rle> <IRanges>  <Rle>
##   [1]      seq  [ 1,  5]      *
##   [2]      seq  [ 6,  8]      *
##   [3]      seq  [13, 15]      *
##   -------
##   seqinfo: 1 sequence from an unspecified genome; no seqlengths
Disjoint exons. Windows of distinct exonic sequence for the example gene. Disjoint exons 1 and 2 form exon 1.

Figure 6: Disjoint exons
Windows of distinct exonic sequence for the example gene. Disjoint exons 1 and 2 form exon 1.

Now that we have disjoint exons, we can compute the base-pair coverage for each of them as shown in Figure 7. That is, for each base-pair that corresponds to exonic sequence, we compute the number of reads overlapping that given base-pair. For example, the first base-pair is covered by 3 different reads and it does not matter whether the reads themselves were soft clipped. Not all reads or bases of a read contribute information to this step as some do not overlap known exonic sequence (light pink in Figure 7).

Base-pair coverage counting for exonic base-pairs. At each exonic base-pair we compute the number of reads overlapping that given base-pair. The first base (orange arrow) has 3 reads overlapping that base-pair. Base-pair 11 has a coverage of 3 but does not overlap known exonic sequence, so that information is not used for the gene and exon count matrices (grey arrow). If a read partially overlaps exonic sequence, only the portion that overlaps is used in the computation (see right most read).

Figure 7: Base-pair coverage counting for exonic base-pairs
At each exonic base-pair we compute the number of reads overlapping that given base-pair. The first base (orange arrow) has 3 reads overlapping that base-pair. Base-pair 11 has a coverage of 3 but does not overlap known exonic sequence, so that information is not used for the gene and exon count matrices (grey arrow). If a read partially overlaps exonic sequence, only the portion that overlaps is used in the computation (see right most read).

With base-pair coverage for the exonic sequences computed, the coverage count for each distinct exon is simply the sum of the base-pair coverage for each base in a given distinct exon. For example, the coverage count for disjoint exon 2 is \(2 + 2 + 3 = 7\) as shown in Figure 8. The gene coverage count is then \(\sum_i^n \texttt{coverage}_i\) where \(n\) is the number of exonic base-pairs for the gene and is equal to the sum of the coverage counts for its disjoint exons as shown in Figure 8.

Exon and gene coverage counts. The coverage counts for each disjoint exon are the sum of the base-pair coverage. The gene coverage count is the sum of the disjoint exons coverage counts.

Figure 8: Exon and gene coverage counts
The coverage counts for each disjoint exon are the sum of the base-pair coverage. The gene coverage count is the sum of the disjoint exons coverage counts.

For the exons, recount2 provides the disjoint exons coverage count matrix. It is possible to reconstruct the exon coverage count matrix by summing the coverage count for the disjoint exons that compose each exon. For example, the coverage count for exon 1 would be the sum of the coverage counts for disjoint exons 1 and 2, that is \(19 + 7 = 26\). Some methods might assume that double counting of the shared base-pairs was performed while others assume or recommend the opposite.

2.1 Scaling coverage counts

The coverage counts described previously are the ones actually included in the rse objects in recount2 instead of typical read count matrices. This is an important difference to keep in mind as most methods were developed for read count matrices. Part of the sample metadata available from recount2 includes the read length and number of mapped reads. Given a target library size (40 million reads by default), the coverage counts in recount2 can be scaled to read counts for a given library size as shown in Equation (1). Note that the resulting scaled read counts are not necessarily integers so it might be neccessary to round them if a differential expression method assumes integer data.

\[\begin{equation} \frac{\sum_i^n \text{coverage}_i }{\text{Read Length}} * \frac{\text{target}}{\text{mapped}} = \text{scaled read counts} \tag{1} \end{equation}\]

From Figure 4 we know that Rail-RNA soft clipped some reads, so a more precise measure than the denominator of Equation (1) is the area under coverage (AUC) which is the sum of the coverage for all base-pairs of the genome, regardless of the annotation as shown in Figure 9. Without soft clipping reads, the AUC would be equal to the number of reads mapped multiplied by the read length. So for our example gene, the scaled counts for a library size of 20 reads would be \(\frac{36}{45} * 20 = 16\) and in general calculated with Equation (2). The following code shows how to compute the AUC given a set of aligned reads and reproduce a portion of Figure 9.

\[\begin{equation} \frac{\sum_i^n \text{coverage}_i }{\text{AUC}} * \text{target} = \text{scaled read counts} \tag{2} \end{equation}\]
## Take the example and translate it to R code
library("GenomicRanges")
reads <- GRanges("seq", IRanges(
    start = rep(
        c(1, 2, 3, 4, 5, 7, 8, 9, 10, 13, 14), 
        c(3, 1, 2, 1, 2, 1, 2, 1, 2, 4, 1)
    ), width = rep(
        c(1, 3, 2, 3, 1, 2, 1, 3, 2, 3, 2, 1, 3),
        c(1, 4, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1)
    )
))
## Get the base-level genome coverage curve
cov <- as.integer(coverage(reads)$seq)

## AUC
sum(cov)
## [1] 45
## Code for reproducing the bottom portion of Figure 8.
pdf("base_pair_coverage.pdf", width = 20)
par(mar = c(5, 6, 4, 2) + 0.1)
plot(cov, type = "o", col = "violetred1", lwd = 10, ylim = c(0, 5),
     xlab = "Genome", ylab = "Coverage", cex.axis = 2, cex.lab = 3,
     bty = "n")
polygon(c(1, seq_len(length(cov)), length(cov)), c(0, cov, 0),
        border = NA, density = -1, col = "light blue")
points(seq_len(length(cov)), cov, col = "violetred1", type = "o",
       lwd = 10)
dev.off()
Area under coverage (AUC). The area under coverage is the sum of the base-pair coverage for all positions in the genome regardless of the annotation. It is the area under the base-level coverage curve shown as the light blue area under the pink curve.

Figure 9: Area under coverage (AUC)
The area under coverage is the sum of the base-pair coverage for all positions in the genome regardless of the annotation. It is the area under the base-level coverage curve shown as the light blue area under the pink curve.

The recount function scale_counts() computes the scaled read counts for a target library size of 40 million reads and we highly recommend using it before doing other analyses. The following code shows how to use scale_counts() and that the resulting read counts per sample can be lower than the target size (40 million). This happens when not all mapped reads overlap known exonic base-pairs of the genome. In our example, the gene has a scaled count of 16 reads for a library size of 20 reads, meaning that 4 reads did not overlap exonic sequences.

## Check that the number of reads is less than or equal to 40 million
## after scaling.
library("recount")
rse_scaled <- scale_counts(rse_gene_SRP009615, round = FALSE)
summary(colSums(assays(rse_scaled)$counts)) / 1e6
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   22.62   29.97   34.00   31.96   34.86   36.78

2.2 Enriching the annotation

Data in recount2 can be used for annotation-agnostic analyses and enriching the known annotation. Just like exon and gene coverage count matrices, recount2 provides exon-exon junction count matrices. These matrices can be used to identify new isoforms (Figure 10) or identify differentially expressed isoforms. For example, exon-exon junctions 2, 5 and 6 in Figure 1 are only present in one annotated isoform. Snaptron (10) allows programatic and high-level queries of the exon-exon junction information and it is graphical user interface is specially useful for visualizing this data. Inside R, the recount function snaptron_query() can be used for searching specific exon-exon junctions in recount2.

Exon-exon junctions go beyond the annotation. Reads spanning exon-exon junctions are highlighted and compared against the annotation. Three of them match the annotated junctions, but one (blue and orange read) spans an un-annotated exon-exon junction with the left end matching the annotation and the right end hinting at a possible new isoform for this gene (blue and orange isoform).

Figure 10: Exon-exon junctions go beyond the annotation
Reads spanning exon-exon junctions are highlighted and compared against the annotation. Three of them match the annotated junctions, but one (blue and orange read) spans an un-annotated exon-exon junction with the left end matching the annotation and the right end hinting at a possible new isoform for this gene (blue and orange isoform).

The base-pair coverage data from recount2 can be used together with derfinder (8) to identify expressed regions of the genome, providing another annotation-agnostic analysis of the expression data. Using the function expressed_regions() we can identify regions of expression based on a given data set in recount2. These regions might overlap known exons but can also provide information about intron retention events (Figure 11), improve detection of exon boundaries (Figure 12), and help identify new exons (Fig 1) or expressed sequences in intergenic regions. Using coverage_matrix() we can compute a coverage matrix based on the expressed regions or another set of genomic intervals. The resulting matrix can then be used for a differential expression analysis, just like the exon, gene and exon-exon junction matrices.

Intron retention events. Some reads might align with known intronic segments of the genome and provide information for exploring intron retention events (pink read). Some might support an intron retention event or a new isoform when coupled with exon-exon junction data (orange read).

Figure 11: Intron retention events
Some reads might align with known intronic segments of the genome and provide information for exploring intron retention events (pink read). Some might support an intron retention event or a new isoform when coupled with exon-exon junction data (orange read).

Exon boundaries. Reads that go beyond the known exon boundaries can inform us of whether the annotated boundaries are correct or if there was a run-off transcription event.

Figure 12: Exon boundaries
Reads that go beyond the known exon boundaries can inform us of whether the annotated boundaries are correct or if there was a run-off transcription event.

3 Gene level analysis

Having reviewed how the coverage counts in recount2 were produced, we can now do a differential expression analysis. We will use data from GSE67333 (13) whose overall design was: We performed directional RNA sequencing on high quality RNA samples extracted from hippocampi of 4 late onset Alzheimer’s disease (LOAD) and 4 age-matched controls. The function download_study() requires a SRA accession id which can be found using abstract_search(). download_study() can then be used to download the gene coverage count data as well as other expression features. The files are saved in a directory named after the SRA accession id, in this case SRP056604.

To facilitate this workshop, we included the data in the recountWorkshop package. It can be located with the system.file() function as shown below.

## Locate path with the data
library("recountWorkshop")
local_path <- system.file("extdata", "SRP056604", package = "recountWorkshop")
dir(local_path)
## [1] "SRP056604.tsv"   "SraRunTable.txt" "bw"              "rse_exon.Rdata" 
## [5] "rse_gene.Rdata"

The commands should work with the data hosted from recount2 if there are no problems with the wifi connection. Although we prefer that you use the pre-installed data for this workshop.

library("recount")

## Find the project id by searching abstracts of studies
abstract_search("hippocampi of 4")
##      number_samples species
## 1643              8   human
##                                                                                                                                                                                                                                                                                                                                                                                                    abstract
## 1643 Our data provide a comprehensive list of transcriptomics alterations and warrant holistic approach including both coding and non-coding RNAs in functional studies aimed to understand the pathophysiology of LOAD Overall design: We performed directional RNA sequencing on high quality RNA samples extracted from hippocampi of 4 late onset Alzheimer's diseas (LOAD) and 4 age-matched controls.
##        project
## 1643 SRP056604
## Download the data if it is not there
if(!file.exists(file.path(local_path, "rse_gene.Rdata"))) {
    ## In case you decide to download the data instead of using the
    ## pre-installed data
    local_path <- "SRP056604"
    download_study("SRP056604", type = "rse-gene")
}

## Check that the file was downloaded
file.exists(file.path(local_path, "rse_gene.Rdata"))
## [1] TRUE
## Load the data
load(file.path(local_path, "rse_gene.Rdata"))

The coverage count matrices are provided as RangedSummarizedExperiment objects (rse) (9). These objects store information at the feature level, the samples and the actual count matrix as shown in Figure 1 of Love et al., 2016 (3). Figure 2 shows the actual rse objects provided by recount2 and how to access the different portions of the data. Using a unique sample id such as the SRA Run id it is possible to expand the sample metadata. This can be done using the predicted phenotype provided by add_predictions() (14), pulling information from GEO via find_geo() and geo_characteristics(), or with custom code.

3.1 Metadata

Using the colData() function we can access sample metadata. More information on these metadata is provided in the supplementary material of the recount2 paper (7), and we provide a brief review here. The rse objects for SRA data sets include 21 columns with mostly technical information. The GTEx and TCGA rse objects include additional metadata as available from the raw sources. In particular, we compiled metadata for GTEx using the v6 phenotype information available at gtexportal.org, and we put together a large table of TCGA case and sample information by combining information accumulated across Seven Bridges’ Cancer Genomics Cloud and TCGAbiolinks (15).

## One row per sample, one column per phenotype variable
dim(colData(rse_gene))
## [1]  8 21
## Mostly technical variables are included
colnames(colData(rse_gene))
##  [1] "project"                                       
##  [2] "sample"                                        
##  [3] "experiment"                                    
##  [4] "run"                                           
##  [5] "read_count_as_reported_by_sra"                 
##  [6] "reads_downloaded"                              
##  [7] "proportion_of_reads_reported_by_sra_downloaded"
##  [8] "paired_end"                                    
##  [9] "sra_misreported_paired_end"                    
## [10] "mapped_read_count"                             
## [11] "auc"                                           
## [12] "sharq_beta_tissue"                             
## [13] "sharq_beta_cell_type"                          
## [14] "biosample_submission_date"                     
## [15] "biosample_publication_date"                    
## [16] "biosample_update_date"                         
## [17] "avg_read_length"                               
## [18] "geo_accession"                                 
## [19] "bigwig_file"                                   
## [20] "title"                                         
## [21] "characteristics"

3.1.1 Technical variables

Several of these technical variables include the number of reads as reported by SRA, the actual number of reads Rail-RNA was able to download (which might be lower in some cases), the number of reads mapped by Rail-RNA, whether the sample is paired-end or not, the coverage AUC and the average read length (times 2 for paired-end samples). Note that sample with SRA Run id SRR2071341 has about 240.8 million reads as reported by SRA, while it has 120.4 million spots reported in https://trace.ncbi.nlm.nih.gov/Traces/sra/?run=SRR2071341; that is because it is a paired-end sample (2 reads per spot). These details are important for those interested on writing alternative scaling functions to scale_counts().

## Input reads: number reported by SRA might be larger than number
## of reads Rail-RNA downloaded
colData(rse_gene)[, c("read_count_as_reported_by_sra", "reads_downloaded")]
## DataFrame with 8 rows and 2 columns
##            read_count_as_reported_by_sra reads_downloaded
##                                <integer>        <integer>
## SRR1931819                     170053030        170053030
## SRR1931818                     164772379        164772379
## SRR1931817                     173894719        173894719
## SRR1931816                     177108169        177108169
## SRR1931815                     188604801        188604801
## SRR1931814                     178521597        178521597
## SRR1931813                     180318237        180318237
## SRR1931812                     187514717        187514717
summary(colData(rse_gene)$proportion_of_reads_reported_by_sra_downloaded)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       1       1       1       1       1       1
## AUC information used by scale_counts() by default
head(colData(rse_gene)$auc)
## [1] 14058249889 13996129504 13578647527 14599138400 16423440640 15559854293
## Alternatively, scale_scounts() can use the number of mapped reads
## and other information
colData(rse_gene)[, c("mapped_read_count", "paired_end", "avg_read_length")]
## DataFrame with 8 rows and 3 columns
##            mapped_read_count paired_end avg_read_length
##                    <integer>  <logical>       <integer>
## SRR1931819         160584474      FALSE              99
## SRR1931818         155722526      FALSE              99
## SRR1931817         164110375      FALSE              99
## SRR1931816         165119594      FALSE              99
## SRR1931815         180961318      FALSE              99
## SRR1931814         170579381      FALSE              99
## SRR1931813         171525236      FALSE              99
## SRR1931812         178912737      FALSE              99

3.1.2 Biological information

Other metadata variables included provide more biological information, such as the SHARQ beta tissue and cell type predictions, which are based on processing the abstract of papers. This information is available for some of the SRA projects.

## SHARQ tissue predictions: not present for all studies
head(colData(rse_gene)$sharq_beta_tissue)
## [1] NA NA NA NA NA NA
head(colData(rse_gene_SRP009615)$sharq_beta_tissue)
## [1] "blood" "blood" "blood" "blood" "blood" "blood"

For some data sets we were able to find the GEO accession ids, which we then used to create the title and characteristics variables. If present, the characteristics information can be used to create additional metadata variables by parsing the CharacterList in which it is stored. Since the input is free text, sometimes more than one type of wording is used to describe the same information. Meaning that we might have to process that information in order to build a more convenient variable, such as a factor vector.

## GEO information was absent for the SRP056604 data set
colData(rse_gene)[, c("geo_accession", "title", "characteristics")]
## DataFrame with 8 rows and 3 columns
##            geo_accession       title
##              <character> <character>
## SRR1931819    GSM1645003       CTRL4
## SRR1931818    GSM1645002       CTRL3
## SRR1931817    GSM1645001       CTRL2
## SRR1931816    GSM1645000       CTRL1
## SRR1931815    GSM1644999       LOAD4
## SRR1931814    GSM1644998       LOAD3
## SRR1931813    GSM1644997       LOAD2
## SRR1931812    GSM1644996       LOAD1
##                                                                                     characteristics
##                                                                                     <CharacterList>
## SRR1931819                      age (yrs): 85,subject group: age-matched control,gender: female,...
## SRR1931818                       age (yrs): >90,subject group: age-matched control,gender: male,...
## SRR1931817                        age (yrs): 83,subject group: age-matched control,gender: male,...
## SRR1931816                      age (yrs): 77,subject group: age-matched control,gender: female,...
## SRR1931815 age (yrs): 82,subject group: LOAD (late onset of Alzheimer’s disease),gender: female,...
## SRR1931814   age (yrs): 83,subject group: LOAD (late onset of Alzheimer’s disease),gender: male,...
## SRR1931813 age (yrs): 87,subject group: LOAD (late onset of Alzheimer’s disease),gender: female,...
## SRR1931812 age (yrs): 82,subject group: LOAD (late onset of Alzheimer’s disease),gender: female,...
## GEO information for the SRP009615 data set
head(colData(rse_gene_SRP009615)$geo_accession)
## [1] "GSM836270" "GSM836271" "GSM836272" "GSM836273" "GSM847561" "GSM847562"
head(colData(rse_gene_SRP009615)$title, 2)
## [1] "K562 cells with shRNA targeting SRF gene cultured with no doxycycline (uninduced - UI), rep1." 
## [2] "K562 cells with shRNA targeting SRF gene cultured with doxycycline for 48 hours (48 hr), rep1."
head(colData(rse_gene_SRP009615)$characteristics, 2)
## CharacterList of length 2
## [[1]] cells: K562 shRNA expression: no treatment: Puromycin
## [[2]] cells: K562 shRNA expression: yes, targeting SRF treatment: Puromycin, doxycycline
## Similar but not exactly the same wording used for two different samples
colData(rse_gene_SRP009615)$characteristics[[1]]
## [1] "cells: K562"          "shRNA expression: no" "treatment: Puromycin"
colData(rse_gene_SRP009615)$characteristics[[11]]
## [1] "cell line: K562"                      
## [2] "shRNA expression: no shRNA expression"
## [3] "treatment: Puromycin"
## For study SRP056604 we have characteristics information
## Note the > symbol in the age for the second sample
colData(rse_gene)$characteristics[[1]]
## [1] "age (yrs): 85"                      "subject group: age-matched control"
## [3] "gender: female"                     "apoe genotype: 2/3"                
## [5] "braak stage: II"                    "tissue: Hippocampus"
colData(rse_gene)$characteristics[[2]]
## [1] "age (yrs): >90"                     "subject group: age-matched control"
## [3] "gender: male"                       "apoe genotype: 3/3"                
## [5] "braak stage: II"                    "tissue: Hippocampus"

Since we have the characteristics information for study SRP056604, lets extract some data from them. We can extract the case status, sex and age.

## Get the case status: either LOAD or control
colData(rse_gene)$case <- factor(
    sapply(colData(rse_gene)$characteristics, function(x)
        ifelse(any(grepl("LOAD", x)), "control", "LOAD"))
)

## Get the sex
colData(rse_gene)$sex <- factor(
    sapply(colData(rse_gene)$characteristics, function(x)
        ifelse(any(grepl("female", x)),
    "female", "male"))
)

## Extract the age. Note that one of them is a bit more complicated.
colData(rse_gene)$age <- sapply(colData(rse_gene)$characteristics,
    function(x) {
        y <- x[grep("age.*(yrs)", x)]
        as.integer(gsub("age.*\\(yrs\\): |>", "", y))
    }
)

Now that we have added the biological metadata variables, we can explore them.

table(colData(rse_gene)$case, colData(rse_gene)$sex)
##          
##           female male
##   LOAD         2    2
##   control      3    1
table(colData(rse_gene)$case, colData(rse_gene)$age)
##          
##           77 82 83 85 87 90
##   LOAD     1  0  1  1  0  1
##   control  0  2  1  0  1  0

From the previous tables, case seems to be balanced by sex and age.

As shown in Figure 2, we can expand the biological metadata information by adding predictions based on RNA-seq data (14). The predictions include information about sex, sample source (cell line vs tissue), tissue and the sequencing strategy used. To add the predictions, simply use the function add_predictions() to expand the colData() slot.

## Before adding predictions
dim(colData(rse_gene))
## [1]  8 24
## Add the predictions
rse_gene <- add_predictions(rse_gene)
## 2017-08-01 15:04:49 downloading the predictions to /tmp/RtmpGpAsDF/PredictedPhenotypes_v0.0.03.rda
## After adding the predictions
dim(colData(rse_gene))
## [1]  8 36
## Explore the variables
colData(rse_gene)[, 25:ncol(colData(rse_gene))]
## DataFrame with 8 rows and 12 columns
##            reported_sex predicted_sex accuracy_sex reported_samplesource
##                <factor>      <factor>    <numeric>              <factor>
## SRR1931819           NA          male    0.8428571                tissue
## SRR1931818           NA          male    0.8428571                tissue
## SRR1931817           NA        female    0.8428571                tissue
## SRR1931816           NA        female    0.8428571                tissue
## SRR1931815           NA        female    0.8428571                tissue
## SRR1931814           NA        female    0.8428571                tissue
## SRR1931813           NA          male    0.8428571                tissue
## SRR1931812           NA        female    0.8428571                tissue
##            predicted_samplesource accuracy_samplesource reported_tissue
##                          <factor>             <numeric>        <factor>
## SRR1931819                 tissue             0.8923497              NA
## SRR1931818                 tissue             0.8923497              NA
## SRR1931817                 tissue             0.8923497              NA
## SRR1931816                 tissue             0.8923497              NA
## SRR1931815                 tissue             0.8923497              NA
## SRR1931814                 tissue             0.8923497              NA
## SRR1931813                 tissue             0.8923497              NA
## SRR1931812                 tissue             0.8923497              NA
##            predicted_tissue accuracy_tissue reported_sequencingstrategy
##                    <factor>       <numeric>                    <factor>
## SRR1931819            Brain       0.4707854                      SINGLE
## SRR1931818            Brain       0.4707854                      SINGLE
## SRR1931817            Brain       0.4707854                      SINGLE
## SRR1931816            Brain       0.4707854                      SINGLE
## SRR1931815            Brain       0.4707854                      SINGLE
## SRR1931814            Brain       0.4707854                      SINGLE
## SRR1931813            Brain       0.4707854                      SINGLE
## SRR1931812            Brain       0.4707854                      SINGLE
##            predicted_sequencingstrategy accuracy_sequencingstrategy
##                                <factor>                   <numeric>
## SRR1931819                       SINGLE                   0.8915381
## SRR1931818                       SINGLE                   0.8915381
## SRR1931817                       SINGLE                   0.8915381
## SRR1931816                       SINGLE                   0.8915381
## SRR1931815                       SINGLE                   0.8915381
## SRR1931814                       SINGLE                   0.8915381
## SRR1931813                       SINGLE                   0.8915381
## SRR1931812                       SINGLE                   0.8915381

From the predictions, we see that all samples are predicted to be from the brain, which matches the samples description. We also have predicted sex which we can compare against the reported sex.

table("Observed" = colData(rse_gene)$sex,
    "Predicted" = colData(rse_gene)$predicted_sex)
##         Predicted
## Observed female male Unassigned
##   female      3    2          0
##   male        2    1          0

We have 4 sex prediction mismatches, which is very high. Let’s explore whether the sex is matching is related to other variables.

## Is the sex matching? TRUE for yes.
colData(rse_gene)$matching_sex <- as.character(colData(rse_gene)$sex) ==
    as.character(colData(rse_gene)$predicted_sex)

## Matching sex vs other variables
table(colData(rse_gene)$matching_sex, colData(rse_gene)$case)
##        
##         LOAD control
##   FALSE    2       2
##   TRUE     2       2
table(colData(rse_gene)$matching_sex, colData(rse_gene)$age)
##        
##         77 82 83 85 87 90
##   FALSE  0  0  2  1  1  0
##   TRUE   1  2  0  0  0  1
boxplot(colData(rse_gene)$mapped_read_count ~ colData(rse_gene)$matching_sex,
    ylab = "Mapped read count", xlab = "Matching sex")

There are no discernible differences by case, age or mapped read count when compared with the matching sex status.

3.1.3 Adding more information

Ultimately, more sample metadata information could be available elsewhere which can be useful for analyses. This information might be provided in the paper describing the data, the SRA Run Selector or other sources. As shown in Figure 2, it is possible to append information to the colData() slot as long as there is a unique sample identifier such as the SRA Run id.

For our example use case, project SRP056604 has redundant information with the characteristics and the SRA Run selector https://trace.ncbi.nlm.nih.gov/Traces/study/?acc=SRP056604. However, this might not be the case for other projects. While the SRA Run Selector information is redundant in this case, we can practice adding it. We can download that information into text file named SraRunTable.txt by default, then load it into R, sort it appropriately and then append it to the colData() slot. Below we do so for the SRP056604 project.

## Save the information from 
## https://trace.ncbi.nlm.nih.gov/Traces/study/?acc=SRP056604
## to a table. We saved the file as SRP056604/SraRunTable.txt.
file.exists(file.path(local_path, "SraRunTable.txt"))
## [1] TRUE
## Read the table
sra <- read.table(file.path(local_path, "SraRunTable.txt"),
    header = TRUE, sep = "\t")

## Explore it
head(sra)
##    BioSample_s Experiment_s MBases_l MBytes_l      Run_s SRA_Sample_s
## 1 SAMN03448725    SRX970047    17703    12139 SRR1931812    SRS885256
## 2 SAMN03448726    SRX970048    17024    11659 SRR1931813    SRS885255
## 3 SAMN03448730    SRX970049    16854    11560 SRR1931814    SRS885254
## 4 SAMN03448728    SRX970050    17806    12561 SRR1931815    SRS885253
## 5 SAMN03448727    SRX970051    16721    11576 SRR1931816    SRS885252
## 6 SAMN03448729    SRX970052    16418    11424 SRR1931817    SRS885251
##   Sample_Name_s apoe_genotype_s braak_stage_s gender_s
## 1    GSM1644996             3/3            VI   female
## 2    GSM1644997             3/3             V   female
## 3    GSM1644998             3/3            VI     male
## 4    GSM1644999             3/3            VI   female
## 5    GSM1645000             2/3             I   female
## 6    GSM1645001   Not available            II     male
##                    source_name_s                          subject_group_s
## 1                LOAD_hippocampi LOAD (late onset of Alzheimer’s disease)
## 2                LOAD_hippocampi LOAD (late onset of Alzheimer’s disease)
## 3                LOAD_hippocampi LOAD (late onset of Alzheimer’s disease)
## 4                LOAD_hippocampi LOAD (late onset of Alzheimer’s disease)
## 5 age-matched control_hippocampi                      age-matched control
## 6 age-matched control_hippocampi                      age-matched control
##   Assay_Type_s AvgSpotLen_l BioProject_s Center_Name_s Consent_s
## 1      RNA-Seq           99  PRJNA279526           GEO    public
## 2      RNA-Seq           99  PRJNA279526           GEO    public
## 3      RNA-Seq           99  PRJNA279526           GEO    public
## 4      RNA-Seq           99  PRJNA279526           GEO    public
## 5      RNA-Seq           99  PRJNA279526           GEO    public
## 6      RNA-Seq           99  PRJNA279526           GEO    public
##   InsertSize_l        Instrument_s LibraryLayout_s LibrarySelection_s
## 1            0 Illumina HiSeq 2000          SINGLE               cDNA
## 2            0 Illumina HiSeq 2000          SINGLE               cDNA
## 3            0 Illumina HiSeq 2000          SINGLE               cDNA
## 4            0 Illumina HiSeq 2000          SINGLE               cDNA
## 5            0 Illumina HiSeq 2000          SINGLE               cDNA
## 6            0 Illumina HiSeq 2000          SINGLE               cDNA
##   LibrarySource_s LoadDate_s   Organism_s Platform_s ReleaseDate_s
## 1  TRANSCRIPTOMIC 2015-03-26 Homo sapiens   ILLUMINA    2015-04-01
## 2  TRANSCRIPTOMIC 2015-03-26 Homo sapiens   ILLUMINA    2015-04-01
## 3  TRANSCRIPTOMIC 2015-03-26 Homo sapiens   ILLUMINA    2015-04-01
## 4  TRANSCRIPTOMIC 2015-03-26 Homo sapiens   ILLUMINA    2015-04-01
## 5  TRANSCRIPTOMIC 2015-03-26 Homo sapiens   ILLUMINA    2015-04-01
## 6  TRANSCRIPTOMIC 2015-03-26 Homo sapiens   ILLUMINA    2015-04-01
##   SRA_Study_s    tissue_s
## 1   SRP056604 Hippocampus
## 2   SRP056604 Hippocampus
## 3   SRP056604 Hippocampus
## 4   SRP056604 Hippocampus
## 5   SRP056604 Hippocampus
## 6   SRP056604 Hippocampus
## We will remove some trailing '_s' from the variable names
colnames(sra) <- gsub("_s$", "", colnames(sra))

## Choose some variables we want to add
sra_vars <- c("braak_stage", "gender", "tissue")

## Re-organize the SRA table based on the SRA Run ids we have
sra <- sra[match(colData(rse_gene)$run, sra$Run), ]

## Double check the order
identical(colData(rse_gene)$run, as.character(sra$Run))
## [1] TRUE
## Append the variables of interest
colData(rse_gene) <- cbind(colData(rse_gene), sra[, sra_vars])

## Final dimensions
dim(colData(rse_gene))
## [1]  8 40
## Explore result
colData(rse_gene)[, 38:ncol(colData(rse_gene))]
## DataFrame with 8 rows and 3 columns
##            braak_stage   gender      tissue
##               <factor> <factor>    <factor>
## SRR1931819          II   female Hippocampus
## SRR1931818          II     male Hippocampus
## SRR1931817          II     male Hippocampus
## SRR1931816           I   female Hippocampus
## SRR1931815          VI   female Hippocampus
## SRR1931814          VI     male Hippocampus
## SRR1931813           V   female Hippocampus
## SRR1931812          VI   female Hippocampus
## The sex information from the 'characteristics' and the
## SRA Run Selector match
table(colData(rse_gene)$gender, colData(rse_gene)$sex)
##         
##          female male
##   female      5    0
##   male        0    3

3.2 DE setup

Now that we have all the metadata available we can perform a differential expression analysis. Lets look for differences by case when adjusting for the sex and age of the sample.

As we saw earlier in Figure 9, it is important to scale the coverage counts to read counts. To highlight the fact that we scaled the counts, we will use a new object name and delete the previous one. However, in practice we would simply overwrite the rse object with the output of scale_counts(rse).

## Scale counts
rse_gene_scaled <- scale_counts(rse_gene)

## To highlight that we scaled the counts
rm(rse_gene)

3.3 DE analysis

Now that we have scaled the counts, there are multiple differential expression packages we could use as described elsewhere (2,3). Since we have very few samples per group, we will use DESeq2 (16). The model we will use will test for differential expression between LOAD and control samples, adjusting for sex and age. In a real use case we might have to explore the results with different models.

library("DESeq2")

## Specify design and switch to DESeq2 format
dds <- DESeqDataSet(rse_gene_scaled, ~ sex + age + case)
## converting counts to integer mode
## the design formula contains a numeric variable with integer values,
##   specifying a model with increasing fold change for higher values.
##   did you mean for this to be a factor? if so, first convert
##   this variable to a factor using the factor() function
## it appears that the last variable in the design formula, 'case',
##   has a factor level, 'control', which is not the reference level. we recommend
##   to use factor(...,levels=...) or relevel() to set this as the reference level
##   before proceeding. for more information, please see the 'Note on factor levels'
##   in vignette('DESeq2').
## Perform DE analysis
dds <- DESeq(dds, test = "LRT", reduced = ~ sex + age, fitType = "local")
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## final dispersion estimates
## fitting model and testing
res <- results(dds, alpha = 0.01)

## Explore results
plotMA(res, main="DESeq2 results for SRP056604")

We can use ideal (17) to make a volcano plot of the DE results.

## Make a volcano plot
library("ideal")
plot_volcano(res, FDR = 0.01)

Having run the DE analysis, we can explore some of the top results either with an MA plot and a volcano plot. Both reveal very strong and widespread differential expression signal.

3.4 DE report

Now that we have the differential expression results, we can use some of the tools with the biocView ReportWriting to create a report. One of them is regionReport (18) which can create reports from DESeq2 (16) and edgeR (19) results. It can also handle limma-voom (20) results by making them look like DESeq2 results.

We can now create the report, which should open automatically in a browser.

## Make a report with the results
library("regionReport")
DESeq2Report(dds, res = res, project = "SRP056604",
    intgroup = c("sex", "case"), outdir = ".",
    output = "SRP056604_main-results")

If the report does not open automatically, we can open it with browseURL().

browseURL("SRP056604_main-results.html")

3.5 GO enrichment

Using clusterProfiler (21) we can then perform several enrichment analyses. The gene names from the recount2 objects use Gencode ids, which do not work by default with org.Hs.eg.db. To make sure they do, we can simply change the ids to Ensembl ids. Here we show how to perform an enrichment analysis using the biological process ontology. We will the genes that have a p-value as the universe background.

library("clusterProfiler")
library("org.Hs.eg.db")

## Remember that dds had ENSEMBL ids for the genes
ensembl <- gsub("\\..*", "", rownames(dds))
head(ensembl)
## [1] "ENSG00000000003" "ENSG00000000005" "ENSG00000000419" "ENSG00000000457"
## [5] "ENSG00000000460" "ENSG00000000938"
## Not all genes have a p-value
table(!is.na(res$padj))
## 
## FALSE  TRUE 
## 25863 32174
## Perform enrichment analysis for Biological Process (BP)
## Note that the argument is keytype instead of keyType in Bioconductor 3.5
enrich_go <- enrichGO(gene = ensembl[which(res$padj < 0.05)],
    OrgDb = org.Hs.eg.db, keyType = "ENSEMBL", ont = "BP",
    pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05,
    universe = ensembl[!is.na(res$padj)])

## Visualize enrichment results
dotplot(enrich_go)

Several other analyses can be performed with the resulting list of differentially expressed genes as described previously (2,3), although that is beyond the scope of this workshop.

3.6 Secondary analysis

Since we noticed that the sex predictions and the reported sex do not match for half of the samples, we can check if there are any genes associated with whether the sex matched.

## DE analysis checking what genes are different by matching sex
dds2 <- DESeqDataSet(rse_gene_scaled, ~ matching_sex)
## converting counts to integer mode
dds2 <- DESeq(dds2, test = "LRT", reduced = ~ 1, fitType = "local")
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## final dispersion estimates
## fitting model and testing
res2 <- results(dds2, alpha = 0.01)

## Visually inspect results
plotMA(res2, main="DESeq2 results for SRP056604 - sex predictions")

## Lets add gene symbols to the volcano plot, they are stored in
## the rowRanges slot of the rse object
rowRanges(rse_gene_scaled)
## GRanges object with 58037 ranges and 3 metadata columns:
##                      seqnames                 ranges strand |
##                         <Rle>              <IRanges>  <Rle> |
##   ENSG00000000003.14     chrX [100627109, 100639991]      - |
##    ENSG00000000005.5     chrX [100584802, 100599885]      + |
##   ENSG00000000419.12    chr20 [ 50934867,  50958555]      - |
##   ENSG00000000457.13     chr1 [169849631, 169894267]      - |
##   ENSG00000000460.16     chr1 [169662007, 169854080]      + |
##                  ...      ...                    ...    ... .
##    ENSG00000283695.1    chr19 [ 52865369,  52865429]      - |
##    ENSG00000283696.1     chr1 [161399409, 161422424]      + |
##    ENSG00000283697.1     chrX [149548210, 149549852]      - |
##    ENSG00000283698.1     chr2 [112439312, 112469687]      - |
##    ENSG00000283699.1    chr10 [ 12653138,  12653197]      - |
##                                 gene_id bp_length          symbol
##                             <character> <integer> <CharacterList>
##   ENSG00000000003.14 ENSG00000000003.14      4535          TSPAN6
##    ENSG00000000005.5  ENSG00000000005.5      1610            TNMD
##   ENSG00000000419.12 ENSG00000000419.12      1207            DPM1
##   ENSG00000000457.13 ENSG00000000457.13      6883           SCYL3
##   ENSG00000000460.16 ENSG00000000460.16      5967        C1orf112
##                  ...                ...       ...             ...
##    ENSG00000283695.1  ENSG00000283695.1        61              NA
##    ENSG00000283696.1  ENSG00000283696.1       997              NA
##    ENSG00000283697.1  ENSG00000283697.1      1184    LOC101928917
##    ENSG00000283698.1  ENSG00000283698.1       940              NA
##    ENSG00000283699.1  ENSG00000283699.1        60         MIR4481
##   -------
##   seqinfo: 25 sequences (1 circular) from an unspecified genome; no seqlengths
res2$symbol <- sapply(rowRanges(rse_gene_scaled)$symbol, "[[", 1)

## Select some DE genes
intgenes <- res2$symbol[which(res2$padj < 0.0005)]
intgenes <- intgenes[!is.na(intgenes)]

## Make the volcano plot
plot_volcano(res2, FDR = 0.01, intgenes = intgenes)
## Warning: Removed 44 rows containing missing values (geom_point).

We can create a report just like before.

DESeq2Report(dds2, res = res2, project = "SRP056604 - matching sex",
    intgroup = c("sex", "predicted_sex"), outdir = ".",
    output = "SRP056604_sex-predictions")

Checking the chromosome of the DE genes by matching sex status shows that most of these genes are not in chromosomes X and Y as shown below.

sort(table(seqnames(rowRanges(rse_gene_scaled))[which(res2$padj < 0.01)]))
## 
## chr13 chr14 chr16 chr18 chr21  chrY  chrM  chr1  chr5  chr9 chr10  chr2 
##     0     0     0     0     0     0     0     1     1     1     1     2 
##  chr4  chr7 chr22  chrX  chr3  chr6 chr12 chr20  chr8 chr15 chr19 chr11 
##     2     2     2     2     3     3     3     3     4     4     4     5 
## chr17 
##     5

4 Other features

As described in Figure 1, recount2 provides data for expression features beyond genes. In this section we perform a differential expression analysis using the exon data as well as the base-pair resolution information.

4.1 Exon and exon-exon junctions

The exon and exon-exon junction coverage count matrices are similar to the gene level one and can also be downloaded with download_study(). However, these coverage count matrices are much larger than the gene one. Aggressive filtering of lowly expressed exons or exon-exon junctions can reduce the matrix dimensions if this impacts the performance of the differential expression software used.

Below we repeat the gene level analysis for the disjoint exon data. We first download the exon data, add the expanded metadata we constructed for the gene analysis, and then perform the differential expression analysis using limma-voom.

## Download the data if it is not there
if(!file.exists(file.path(local_path, "rse_exon.Rdata"))) {
    ## In case you decide to download the data instead of using the
    ## pre-installed data
    local_path <- "SRP056604"
    download_study("SRP056604", type = "rse-exon")
}

## Load the data
load(file.path(local_path, "rse_exon.Rdata"))

## Scale and add the metadata (it is in the same order)
identical(colData(rse_exon)$run, colData(rse_gene_scaled)$run)
## [1] TRUE
colData(rse_exon) <- colData(rse_gene_scaled)
rse_exon_scaled <- scale_counts(rse_exon)
## To highlight that we scaled the counts
rm(rse_exon)

## Filter lowly expressed exons: reduces the object size
## and run time
filter_exon <- rowMeans(assays(rse_exon_scaled)$counts) > 5
round(table(filter_exon) / length(filter_exon) * 100, 2)
## filter_exon
## FALSE  TRUE 
## 51.59 48.41
## Perform the filtering and change default names
rse_e <- rse_exon_scaled[filter_exon, ]
rowRanges(rse_e)$gene_id <- rownames(rse_e)
rownames(rse_e) <- paste0("exon_", seq_len(nrow(rse_e)))

## Create DESeq2 object for the exon data
dds_exon <- DESeqDataSet(rse_e, ~ sex + age + case)
## converting counts to integer mode
## the design formula contains a numeric variable with integer values,
##   specifying a model with increasing fold change for higher values.
##   did you mean for this to be a factor? if so, first convert
##   this variable to a factor using the factor() function
## it appears that the last variable in the design formula, 'case',
##   has a factor level, 'control', which is not the reference level. we recommend
##   to use factor(...,levels=...) or relevel() to set this as the reference level
##   before proceeding. for more information, please see the 'Note on factor levels'
##   in vignette('DESeq2').
## Perform DE analysis
dds_exon <- DESeq(dds_exon, test = "LRT", reduced = ~ sex + age,
    fitType = "local")
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## final dispersion estimates
## fitting model and testing
res_exon <- results(dds_exon, alpha = 0.01)

## Explore results
plotMA(res_exon, main="DESeq2 results for SRP056604 - exon level")

plot_volcano(res_exon, FDR = 0.01)

Just like at the gene level, we see many exons differentially expressed between LOAD and controls samples. As a first step to integrate the results from the two features, we can compare the list of genes that are differentially expressed versus the genes that have at least one exon differentially expressed.

## Get the gene ids for genes that are DE at the gene level or that have at
## least one exon with DE signal.
genes_w_de_exon <- unique(rowRanges(rse_e)$gene_id[which(res_exon$padj < 0.01)])
genes_de <- rownames(rse_gene_scaled)[which(res$padj < 0.01)]

## Make a venn diagram
library("gplots")
vinfo <- venn(list("genes" = genes_de, "exons" = genes_w_de_exon),
    names = c("genes", "exons"), show.plot = FALSE) 
plot(vinfo) +
    title("Genes with DE signal: at the gene and exon levels")

## integer(0)

Not all differentially expressed genes have differentially expressed exons, nor genes with at least one differentially expressed exon are necessarily differentially expressed. This is in line with what was described in Figure 2B of Soneson et al., 2015 (22).

This was just a quick example of how we can perform differential expression analyses at the gene and exon feature levels. We envision that more involved pipelines could be developed that leverage both feature levels such as in Jaffe at al., 2017 (23). For instance, we could focus on the differentially expressed genes with at least one differentially expressed exon and compare the direction of the DE signal versus the gene level signal as shown below.

## Keep only the DE exons that are from a gene that is also DE
top_exon_de <- res_exon[intersect(which(res_exon$padj < 0.01),
    which(rowRanges(rse_e)$gene_id %in% 
    attr(vinfo, "intersections")[["genes:exons"]])), ]
## Add the gene id
top_exon_de$gene_id <- rowRanges(rse_e)$gene_id[match(rownames(top_exon_de),
    rownames(rse_e))]
    
## Find the fold change that is the most extreme among the DE exons of a gene
exon_max_fc <- tapply(top_exon_de$log2FoldChange, top_exon_de$gene_id,
    function(x) { x[which.max(abs(x))] })

## Keep only the DE genes that match the previous selection
top_gene_de <- res[match(names(exon_max_fc), rownames(res)), ]

## Make the plot
plot(top_gene_de$log2FoldChange, exon_max_fc, pch = 20,
    col = adjustcolor("black", 1/2),
    ylab = "Most extreme log FC at the exon level among DE exons",
    xlab = "Log fold change (FC) at the gene level",
    main = "DE genes with at least one DE exon")
abline(a = 0, b = 1, col = "red")
abline(h = 0, col = "grey80")
abline(v = 0, col = "grey80")

The fold change for most exons shown above agrees with the gene level fold change. In data from other projects, some of the fold changes have opposite directions and could be interesting to study further.

4.2 Base-pair resolution

recount2 provides BigWig coverage files (unscaled) for all samples as well as a mean BigWig coverage file per project where each sample was scaled to 40 million 100 base-pair reads. The mean BigWig files are exactly what is needed to start an expressed regions analysis with derfinder (8). recount provides two related functions: expressed_regions() which is used to define a set of regions based on the mean BigWig file for a given project, and coverage_matrix() which based on a set of regions builds a count coverage matrix in a RangedSummarizedExperiment object just like the ones that are provided for genes and exons. Both functions ultimately use import.bw() from rtracklayer (24) which currently is not supported on Windows machines. While this presents a portability disadvantage, on the other side it allows reading portions of BigWig files from the web without having to fully download them. download_study() with type = "mean" or type = "samples" can be used to download the BigWig files, which we recommend doing when working with them extensively.

For illustrative purposes, we will use the data from chromosome 12 for the SRP056604 project. We chose chromosome 12 based on the number of DE genes per chromosome

sort(table(seqnames(rowRanges(rse_gene_scaled)[which(res$padj < 0.01)])),
    decreasing = TRUE)
## 
## chr12 chr15  chr6 chr14  chr4  chr5  chr7  chr8 chr13  chr1  chr2 chr11 
##     9     8     6     6     5     5     5     5     5     4     4     4 
## chr17  chrX  chr3 chr10  chr9 chr18 chr20 chr22 chr16 chr21  chrY chr19 
##     4     4     3     3     2     2     2     2     1     1     1     0 
##  chrM 
##     0

First, we obtain the expressed regions using a relatively high mean cutoff of 5. We then filter the regions to keep only the ones longer than 100 base-pairs to shorten the time needed for running coverage_matrix().

## Define expressed regions for study SRP056604, only for chromosome 12
regions <- expressed_regions("SRP056604", "chr12", cutoff = 5L,
    maxClusterGap = 3000L, outdir = local_path)
## 2017-08-01 15:09:34 loadCoverage: loading BigWig file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/mean_SRP056604.bw
## 2017-08-01 15:09:44 loadCoverage: applying the cutoff to the merged data
## 2017-08-01 15:09:44 filterData: originally there were 133275309 rows, now there are 133275309 rows. Meaning that 0 percent was filtered.
## 2017-08-01 15:09:44 findRegions: identifying potential segments
## 2017-08-01 15:09:44 findRegions: segmenting information
## 2017-08-01 15:09:44 .getSegmentsRle: segmenting with cutoff(s) 5
## 2017-08-01 15:09:49 findRegions: identifying candidate regions
## 2017-08-01 15:09:49 findRegions: identifying region clusters
## Explore the resulting expressed regions
regions
## GRanges object with 45415 ranges and 6 metadata columns:
##         seqnames                 ranges strand |            value
##            <Rle>              <IRanges>  <Rle> |        <numeric>
##       1    chr12         [14557, 14609]      * | 5.51228961404764
##       2    chr12         [14694, 14944]      * | 18.5175433177872
##       3    chr12         [15085, 15153]      * | 32.1930030463398
##       4    chr12         [15489, 15589]      * | 15.5183322169993
##       5    chr12         [15889, 16065]      * | 51.5721219623156
##     ...      ...                    ...    ... .              ...
##   45411    chr12 [133204363, 133204806]      * | 14.7140764245042
##   45412    chr12 [133205808, 133205818]      * | 5.28275680541992
##   45413    chr12 [133206109, 133206245]      * | 9.16745478219359
##   45414    chr12 [133206247, 133206273]      * | 5.30814688294022
##   45415    chr12 [133206625, 133206646]      * | 5.22780539772727
##                     area indexStart  indexEnd cluster clusterL
##                <numeric>  <integer> <integer>   <Rle>    <Rle>
##       1 292.151349544525      14557     14609       1    16374
##       2 4647.90337276459      14694     14944       1    16374
##       3 2221.31721019745      15085     15153       1    16374
##       4 1567.35155391693      15489     15589       1    16374
##       5 9128.26558732986      15889     16065       1    16374
##     ...              ...        ...       ...     ...      ...
##   45411 6533.04993247986  133204363 133204806    4711     4503
##   45412 58.1103248596191  133205808 133205818    4711     4503
##   45413 1255.94130516052  133206109 133206245    4711     4503
##   45414 143.319965839386  133206247 133206273    4711     4503
##   45415     115.01171875  133206625 133206646    4711     4503
##   -------
##   seqinfo: 1 sequence from an unspecified genome
summary(width(regions))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     1.0     9.0    61.0    88.3   120.0  5483.0
table(width(regions) >= 60)
## 
## FALSE  TRUE 
## 22465 22950
## Keep only the ones that are at least 60 bp long
regions <- regions[width(regions) >= 60]
length(regions)
## [1] 22950

Now that we have a set of regions to work with, we proceed to build a RangedSummarizedExperiment object with the coverage counts, add the expanded metadata we built for the gene level, and scale the counts. Note that coverage_matrix() by defaults scales the counts. We will round them to integers in order to use DESeq2.

## Compute coverage matrix for study SRP056604, only for chromosome 12
## Takes about 45 seconds with local data
## and about 70 seconds with data from the web
system.time(rse_er <- coverage_matrix("SRP056604", "chr12", regions,
    chunksize = length(regions), outdir = local_path, round = TRUE))
## 2017-08-01 15:09:57 railMatrix: processing regions 1 to 22950
## 2017-08-01 15:09:57 railMatrix: processing file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/SRR1931819.bw
## 2017-08-01 15:10:03 railMatrix: processing file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/SRR1931818.bw
## 2017-08-01 15:10:08 railMatrix: processing file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/SRR1931817.bw
## 2017-08-01 15:10:14 railMatrix: processing file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/SRR1931816.bw
## 2017-08-01 15:10:19 railMatrix: processing file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/SRR1931815.bw
## 2017-08-01 15:10:25 railMatrix: processing file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/SRR1931814.bw
## 2017-08-01 15:10:31 railMatrix: processing file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/SRR1931813.bw
## 2017-08-01 15:10:37 railMatrix: processing file /tmp/RtmpqorzqP/Rinst21fee7c5387/recountWorkshop/extdata/SRP056604/bw/SRR1931812.bw
##    user  system elapsed 
##  44.728   1.816  46.657
## Use the expanded metadata we built for the gene model
colData(rse_er) <- colData(rse_gene_scaled)

Now that we have an integer count matrix for the expressed regions, we can proceed with the differential expression analysis just like we did at the gene and exon feature levels.

## Define DESeq2 object
dds_er <- DESeqDataSet(rse_er, ~ sex + age + case)
## converting counts to integer mode
## the design formula contains a numeric variable with integer values,
##   specifying a model with increasing fold change for higher values.
##   did you mean for this to be a factor? if so, first convert
##   this variable to a factor using the factor() function
## it appears that the last variable in the design formula, 'case',
##   has a factor level, 'control', which is not the reference level. we recommend
##   to use factor(...,levels=...) or relevel() to set this as the reference level
##   before proceeding. for more information, please see the 'Note on factor levels'
##   in vignette('DESeq2').
dds_er <- DESeq(dds_er, test = "LRT", reduced = ~ sex + age, fitType = "local")
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## final dispersion estimates
## fitting model and testing
## 1 rows did not converge in beta, labelled in mcols(object)$fullBetaConv. Use larger maxit argument with nbinomLRT
res_er <- results(dds_er, alpha = 0.05)

## Visually inspect results
plotMA(res_er, main="DESeq2 results for SRP056604 - DERs")

plot_volcano(res_er, FDR = 0.05)

We can also create a report, just like before.

DESeq2Report(dds_er, res = res_er, project = "SRP056604 - DERs",
    intgroup = c("sex", "case"), outdir = ".",
    output = "SRP056604_DERs")

Having identified the differentially expressed regions (DERs), we can sort all regions by their adjusted p-value.

## Sort regions by q-value
regions_by_padj <- regions[order(res_er$padj, decreasing = FALSE)]

## Look at the top 10
regions_by_padj[1:10]
## GRanges object with 10 ranges and 6 metadata columns:
##         seqnames                 ranges strand |            value
##            <Rle>              <IRanges>  <Rle> |        <numeric>
##   34249    chr12 [108250663, 108250900]      * |  38.194384272359
##    1567    chr12 [  2189828,   2189963]      * | 11.6252035463558
##   18192    chr12 [ 54963840,  54963950]      * | 17.1647116472055
##   29356    chr12 [ 91178342,  91178585]      * | 34.8185044624766
##   10648    chr12 [ 29767898,  29768075]      * | 74.1435057607929
##   18188    chr12 [ 54962431,  54962638]      * | 11.6006789757655
##   18191    chr12 [ 54962854,  54963101]      * | 13.8672616866327
##   18200    chr12 [ 54967146,  54967243]      * | 21.5609737415703
##   34250    chr12 [108250902, 108251194]      * | 21.5030734612266
##   34258    chr12 [108253988, 108254830]      * | 13.9660946477209
##                     area indexStart  indexEnd cluster clusterL
##                <numeric>  <integer> <integer>   <Rle>    <Rle>
##   34249 9090.26345682144  108250663 108250900    3633    20890
##    1567 1581.02768230438    2189828   2189963     147   140108
##   18192 1905.28299283981   54963840  54963950    1940     9191
##   29356  8495.7150888443   91178342  91178585    3007     1163
##   10648 13197.5440254211   29767898  29768075    1187      178
##   18188 2412.94122695923   54962431  54962638    1940     9191
##   18191 3439.08089828491   54962854  54963101    1940     9191
##   18200 2112.97542667389   54967146  54967243    1940     9191
##   34250  6300.4005241394  108250902 108251194    3633    20890
##   34258 11773.4177880287  108253988 108254830    3633    20890
##   -------
##   seqinfo: 1 sequence from an unspecified genome
width(regions_by_padj[1:10])
##  [1] 238 136 111 244 178 208 248  98 293 843

4.3 Visualize regions

Since the DERs do not necessarily match the annotation, it is important to visualize them. The code for visualizing DERs can easily be adapted to visualize other regions. Although, the width and number of the regions will influence the computing resources needed to make the plots.

Because the unscaled BigWig files are available in recount2, several visualization packages can be used such as epivizr (25), wiggleplotr (26) and derfinderPlot (8). With all of them it is important to remember to scale the data except when visualizing the mean BigWig file for a given project.

First, we need to get the list of URLs for the BigWig files. We can either manually construct them or search them inside the recount_url table. For this workshop, we have the data locally so we will use those files.

## Construct the list of BigWig URLs
## They have the following form:
## http://duffel.rail.bio/recount/
## project id
## /bw/
## sample run id
## .bw
bws_web <- paste0("http://duffel.rail.bio/recount/SRP056604/bw/",
    colData(rse_er)$bigwig_file)

## Note that they are also present in the recount_url data.frame
bws_url <- recount_url$url[match(colData(rse_er)$bigwig_file,
    recount_url$file_name)]
identical(bws_web, bws_url)
## [1] TRUE
## Local bigwigs
bws <- file.path(local_path, "bw", colData(rse_er)$bigwig_file)
all(file.exists(bws))
## [1] TRUE
## Use the sample run ids as the sample names
names(bws) <- colData(rse_er)$run

We will visualize the DERs using derfinderPlot, similar to what was done in Jaffe et al., 2015 (27). We will first add a little padding to the regions: 100 base-pairs on each side.

## Add 100 bp padding on each side
regions_resized <- resize(regions_by_padj[1:10],
    width(regions_by_padj[1:10]) + 200, fix = "center")

Next, we obtain the base-pair coverage data for each DER and scale the data to a library size of 40 million 100 base-pair reads using the coverage AUC information we have in the metadata.

## Get the bp coverage data for the plots
library("derfinder")
regionCov <- getRegionCoverage(regions = regions_resized, files = bws,
    targetSize = 40 * 1e6 * 100, totalMapped = colData(rse_er)$auc,
    verbose = FALSE)

The function plotRegionCoverage() requires several pieces of annotation information for the plots that use a TxDb object. For recount2 we used Gencode v25 hg38’s annotation, which means that we need to process it manually instead of using a pre-computed TxDb package.

To create a TxDb object for Gencode v25, we first need to import the data. Since we are working only with chromosome 21 for this example, we can then subset it. Next we need to add the relevant chromosome information. Some of the annotation functions we will use can handle Entrez or Ensembl ids, but not Gencode ids. So we will make sure that we are working with Ensembl ids before finally creating the Gencode v25 TxDb object.

## Import the Gencode v25 hg38 gene annotation
library("rtracklayer")

## If accessing from the web
if(FALSE) {
    gencode_v25_hg38 <- import(paste0(
        "ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_25/",
        "gencode.v25.annotation.gtf.gz"))  
}

## Using the file locally, included in the workshop package
gencode_v25_hg38 <- import(system.file("extdata",
    "gencode.v25.annotation.gtf.gz", package = "recountWorkshop"))
            
## Keep only the chr12 info
gencode_v25_hg38 <- keepSeqlevels(gencode_v25_hg38, "chr12",
    pruning.mode = "coarse")

## Get the chromosome information for hg38
library("GenomicFeatures")
chrInfo <- getChromInfoFromUCSC("hg38")
## Download and preprocess the 'chrominfo' data frame ...
## OK
chrInfo$chrom <- as.character(chrInfo$chrom)
chrInfo <- chrInfo[chrInfo$chrom %in% seqlevels(regions), ]
chrInfo$isCircular <- FALSE

## Assign the chromosome information to the object we will use to
## create the txdb object
si <- with(chrInfo, Seqinfo(as.character(chrom), length, isCircular,
    genome = "hg38"))
seqinfo(gencode_v25_hg38) <- si

## Switch from Gencode gene ids to Ensembl gene ids
gencode_v25_hg38$gene_id <- gsub("\\..*", "", gencode_v25_hg38$gene_id)

## Create the TxDb object
gencode_v25_hg38_txdb <- makeTxDbFromGRanges(gencode_v25_hg38)

## Explore the TxDb object
gencode_v25_hg38_txdb
## TxDb object:
## # Db type: TxDb
## # Supporting package: GenomicFeatures
## # Genome: hg38
## # transcript_nrow: 11419
## # exon_nrow: 39709
## # cds_nrow: 15918
## # Db created by: GenomicFeatures package from Bioconductor
## # Creation time: 2017-08-01 15:11:40 +0000 (Tue, 01 Aug 2017)
## # GenomicFeatures version at creation time: 1.29.8
## # RSQLite version at creation time: 2.0
## # DBSCHEMAVERSION: 1.1

Now that we have a TxDb object for Gencode v25 on hg38 coordinates, we can use bumphunter’s (28) annotation functions for annotating the original 10 regions we were working with. Since we are using Ensembl instead of Entrez gene ids, we need to pass this information to annotateTranscripts(). Otherwise, the function will fail to retrieve the gene symbols.

library("bumphunter")
## Annotate all transcripts for gencode v25 based on the TxDb object
## we built previously.
ann_gencode_v25_hg38 <- annotateTranscripts(gencode_v25_hg38_txdb,
    annotationPackage = "org.Hs.eg.db",
    mappingInfo = list("column" = "ENTREZID", "keytype" = "ENSEMBL",
    "multiVals" = "first"))
## Getting TSS and TSE.
## Getting CSS and CSE.
## Getting exons.
## Annotating genes.
## 'select()' returned 1:many mapping between keys and columns
## Annotate the regions of interest
## Note that we are using the original regions, not the resized ones
nearest_ann <- matchGenes(regions_by_padj[1:10], ann_gencode_v25_hg38)

The final piece we need to run plotRegionCoverage() is information about which base-pairs are exonic, intronic, etc. This is done via the annotateRegions() function in derfinder, which itself requires prior processing of the TxDb information by makeGenomicState().

## Create the genomic state object using the gencode TxDb object
gs_gencode_v25_hg38 <- makeGenomicState(gencode_v25_hg38_txdb,
    chrs = seqlevels(regions))
## 'select()' returned 1:1 mapping between keys and columns
## Annotate the original regions
regions_ann <- annotateRegions(regions_resized,
    gs_gencode_v25_hg38$fullGenome)
## 2017-08-01 15:12:37 annotateRegions: counting
## 2017-08-01 15:12:37 annotateRegions: annotating

We can finally use plotRegionCoverage() to visualize the top 10 regions coloring by whether they are LOAD or control samples. Known exons are shown in dark blue, introns in light blue.

library("derfinderPlot")
plotRegionCoverage(regions = regions_resized, regionCoverage = regionCov, 
   groupInfo = colData(rse_er)$case,
   nearestAnnotation = nearest_ann, 
   annotatedRegions = regions_ann,
   txdb = gencode_v25_hg38_txdb,
   scalefac = 1, ylab = "Coverage (RP40M, 100bp)",
   ask = FALSE, verbose = FALSE)

In the previous plots we can see that some DERs are longer than known exons, others match known exons, and some are un-annotated expressed regions.

5 Summary

In this workshop we described in detail the available data in recount2, how the coverage count matrices were computed, the metadata included in recount2 and how to get new phenotypic information from other sources. We showed how to perform a differential expression analysis at the gene and exon levels as well as use an annotation-agnostic approach. Finally, we explained how to visualize the base-pair information for a given set of regions. This workshop constitutes a strong basis to leverage the recount2 data for human RNA-seq analyses.

6 Session information

This workflow was created using BiocStyle (29).

## Pandoc information
rmarkdown::pandoc_version()
## [1] '1.19.1'
## Time for reproducing this workflow, in minutes
round(proc.time()[3] / 60, 1)
## elapsed 
##       9
options(width = 100)
library("devtools")
session_info()
## Session info --------------------------------------------------------------------------------------
##  setting  value                       
##  version  R version 3.4.1 (2017-06-30)
##  system   x86_64, linux-gnu           
##  ui       X11                         
##  language (EN)                        
##  collate  C                           
##  tz       Zulu                        
##  date     2017-08-01
## Packages ------------------------------------------------------------------------------------------
##  package                * version  date       source                                        
##  acepack                  1.4.1    2016-10-29 CRAN (R 3.4.1)                                
##  annotate                 1.55.0   2017-07-18 Bioconductor                                  
##  AnnotationDbi          * 1.39.2   2017-08-01 cran (@1.39.2)                                
##  AnnotationFilter         1.1.3    2017-07-18 Bioconductor                                  
##  AnnotationForge          1.19.4   2017-07-22 Bioconductor                                  
##  AnnotationHub            2.9.5    2017-07-18 Bioconductor                                  
##  assertthat               0.2.0    2017-04-11 CRAN (R 3.4.1)                                
##  backports                1.1.0    2017-05-22 CRAN (R 3.4.1)                                
##  base                   * 3.4.1    2017-07-18 local                                         
##  base64enc                0.1-3    2015-07-28 CRAN (R 3.4.1)                                
##  BiasedUrn                1.07     2015-12-28 cran (@1.07)                                  
##  bibtex                   0.4.2    2017-06-30 cran (@0.4.2)                                 
##  bindr                    0.1      2016-11-13 CRAN (R 3.4.1)                                
##  bindrcpp                 0.2      2017-06-17 CRAN (R 3.4.1)                                
##  Biobase                * 2.37.2   2017-07-18 Bioconductor                                  
##  BiocGenerics           * 0.23.0   2017-07-18 Bioconductor                                  
##  BiocInstaller            1.27.2   2017-07-18 Bioconductor                                  
##  BiocParallel             1.11.4   2017-07-18 Bioconductor                                  
##  BiocStyle              * 2.5.8    2017-07-22 Bioconductor                                  
##  biomaRt                  2.33.3   2017-07-18 Bioconductor                                  
##  Biostrings               2.45.3   2017-07-22 Bioconductor                                  
##  biovizBase               1.25.1   2017-07-18 Bioconductor                                  
##  bit                      1.1-12   2014-04-09 CRAN (R 3.4.1)                                
##  bit64                    0.9-7    2017-05-08 CRAN (R 3.4.1)                                
##  bitops                   1.0-6    2013-08-17 CRAN (R 3.4.1)                                
##  blob                     1.1.0    2017-06-17 CRAN (R 3.4.1)                                
##  bookdown                 0.4      2017-05-20 CRAN (R 3.4.1)                                
##  BSgenome                 1.45.1   2017-07-18 Bioconductor                                  
##  bumphunter             * 1.17.2   2017-07-18 Bioconductor                                  
##  Category                 2.43.1   2017-07-18 Bioconductor                                  
##  caTools                  1.17.1   2014-09-10 CRAN (R 3.4.1)                                
##  checkmate                1.8.3    2017-07-03 CRAN (R 3.4.1)                                
##  cluster                  2.0.6    2017-03-16 CRAN (R 3.4.1)                                
##  clusterProfiler        * 3.5.5    2017-08-01 Github (GuangchuangYu/clusterProfiler@0c9948a)
##  codetools                0.2-15   2016-10-05 CRAN (R 3.4.1)                                
##  colorspace               1.3-2    2016-12-14 CRAN (R 3.4.1)                                
##  compiler                 3.4.1    2017-07-18 local                                         
##  curl                     2.8.1    2017-07-21 CRAN (R 3.4.1)                                
##  d3heatmap                0.6.1.1  2016-02-23 cran (@0.6.1.1)                               
##  data.table               1.10.4   2017-02-01 CRAN (R 3.4.1)                                
##  datasets               * 3.4.1    2017-07-18 local                                         
##  DBI                      0.7      2017-06-18 CRAN (R 3.4.1)                                
##  DEFormats                1.5.0    2017-07-22 cran (@1.5.0)                                 
##  DelayedArray           * 0.3.17   2017-07-24 Bioconductor                                  
##  derfinder              * 1.11.5   2017-07-22 cran (@1.11.5)                                
##  derfinderHelper          1.11.0   2017-07-22 cran (@1.11.0)                                
##  derfinderPlot          * 1.11.0   2017-07-22 cran (@1.11.0)                                
##  DESeq2                 * 1.17.12  2017-08-01 cran (@1.17.12)                               
##  devtools               * 1.13.2   2017-06-02 CRAN (R 3.4.1)                                
##  dichromat                2.0-0    2013-01-24 CRAN (R 3.4.1)                                
##  digest                   0.6.12   2017-01-27 CRAN (R 3.4.1)                                
##  DO.db                    2.9      2017-07-18 Bioconductor                                  
##  doParallel               1.0.10   2015-10-14 CRAN (R 3.4.1)                                
##  doRNG                    1.6.6    2017-04-10 CRAN (R 3.4.1)                                
##  DOSE                   * 3.3.1    2017-07-18 Bioconductor                                  
##  downloader               0.4      2015-07-09 CRAN (R 3.4.1)                                
##  dplyr                    0.7.2    2017-07-20 CRAN (R 3.4.1)                                
##  DT                       0.2      2016-08-09 cran (@0.2)                                   
##  edgeR                    3.19.3   2017-07-24 Bioconductor                                  
##  ensembldb                2.1.10   2017-07-18 Bioconductor                                  
##  evaluate                 0.10.1   2017-06-24 CRAN (R 3.4.1)                                
##  fastmatch                1.1-0    2017-01-28 CRAN (R 3.4.1)                                
##  fdrtool                  1.2.15   2015-07-08 cran (@1.2.15)                                
##  fgsea                    1.3.1    2017-07-18 Bioconductor                                  
##  foreach                * 1.4.3    2015-10-13 CRAN (R 3.4.1)                                
##  foreign                  0.8-69   2017-06-21 CRAN (R 3.4.1)                                
##  Formula                  1.2-2    2017-07-10 CRAN (R 3.4.1)                                
##  gdata                    2.18.0   2017-06-06 CRAN (R 3.4.1)                                
##  genefilter               1.59.0   2017-07-18 Bioconductor                                  
##  geneLenDataBase          1.13.0   2017-07-18 Bioconductor                                  
##  geneplotter              1.55.0   2017-07-18 Bioconductor                                  
##  GenomeInfoDb           * 1.13.4   2017-07-18 Bioconductor                                  
##  GenomeInfoDbData         0.99.1   2017-07-18 Bioconductor                                  
##  GenomicAlignments        1.13.4   2017-07-22 Bioconductor                                  
##  GenomicFeatures        * 1.29.8   2017-07-22 Bioconductor                                  
##  GenomicFiles             1.13.10  2017-07-22 cran (@1.13.10)                               
##  GenomicRanges          * 1.29.12  2017-08-01 cran (@1.29.12)                               
##  GEOquery                 2.43.0   2017-07-18 Bioconductor                                  
##  GGally                   1.3.1    2017-06-08 CRAN (R 3.4.1)                                
##  ggbio                    1.25.3   2017-07-18 Bioconductor                                  
##  ggplot2                  2.2.1    2016-12-30 CRAN (R 3.4.1)                                
##  ggrepel                  0.6.5    2016-11-24 cran (@0.6.5)                                 
##  glue                     1.1.1    2017-06-21 CRAN (R 3.4.1)                                
##  GO.db                  * 3.4.1    2017-07-18 Bioconductor                                  
##  GOSemSim                 2.3.1    2017-07-18 Bioconductor                                  
##  goseq                    1.29.0   2017-07-22 cran (@1.29.0)                                
##  GOstats                  2.43.0   2017-07-18 Bioconductor                                  
##  gplots                 * 3.0.1    2016-03-30 CRAN (R 3.4.1)                                
##  graph                  * 1.55.0   2017-07-18 Bioconductor                                  
##  graphics               * 3.4.1    2017-07-18 local                                         
##  grDevices              * 3.4.1    2017-07-18 local                                         
##  grid                     3.4.1    2017-07-18 local                                         
##  gridBase                 0.4-7    2014-02-24 cran (@0.4-7)                                 
##  gridExtra                2.2.1    2016-02-29 CRAN (R 3.4.1)                                
##  GSEABase                 1.39.0   2017-07-18 Bioconductor                                  
##  gtable                   0.2.0    2016-02-26 CRAN (R 3.4.1)                                
##  gtools                   3.5.0    2015-05-29 CRAN (R 3.4.1)                                
##  highr                    0.6      2016-05-09 CRAN (R 3.4.1)                                
##  Hmisc                    4.0-3    2017-05-02 CRAN (R 3.4.1)                                
##  htmlTable                1.9      2017-01-26 CRAN (R 3.4.1)                                
##  htmltools                0.3.6    2017-04-28 CRAN (R 3.4.1)                                
##  htmlwidgets              0.9      2017-07-10 CRAN (R 3.4.1)                                
##  httpuv                   1.3.5    2017-07-04 CRAN (R 3.4.1)                                
##  httr                     1.2.1    2016-07-03 CRAN (R 3.4.1)                                
##  ideal                  * 1.1.0    2017-07-22 cran (@1.1.0)                                 
##  igraph                   1.1.2    2017-07-21 CRAN (R 3.4.1)                                
##  IHW                      1.5.0    2017-07-22 cran (@1.5.0)                                 
##  interactiveDisplayBase   1.15.0   2017-07-18 Bioconductor                                  
##  IRanges                * 2.11.12  2017-07-22 Bioconductor                                  
##  iterators              * 1.0.8    2015-10-13 CRAN (R 3.4.1)                                
##  jsonlite                 1.5      2017-06-01 CRAN (R 3.4.1)                                
##  KernSmooth               2.23-15  2015-06-29 CRAN (R 3.4.1)                                
##  knitcitations            1.0.8    2017-07-04 cran (@1.0.8)                                 
##  knitr                    1.16     2017-05-18 CRAN (R 3.4.1)                                
##  knitrBootstrap           1.0.1    2017-07-19 cran (@1.0.1)                                 
##  labeling                 0.3      2014-08-23 CRAN (R 3.4.1)                                
##  lattice                  0.20-35  2017-03-25 CRAN (R 3.4.1)                                
##  latticeExtra             0.6-28   2016-02-09 CRAN (R 3.4.1)                                
##  lazyeval                 0.2.0    2016-06-12 CRAN (R 3.4.1)                                
##  limma                    3.33.5   2017-07-24 Bioconductor                                  
##  locfit                 * 1.5-9.1  2013-04-20 CRAN (R 3.4.1)                                
##  lpsymphony               1.5.2    2017-07-22 cran (@1.5.2)                                 
##  lubridate                1.6.0    2016-09-13 CRAN (R 3.4.1)                                
##  magrittr                 1.5      2014-11-22 CRAN (R 3.4.1)                                
##  markdown                 0.8      2017-04-20 CRAN (R 3.4.1)                                
##  Matrix                   1.2-10   2017-04-28 CRAN (R 3.4.1)                                
##  matrixStats            * 0.52.2   2017-04-14 CRAN (R 3.4.1)                                
##  memoise                  1.1.0    2017-04-21 CRAN (R 3.4.1)                                
##  methods                * 3.4.1    2017-07-18 local                                         
##  mgcv                     1.8-17   2017-02-08 CRAN (R 3.4.1)                                
##  mime                     0.5      2016-07-07 CRAN (R 3.4.1)                                
##  munsell                  0.4.3    2016-02-13 CRAN (R 3.4.1)                                
##  nlme                     3.1-131  2017-02-06 CRAN (R 3.4.1)                                
##  NMF                      0.20.6   2015-05-26 cran (@0.20.6)                                
##  nnet                     7.3-12   2016-02-02 CRAN (R 3.4.1)                                
##  org.Hs.eg.db           * 3.4.1    2017-07-18 Bioconductor                                  
##  OrganismDbi              1.19.0   2017-07-18 Bioconductor                                  
##  parallel               * 3.4.1    2017-07-18 local                                         
##  pcaExplorer              2.3.0    2017-07-22 cran (@2.3.0)                                 
##  pheatmap                 1.0.8    2015-12-11 CRAN (R 3.4.1)                                
##  pkgconfig                2.0.1    2017-03-21 CRAN (R 3.4.1)                                
##  pkgmaker                 0.22     2014-05-14 CRAN (R 3.4.1)                                
##  plyr                     1.8.4    2016-06-08 CRAN (R 3.4.1)                                
##  png                      0.1-7    2013-12-03 CRAN (R 3.4.1)                                
##  prettyunits              1.0.2    2015-07-13 CRAN (R 3.4.1)                                
##  progress                 1.1.2    2016-12-14 CRAN (R 3.4.1)                                
##  ProtGenerics             1.9.0    2017-07-18 Bioconductor                                  
##  qvalue                   2.9.0    2017-07-18 Bioconductor                                  
##  R6                       2.2.2    2017-06-17 CRAN (R 3.4.1)                                
##  RBGL                     1.53.0   2017-07-18 Bioconductor                                  
##  RColorBrewer             1.1-2    2014-12-07 CRAN (R 3.4.1)                                
##  Rcpp                     0.12.12  2017-07-15 CRAN (R 3.4.1)                                
##  RCurl                    1.95-4.8 2016-03-01 CRAN (R 3.4.1)                                
##  recount                * 1.3.2    2017-08-01 cran (@1.3.2)                                 
##  recountWorkshop        * 0.99.4   2017-08-01 Bioconductor                                  
##  RefManageR               0.14.12  2017-07-04 cran (@0.14.12)                               
##  regionReport           * 1.11.2   2017-07-22 cran (@1.11.2)                                
##  registry                 0.3      2015-07-08 CRAN (R 3.4.1)                                
##  rentrez                  1.1.0    2017-06-01 CRAN (R 3.4.1)                                
##  reshape                  0.8.6    2016-10-21 CRAN (R 3.4.1)                                
##  reshape2                 1.4.2    2016-10-22 CRAN (R 3.4.1)                                
##  rintrojs                 0.2.0    2017-07-04 cran (@0.2.0)                                 
##  rlang                    0.1.1    2017-05-18 CRAN (R 3.4.1)                                
##  rmarkdown                1.6      2017-06-15 CRAN (R 3.4.1)                                
##  rngtools                 1.2.4    2014-03-06 CRAN (R 3.4.1)                                
##  rpart                    4.1-11   2017-04-21 CRAN (R 3.4.1)                                
##  rprojroot                1.2      2017-01-16 CRAN (R 3.4.1)                                
##  Rsamtools                1.29.0   2017-07-18 Bioconductor                                  
##  RSQLite                  2.0      2017-06-19 CRAN (R 3.4.1)                                
##  rtracklayer            * 1.37.3   2017-07-22 Bioconductor                                  
##  rvcheck                  0.0.9    2017-07-10 CRAN (R 3.4.1)                                
##  S4Vectors              * 0.15.5   2017-07-18 Bioconductor                                  
##  scales                   0.4.1    2016-11-09 CRAN (R 3.4.1)                                
##  shiny                    1.0.3    2017-04-26 CRAN (R 3.4.1)                                
##  shinyAce                 0.2.1    2016-03-14 cran (@0.2.1)                                 
##  shinyBS                  0.61     2015-03-31 cran (@0.61)                                  
##  shinydashboard           0.6.1    2017-06-14 cran (@0.6.1)                                 
##  slam                     0.1-40   2016-12-01 cran (@0.1-40)                                
##  SparseM                * 1.77     2017-04-23 CRAN (R 3.4.1)                                
##  splines                  3.4.1    2017-07-18 local                                         
##  stats                  * 3.4.1    2017-07-18 local                                         
##  stats4                 * 3.4.1    2017-07-18 local                                         
##  stringi                  1.1.5    2017-04-07 CRAN (R 3.4.1)                                
##  stringr                  1.2.0    2017-02-18 CRAN (R 3.4.1)                                
##  SummarizedExperiment   * 1.7.5    2017-07-18 Bioconductor                                  
##  survival                 2.41-3   2017-04-04 CRAN (R 3.4.1)                                
##  threejs                  0.2.2    2016-04-01 cran (@0.2.2)                                 
##  tibble                   1.3.3    2017-05-28 CRAN (R 3.4.1)                                
##  tidyr                    0.6.3    2017-05-15 CRAN (R 3.4.1)                                
##  tools                    3.4.1    2017-07-18 local                                         
##  topGO                  * 2.29.0   2017-07-18 Bioconductor                                  
##  UpSetR                   1.3.3    2017-03-21 CRAN (R 3.4.1)                                
##  utils                  * 3.4.1    2017-07-18 local                                         
##  VariantAnnotation        1.23.6   2017-07-22 Bioconductor                                  
##  withr                    1.0.2    2016-06-20 CRAN (R 3.4.1)                                
##  XML                      3.98-1.9 2017-06-19 CRAN (R 3.4.1)                                
##  xml2                     1.1.1    2017-01-24 CRAN (R 3.4.1)                                
##  xtable                   1.8-2    2016-02-05 CRAN (R 3.4.1)                                
##  XVector                  0.17.0   2017-07-18 Bioconductor                                  
##  yaml                     2.1.14   2016-11-12 CRAN (R 3.4.1)                                
##  zlibbioc                 1.23.0   2017-07-18 Bioconductor

7 Author contributions

LCT wrote the R code. LCT, AN and AEJ wrote the workshop.

8 Competing interests

No competing interests were disclosed.

9 Grant information

LCT and AEJ were supported by NIH grant R21 MH109956-01.

10 Acknowledgments

We would like to acknowledge the Andrew Jaffe and Alexis Battle lab members for feedback on the explanatory pictures and the written manuscript.

References

1. Huber W, Carey VJ, Gentleman R, Anders S, Carlson M, Carvalho BS, et al. Orchestrating high-throughput genomic analysis with bioconductor. Nature methods. 2015;12(2):115–21.

2. Law CW, Alhamdoosh M, Su S, Smyth GK, Ritchie ME. RNA-seq analysis is easy as 1-2-3 with limma, Glimma and edgeR. F1000Research. 2016;5(May):1408.

3. Love MI, Anders S, Kim V, Huber W. RNA-Seq workflow: gene-level exploratory analysis and differential expression. F1000Research. 2016;4(May):1070.

4. Chen Y, Lun ATL, Smyth GK. From reads to genes to pathways: differential expression analysis of RNA-Seq experiments using Rsubread and the edgeR quasi-likelihood pipeline. F1000Research. 2016;5(May):1438.

5. Frazee AC, Langmead B, Leek JT. ReCount: A multi-experiment resource of analysis-ready RNA-seq gene count datasets. BMC bioinformatics. 2011;12:449.

6. Himes, E. B, Jiang, X., Wagner, P., 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;9(6):e99625.

7. Collado-Torres L, Nellore A, Kammers K, Ellis SE, Taub MA, Hansen KD, et al. Reproducible RNA-seq analysis using recount2. Nature Biotechnology. 2017 Apr;35(4):319–21.

8. Collado-Torres L, Nellore A, Frazee AC, Wilks C, Love MI, Langmead B, et al. Flexible expressed region analysis for RNA-seq with derfinder. Nucleic Acids Research. 2017 Jan;45(2):e9–9.

9. Morgan M, Obenchain V, Hester J, Pagès H. SummarizedExperiment: SummarizedExperiment container. 2017.

10. Wilks C, Gaddipati P, Nellore A, Langmead B. Snaptron: querying and visualizing splicing across tens of thousands of RNA-seq samples. bioRxiv. 2017;

11. Nellore A, Collado-Torres L, Jaffe AE, Alquicira-Hernández J, Wilks C, Pritt J, et al. Rail-RNA: Scalable analysis of RNA-seq splicing and coverage. Bioinformatics (Oxford, England). 2016 Sep;

12. Lawrence M, Huber W, Pages H, Aboyoun P, Carlson M, Gentleman R, et al. Software for computing and annotating genomic ranges. PLoS computational biology. 2013;9(8):e1003118.

13. Magistri M, Velmeshev D, Makhmutova M, Faghihi MA. Transcriptomics Profiling of Alzheimer’s Disease Reveal Neurovascular Defects, Altered Amyloid-β Homeostasis, and Deregulated Expression of Long Noncoding RNAs. Journal of Alzheimer’s disease: JAD. 2015;48(3):647–65.

14. Ellis SE, Collado-Torres L, Leek J. Improving the value of public rna-seq expression data by phenotype prediction. bioRxiv. 2017;

16. Love MI, Huber W, Anders S. Moderated estimation of fold change and dispersion for rna-seq data with deseq2. Genome biology. 2014;15(12):1–21.

17. Marini F. Ideal: Interactive differential expression analysis. 2017.

18. Collado-Torres L, Jaffe AE, Leek JT. regionReport: Interactive reports for region-level and feature-level genomic analyses [version2; referees: 2 approved, 1 approved with reservations]. F1000Research. 2016 Jun;4:1–10.

19. Robinson MD, McCarthy DJ, Smyth GK. edgeR: a bioconductor package for differential expression analysis of digital gene expression data. Bioinformatics (Oxford, England). 2010 Jan;26(1):139–40.

20. Law CW, Chen Y, Shi W, Smyth GK. Voom: Precision weights unlock linear model analysis tools for rna-seq read counts. Genome Biol. 2014;15(2):R29.

21. Yu G, Wang L-G, Han Y, He Q-Y. ClusterProfiler: An r package for comparing biological themes among gene clusters. OMICS: A Journal of Integrative Biology. 2012;16(5):284–7.

22. Soneson C, Love MI, Robinson MD. Differential analyses for RNA-seq: transcript-level estimates improve gene-level inferences. [version 2; referees: 2 approved]. F1000Research. 2015;4(0):1521.

23. Jaffe AE, Straub R, Shin JH, Tao R, Gao Y, Collado-Torres L, et al. Developmental and genetic regulation of the human cortex transcriptome in schizophrenia. bioRxiv. 2017;

24. Lawrence M, Gentleman R, Carey V. Rtracklayer: An r package for interfacing with genome browsers. Bioinformatics. 2009;25:1841–2.

25. Bravo HC, Chelaru F, Smith L, Goldstein N, Kancherla J, Walter M, et al. Epivizr: R interface to epiviz web app. 2017.

26. Alasoo K. Wiggleplotr: Make read coverage plots from bigwig files. 2017.

27. Jaffe AE, Shin J, Collado-Torres L, Leek JT, Tao R, Li C, et al. Developmental regulation of human cortex transcription and its clinical relevance at single base resolution. Nature Neuroscience. 2015 Jan;18(1):154–61.

28. Jaffe AE, Murakami P, Lee H, Leek JT, Fallin DM, Feinberg AP, et al. Bump hunting to identify differentially methylated regions in epigenetic epidemiology studies. International journal of epidemiology. 2012;41(1):200–9.

29. Oleś A, Morgan M, Huber W. BiocStyle: Standard styles for vignettes and other bioconductor documents. 2017.