Period 3 - Gene set analysis

Ludwig Geistlinger

Abstract

Overview of existing methods for enrichment analysis of gene expression data with regard to functional gene sets, pathways, and networks. Functionality for differential expression analysis, set- and network-based enrichment analysis, along with visualization and exploration of results. Introduction to concepts for enrichment analysis of genomic regions and regulatory elements. Required packages: EnrichmentBrowser, ALL, hgu95av2.db, airway, regioneR, BSgenome.Hsapiens.UCSC.hg19.masked

<img src="https://github.com/waldronlab/BrownCOBRE2018/blob/master/notebooks_day2/ExpressionDataAnalysis.png?raw=true", alt="ExpressionDataAnalysis image", style="width:500px">

Where does it all come from?

Test whether known biological functions or processes are over-represented (= enriched) in an experimentally-derived gene list, e.g. a list of differentially expressed (DE) genes. See Goeman and Buehlmann, 2007 for a critical review.

Example: Transcriptomic study, in which 12,671 genes have been tested for differential expression between two sample conditions and 529 genes were found DE.

Among the DE genes, 28 are annotated to a specific functional gene set, which contains in total 170 genes. This setup corresponds to a 2x2 contingency table,

In [1]:
deTable <-
     matrix(c(28, 142, 501, 12000),
            nrow = 2,
            dimnames = list(c("DE", "Not.DE"),
                            c("In.gene.set", "Not.in.gene.set")))
deTable
In.gene.setNot.in.gene.set
DE 28 501
Not.DE142 12000

where the overlap of 28 genes can be assessed based on the hypergeometric distribution. This corresponds to a one-sided version of Fisher's exact test, yielding here a significant enrichment.

In [2]:
fisher.test(deTable, alternative = "greater")
	Fisher's Exact Test for Count Data

data:  deTable
p-value = 4.088e-10
alternative hypothesis: true odds ratio is greater than 1
95 percent confidence interval:
 3.226736      Inf
sample estimates:
odds ratio 
  4.721744 

This basic principle is at the foundation of major public and commercial enrichment tools such as DAVID and Pathway Studio.

Although gene set enrichment methods have been primarily developed and applied on transcriptomic data, they have recently been modified, extended and applied also in other fields of genomic and biomedical research. This includes novel approaches for functional enrichment analysis of proteomic and metabolomic data as well as genomic regions and disease phenotypes, Lavallee and Yates, 2016, Chagoyen et al., 2016, McLean et al., 2010, Ried et al., 2012.

Gene expression-based enrichment analysis

The first part of the workshop is largely based on the EnrichmentBrowser package, which implements an analysis pipeline for high-throughput gene expression data as measured with microarrays and RNA-seq. In a workflow-like manner, the package brings together a selection of established Bioconductor packages for gene expression data analysis. It integrates a wide range of gene set enrichment analysis methods and facilitates combination and exploration of results across methods.

<img src="https://github.com/waldronlab/BrownCOBRE2018/blob/master/notebooks_day2/EnrichmentBrowserWorkflow.png?raw=true", alt="EnrichmentBrowserWorkflow image", style="width:650px">

In [3]:
suppressPackageStartupMessages(library(EnrichmentBrowser))

Further information can be found in the vignette and publication.

A primer on terminology, existing methods & statistical theory

Gene sets, pathways & regulatory networks

Gene sets are simple lists of usually functionally related genes without further specification of relationships between genes.

Pathways can be interpreted as specific gene sets, typically representing a group of genes that work together in a biological process. Pathways are commonly divided in metabolic and signaling pathways. Metabolic pathways such as glycolysis represent biochemical substrate conversions by specific enzymes. Signaling pathways such as the MAPK signaling pathway describe signal transduction cascades from receptor proteins to transcription factors, resulting in activation or inhibition of specific target genes.

Gene regulatory networks describe the interplay and effects of regulatory factors (such as transcription factors and microRNAs) on the expression of their target genes.

Resources

GO and KEGG annotations are most frequently used for the enrichment analysis of functional gene sets. Despite an increasing number of gene set and pathway databases, they are typically the first choice due to their long-standing curation and availability for a wide range of species.

GO: The Gene Ontology (GO) consists of three major sub-ontologies that classify gene products according to molecular function (MF), biological process (BP) and cellular component (CC). Each ontology consists of GO terms that define MFs, BPs or CCs to which specific genes are annotated. The terms are organized in a directed acyclic graph, where edges between the terms represent relationships of different types. They relate the terms according to a parent-child scheme, i.e. parent terms denote more general entities, whereas child terms represent more specific entities.

KEGG: The Kyoto Encyclopedia of Genes and Genomes (KEGG) is a collection of manually drawn pathway maps representing molecular interaction and reaction networks. These pathways cover a wide range of biochemical processes that can be divided in 7 broad categories: metabolism, genetic and environmental information processing, cellular processes, organismal systems, human diseases, and drug development. Metabolism and drug development pathways differ from pathways of the other 5 categories by illustrating reactions between chemical compounds. Pathways of the other 5 categories illustrate molecular interactions between genes and gene products.

Gene set analysis vs. gene set enrichment analysis

The two predominantly used enrichment methods are:

  • Overrepresentation analysis (ORA), testing whether a gene set contains disproportional many genes of significant expression change, based on the procedure outlined in the first section
  • Gene set enrichment analysis (GSEA), testing whether genes of a gene set accumulate at the top or bottom of the full gene vector ordered by direction and magnitude of expression change Subramanian et al., 2005

However, the term gene set enrichment analysis nowadays subsumes a general strategy implemented by a wide range of methods Huang et al., 2009. Those methods have in common the same goal, although approach and statistical model can vary substantially Goeman and Buehlmann, 2007, Khatri et al., 2012.

To better distinguish from the specific method, some authors use the term gene set analysis to denote the general strategy. However, there is also a specific method from Efron and Tibshirani, 2007 of this name.

Underlying null: competitive vs. self-contained

Goeman and Buehlmann, 2007 classified existing enrichment methods into competitive and self-contained based on the underlying null hypothesis.

  • Competitive null hypothesis: the genes in the set of interest are at most as often DE as the genes not in the set,
  • Self-contained null hypothesis: no genes in the set of interest are DE.

Although the authors argue that a self-contained null is closer to the actual question of interest, the vast majority of enrichment methods is competitive.

Goeman and Buehlmann further raise several critical issues concerning the 2x2 ORA:

  • rather arbitrary classification of genes in DE / not DE
  • based on gene sampling, although sampling of subjects is appropriate
  • unrealistic independence assumption between genes, resulting in highly anti-conservative p-values

With regard to these statistical concerns, GSEA is considered superior:

  • takes all measured genes into account
  • subject sampling via permutation of class labels
  • the incorporated permutation procedure implicitly accounts for correlations between genes

However, the simplicity and general applicability of ORA is unmet by subsequent methods improving on these issues. For instance, GSEA requires the expression data as input, which is not available for gene lists derived from other experiment types. On the other hand, the involved sample permutation procedure has been proven inaccurate and time-consuming Efron and Tibshirani, 2007, Phipson and Smyth, 2010, Larson and Owen, 2015.

Generations: ora, fcs & topology-based

Khatri et al., 2012 have taken a slightly different approach by classifying methods along the timeline of development into three generations:

  1. Generation: ORA methods based on the 2x2 contingency table test,
  2. Generation: functional class scoring (FCS) methods such as GSEA, which compute gene set (= functional class) scores by summarizing per-gene DE statistics,
  3. Generation: topology-based methods, explicitly taking into account interactions between genes as defined in signaling pathways and gene regulatory networks (Geistlinger et al., 2011 for an example).

Although topology-based (also: network-based) methods appear to be most realistic, their straightforward application can be impaired by features that are not-detectable on the transcriptional level (such as protein-protein interactions) and insufficient network knowledge Geistlinger et al., 2013, Bayerlova et al., 2015.

Given the individual benefits and limitations of existing methods, cautious interpretation of results is required to derive valid conclusions. Whereas no single method is best suited for all application scenarios, applying multiple methods can be beneficial. This has been shown to filter out spurious hits of individual methods, thereby reducing the outcome to gene sets accumulating evidence from different methods Geistlinger et al., 2016, Alhamdoosh et al., 2017.

Data types

Although RNA-seq (read count data) has become the de facto standard for transcriptomic profiling, it is important to know that many methods for differential expression and gene set enrichment analysis have been originally developed for microarray data (intensity measurements).

However, differences in data distribution assumptions (microarray: quasi-normal, RNA-seq: negative binomial) made adaptations in differential expression analysis and, to some extent, also in gene set enrichment analysis necessary.

Thus, we consider two example datasets - a microarray and a RNA-seq dataset, and discuss similarities and differences of the respective analysis steps.

For microarray data, we consider expression measurements of patients with acute lymphoblastic leukemia Chiaretti et al., 2004. A frequent chromosomal defect found among these patients is a translocation, in which parts of chromosome 9 and 22 swap places. This results in the oncogenic fusion gene BCR/ABL created by positioning the ABL1 gene on chromosome 9 to a part of the BCR gene on chromosome 22.

We load the ALL dataset

In [4]:
library(ALL)
data(ALL)

and select B-cell ALL patients with and without the BCR/ABL fusion, as described previously Gentleman et al., 2005.

In [5]:
ind.bs <- grep("^B", ALL$BT)
ind.mut <- which(ALL$mol.biol %in% c("BCR/ABL", "NEG"))
sset <- intersect(ind.bs, ind.mut)
all.eset <- ALL[, sset]

We can now access the expression values, which are intensity measurements on a log-scale for 12,625 probes (rows) across 79 patients (columns).

In [6]:
dim(all.eset)
Features
12625
Samples
79
In [7]:
exprs(all.eset)[1:4,1:4]
01005010100300204007
1000_at7.5973237.4794457.5675937.905312
1001_at5.0461944.9325374.7992944.844565
1002_f_at3.9004664.2081553.8861693.416923
1003_s_at5.9038566.1690245.8604595.687997

As we often have more than one probe per gene, we compute gene expression values as the average of the corresponding probe values.

In [8]:
all.eset <- probe.2.gene.eset(all.eset) 
head(names(all.eset))
Loading required package: hgu95av2.db

  1. '5595'
  2. '7075'
  3. '1557'
  4. '643'
  5. '1843'
  6. '4319'

For RNA-seq data, we consider transcriptome profiles of four primary human airway smooth muscle cell lines in two conditions: control and treatment with dexamethasone Himes et al., 2014.

We load the airway dataset

In [9]:
library(airway)
data(airway)

For further analysis, we only keep genes that are annotated to an ENSEMBL gene ID.

In [10]:
air.eset <- airway[grep("^ENSG", names(airway)), ]
dim(air.eset)
  1. 63677
  2. 8
In [11]:
assay(air.eset)[1:4,1:4]
SRR1039508SRR1039509SRR1039512SRR1039513
ENSG00000000003679448873408
ENSG00000000005 0 0 0 0
ENSG00000000419467515621365
ENSG00000000457260211263164

Differential expression analysis

Normalization of high-throughput expression data is essential to make results within and between experiments comparable. Microarray (intensity measurements) and RNA-seq (read counts) data typically show distinct features that need to be normalized for. As this is beyond the scope of this workshop, we refer to limma for microarray normalization and EDASeq for RNA-seq normalization. See also EnrichmentBrowser::normalize, which wraps commonly used functionality for normalization.

The EnrichmentBrowser incorporates established functionality from the limma package for differential expression analysis. This involves the voom transformation when applied to RNA-seq data. Alternatively, differential expression analysis for RNA-seq data can also be carried out based on the negative binomial distribution with edgeR and DESeq2.

This can be performed using the function EnrichmentBrowser::de.ana and assumes some standardized variable names:

  • GROUP defines the sample groups being contrasted,
  • BLOCK defines paired samples or sample blocks, as e.g. for batch effects.

For more information on experimental design, see the limma user's guide, chapter 9.

For the ALL dataset, the GROUP variable indicates whether the BCR-ABL gene fusion is present (1) or not (0).

In [12]:
all.eset$GROUP <- ifelse(all.eset$mol.biol == "BCR/ABL", 1, 0)
table(all.eset$GROUP)
 0  1 
42 37 

For the airway dataset, it indicates whether the cell lines have been treated with dexamethasone (1) or not (0).

In [13]:
air.eset$GROUP <- ifelse(colData(airway)$dex == "trt", 1, 0)
table(air.eset$GROUP)
0 1 
4 4 

Paired samples, or in general sample batches/blocks, can be defined via a BLOCK column in the colData slot. For the airway dataset, the sample blocks correspond to the four different cell lines.

In [14]:
air.eset$BLOCK <- airway$cell
table(air.eset$BLOCK)
N052611 N061011 N080611  N61311 
      2       2       2       2 

For microarray data, the EnrichmentBrowser::de.ana function carries out differential expression analysis based on functionality from the limma package. Resulting log2 fold changes and t-test derived p-values for each gene are appended to the rowData slot.

In [15]:
all.eset <- de.ana(all.eset)
rowData(all.eset, use.names=TRUE)
DataFrame with 9010 rows and 3 columns
               FC  ADJ.PVAL limma.STAT
        <numeric> <numeric>  <numeric>
5595   0.04296986 0.8992468  0.7346792
7075   0.03208350 0.9490010  0.4546911
1557  -0.04394014 0.8183301 -1.0657826
643   -0.02775435 0.9291486 -0.5673944
1843  -0.42730253 0.5660348 -1.7505023
...           ...       ...        ...
6300 -0.026651766 0.9228285 -0.6086089
7297 -0.124257678 0.8045785 -1.1127949
2246  0.052242886 0.7480210  1.2740842
7850 -0.009082296 0.9918265 -0.1024063
1593 -0.007477138 0.9895330 -0.1456503

Nominal p-values are already corrected for multiple testing (ADJ.PVAL) using the method from Benjamini and Hochberg implemented in stats::p.adjust.

For RNA-seq data, the de.ana function can be used to carry out differential expression analysis between the two groups either based on functionality from limma (that includes the voom transformation), or alternatively, the frequently used edgeR or DESeq2 package. Here, we use the analysis based on edgeR.

In [16]:
air.eset <- de.ana(air.eset, de.method="edgeR")
Excluding 50740 genes not satisfying min.cpm threshold
Loading required package: edgeR
Loading required package: limma

Attaching package: 'limma'

The following object is masked from 'package:BiocGenerics':

    plotMA

In [17]:
rowData(air.eset, use.names=TRUE)
DataFrame with 12937 rows and 3 columns
                          FC    ADJ.PVAL   edgeR.STAT
                   <numeric>   <numeric>    <numeric>
ENSG00000000003  -0.40494563 0.002134583  35.87437100
ENSG00000000419   0.18298543 0.091569195   5.90960620
ENSG00000000457   0.01434777 0.922279475   0.02339233
ENSG00000000460  -0.14117337 0.619013214   0.49292996
ENSG00000000971   0.40224043 0.004038205  27.85099620
...                      ...         ...          ...
ENSG00000273270 -0.129793853 0.495892936 9.015984e-01
ENSG00000273290  0.505580472 0.006392184 2.309057e+01
ENSG00000273311  0.001615576 0.996356137 8.048212e-05
ENSG00000273329 -0.222817127 0.388294594 1.427233e+00
ENSG00000273344  0.015170401 0.962777106 5.435033e-03

Exercise: Compare the number of differentially expressed genes as obtained on the air.eset with limma/voom, edgeR, and DESeq2.

Gene sets

We are now interested in whether pre-defined sets of genes that are known to work together, e.g. as defined in the Gene Ontology or the KEGG pathway annotation, are coordinately differentially expressed. The function get.kegg.genesets downloads all KEGG pathways for a chosen organism (here: Homo sapiens) as gene sets using NCBI Entrez Gene IDs.

In [18]:
kegg.gs <- get.kegg.genesets("hsa")

Analogously, the function get.go.genesets retrieves GO terms of a selected ontology (here: biological process, BP) as defined in the GO.db annotation package.

In [19]:
go.gs <- get.go.genesets(org="hsa", onto="BP", mode="GO.db")

User-defined gene sets can be parsed from GMT file format. Here, we are using this functionality for reading a list of already downloaded KEGG gene sets for Homo sapiens containing NCBI Entrez Gene IDs.

In [20]:
data.dir <- system.file("extdata", package="EnrichmentBrowser")
gmt.file <- file.path(data.dir, "hsa_kegg_gs.gmt")
hsa.gs <- parse.genesets.from.GMT(gmt.file)
length(hsa.gs)
39
In [21]:
hsa.gs[1:2]
$hsa05416_Viral_myocarditis
  1. '100509457'
  2. '101060835'
  3. '1525'
  4. '1604'
  5. '1605'
  6. '1756'
  7. '1981'
  8. '1982'
  9. '25'
  10. '2534'
  11. '27'
  12. '3105'
  13. '3106'
  14. '3107'
  15. '3108'
  16. '3109'
  17. '3111'
  18. '3112'
  19. '3113'
  20. '3115'
  21. '3117'
  22. '3118'
  23. '3119'
  24. '3122'
  25. '3123'
  26. '3125'
  27. '3126'
  28. '3127'
  29. '3133'
  30. '3134'
  31. '3135'
  32. '3383'
  33. '3683'
  34. '3689'
  35. '3908'
  36. '4624'
  37. '4625'
  38. '54205'
  39. '5551'
  40. '5879'
  41. '5880'
  42. '5881'
  43. '595'
  44. '60'
  45. '637'
  46. '6442'
  47. '6443'
  48. '6444'
  49. '6445'
  50. '71'
  51. '836'
  52. '841'
  53. '842'
  54. '857'
  55. '8672'
  56. '940'
  57. '941'
  58. '942'
  59. '958'
  60. '959'
$`hsa04622_RIG-I-like_receptor_signaling_pathway`
  1. '10010'
  2. '1147'
  3. '1432'
  4. '1540'
  5. '1654'
  6. '23586'
  7. '26007'
  8. '29110'
  9. '338376'
  10. '340061'
  11. '3439'
  12. '3440'
  13. '3441'
  14. '3442'
  15. '3443'
  16. '3444'
  17. '3445'
  18. '3446'
  19. '3447'
  20. '3448'
  21. '3449'
  22. '3451'
  23. '3452'
  24. '3456'
  25. '3467'
  26. '3551'
  27. '3576'
  28. '3592'
  29. '3593'
  30. '3627'
  31. '3661'
  32. '3665'
  33. '4214'
  34. '4790'
  35. '4792'
  36. '4793'
  37. '5300'
  38. '54941'
  39. '55593'
  40. '5599'
  41. '5600'
  42. '5601'
  43. '5602'
  44. '5603'
  45. '56832'
  46. '57506'
  47. '5970'
  48. '6300'
  49. '64135'
  50. '64343'
  51. '6885'
  52. '7124'
  53. '7186'
  54. '7187'
  55. '7189'
  56. '7706'
  57. '79132'
  58. '79671'
  59. '80143'
  60. '841'
  61. '843'
  62. '8517'
  63. '8717'
  64. '8737'
  65. '8772'
  66. '9140'
  67. '9474'
  68. '9636'
  69. '9641'
  70. '9755'

See also the MSigDb for additional gene set collections.

GO/KEGG overrepresentation analysis

A variety of gene set analysis methods have been proposed Khatri et al., 2012. The most basic, yet frequently used, method is the over-representation analysis (ORA) with gene sets defined according to GO or KEGG. As outlined in the first section, ORA tests the overlap between DE genes (typically DE p-value < 0.05) and genes in a gene set based on the hypergeometric distribution. Here, we choose a significance level $\alpha = 0.2$ for demonstration.

In [22]:
ora.all <- sbea(method="ora", eset=all.eset, gs=hsa.gs, perm=0, alpha=0.2)
gs.ranking(ora.all)
DataFrame with 7 rows and 4 columns
                                                         GENE.SET  NR.GENES
                                                      <character> <numeric>
1                hsa05202_Transcriptional_misregulation_in_cancer       153
2 hsa05412_Arrhythmogenic_right_ventricular_cardiomyopathy_(ARVC)        63
3                                                hsa05144_Malaria        45
4                   hsa04670_Leukocyte_transendothelial_migration        94
5                 hsa05100_Bacterial_invasion_of_epithelial_cells        64
6                  hsa04622_RIG-I-like_receptor_signaling_pathway        54
7                  hsa05130_Pathogenic_Escherichia_coli_infection        43
  NR.SIG.GENES   P.VALUE
     <numeric> <numeric>
1           17    0.0351
2            8    0.0717
3            6    0.0932
4           10    0.1220
5            7    0.1620
6            6    0.1780
7            5    0.1840

Such a ranked list is the standard output of most existing enrichment tools. Using the ea.browse function creates a HTML summary from which each gene set can be inspected in more detail.

<img src="https://github.com/waldronlab/BrownCOBRE2018/blob/master/notebooks_day2/EnrichmentBrowserNavigation.png?raw=true", alt="EnrichmentBrowserNavigation image", style="width:600px">

In [23]:
ea.browse(ora.all)
Creating gene report ...
Creating set view ...
Creating kegg view ...

The resulting summary page includes for each significant gene set

  • a gene report, which lists all genes of a set along with fold change and DE $p$-value (click on links in column NR.GENES),
  • interactive overview plots such as heatmap and volcano plot (column SET.VIEW, supports mouse-over and click-on),
  • for KEGG pathways: highlighting of differentially expressed genes on the pathway maps (column PATH.VIEW, supports mouse-over and click-on).

As ORA works on the list of DE genes and not the actual expression values, it can be straightforward applied to RNA-seq data. However, as the gene sets here contain NCBI Entrez gene IDs and the airway dataset contains ENSEMBL gene ids, we first map the airway dataset to Entrez IDs.

In [24]:
air.eset <- map.ids(air.eset, org="hsa", from="ENSEMBL", to="ENTREZID")
'select()' returned 1:many mapping between keys and columns
Excluded 1141 genes without a corresponding to.ID
Encountered 15 from.IDs with >1 corresponding to.ID (a single to.ID was chosen for each of them)
In [25]:
ora.air <- sbea(method="ora", eset=air.eset, gs=hsa.gs, perm=0)
gs.ranking(ora.air)
DataFrame with 9 rows and 4 columns
                                                         GENE.SET  NR.GENES
                                                      <character> <numeric>
1                                    hsa05206_MicroRNAs_in_cancer       118
2                                               hsa05218_Melanoma        50
3                                                 hsa05214_Glioma        47
4                                            hsa05131_Shigellosis        53
5                      hsa05410_Hypertrophic_cardiomyopathy_(HCM)        53
6                   hsa04670_Leukocyte_transendothelial_migration        62
7                 hsa05100_Bacterial_invasion_of_epithelial_cells        60
8                         hsa04514_Cell_adhesion_molecules_(CAMs)        60
9 hsa05412_Arrhythmogenic_right_ventricular_cardiomyopathy_(ARVC)        48
  NR.SIG.GENES   P.VALUE
     <numeric> <numeric>
1           68  0.000523
2           33  0.000674
3           30  0.002660
4           31  0.014400
5           31  0.014400
6           34  0.035700
7           33  0.036500
8           33  0.036500
9           27  0.040600

Note #1: Young et al., 2010, have reported biased results for ORA on RNA-seq data due to over-detection of differential expression for long and highly expressed transcripts. The goseq package and limma::goana implement possibilities to adjust ORA for gene length and abundance bias.

Note #2: Independent of the expression data type under investigation, overlap between gene sets can result in redundant findings. This is well-documented for GO (parent-child structure, Rhee et al., 2008) and KEGG (pathway overlap/crosstalk, Donato et al., 2013). The topGO package (explicitly designed for GO) and mgsa (applicable to arbitrary gene set definitions) implement modifications of ORA to account for such redundancies.

Functional class scoring & permutation testing

A major limitation of ORA is that it restricts analysis to DE genes, excluding genes not satisfying the chosen significance threshold (typically the vast majority).

This is resolved by gene set enrichment analysis (GSEA), which scores the tendency of gene set members to appear rather at the top or bottom of the ranked list of all measured genes Subramanian et al., 2005. The statistical significance of the enrichment score (ES) of a gene set is assessed via sample permutation, i.e. (1) sample labels (= group assignment) are shuffled, (2) per-gene DE statistics are recomputed, and (3) the enrichment score is recomputed. Repeating this procedure many times allows to determine the empirical distribution of the enrichment score and to compare the observed enrichment score against it. Here, we carry out GSEA with 1000 permutations.

In [26]:
gsea.all <- sbea(method="gsea", eset=all.eset, gs=hsa.gs, perm=1000)
Permutations: 1 -- 100
Permutations: 101 -- 200
Permutations: 201 -- 300
Permutations: 301 -- 400
Permutations: 401 -- 500
Permutations: 501 -- 600
Permutations: 601 -- 700
Permutations: 701 -- 800
Permutations: 801 -- 900
Permutations: 901 -- 1000
Processing ...
In [27]:
gs.ranking(gsea.all)
DataFrame with 20 rows and 4 columns
                                                           GENE.SET        ES
                                                        <character> <numeric>
1   hsa05412_Arrhythmogenic_right_ventricular_cardiomyopathy_(ARVC)     0.511
2                     hsa04670_Leukocyte_transendothelial_migration     0.499
3                                        hsa04520_Adherens_junction     0.488
4                                  hsa04390_Hippo_signaling_pathway     0.459
5                                     hsa05323_Rheumatoid_arthritis     0.574
...                                                             ...       ...
16                                    hsa05217_Basal_cell_carcinoma     0.559
17                                               hsa04210_Apoptosis     0.424
18                   hsa05130_Pathogenic_Escherichia_coli_infection     0.486
19                       hsa05410_Hypertrophic_cardiomyopathy_(HCM)     0.386
20                                             hsa05131_Shigellosis     0.479
          NES   P.VALUE
    <numeric> <numeric>
1        1.92    0.0000
2        1.78    0.0000
3        1.74    0.0000
4        1.67    0.0000
5        1.66    0.0019
...       ...       ...
16       1.64    0.0248
17       1.44    0.0336
18       1.54    0.0347
19       1.45    0.0406
20       1.49    0.0436

As GSEA's permutation procedure involves re-computation of per-gene DE statistics, adaptations are necessary for RNA-seq. The EnrichmentBrowser implements an accordingly adapted version of GSEA, which allows incorporation of limma/voom, edgeR, or DESeq2 for repeated DE re-computation within GSEA. However, this is computationally intensive (for limma/voom the least, for DESeq2 the most). Note the relatively long running times for only 100 permutations having used edgeR for DE analysis.

In [28]:
gsea.air <- sbea(method="gsea", eset=air.eset, gs=hsa.gs, perm=100)
100 permutations completed

While it might be in some cases necessary to apply permutation-based GSEA for RNA-seq data, there are also alternatives avoiding permutation. Among them is ROtAtion gene Set Testing (ROAST), which uses rotation instead of permutation Wu et al., 2010.

In [29]:
roast.air <- sbea(method="roast", eset=air.eset, gs=hsa.gs)
gs.ranking(roast.air)
DataFrame with 27 rows and 4 columns
                                        GENE.SET  NR.GENES       DIR   P.VALUE
                                     <character> <numeric> <numeric> <numeric>
1     hsa05410_Hypertrophic_cardiomyopathy_(HCM)        53         1     0.001
2                         hsa05134_Legionellosis        35         1     0.001
3                     hsa05416_Viral_myocarditis        33         1     0.001
4                   hsa00790_Folate_biosynthesis        11         1     0.001
5            hsa03420_Nucleotide_excision_repair        42        -1     0.001
...                                          ...       ...       ...       ...
23               hsa04150_mTOR_signaling_pathway        50         1     0.027
24           hsa04350_TGF-beta_signaling_pathway        63         1     0.029
25              hsa00561_Glycerolipid_metabolism        39         1     0.032
26  hsa04621_NOD-like_receptor_signaling_pathway        40        -1     0.033
27       hsa04514_Cell_adhesion_molecules_(CAMs)        60        -1     0.035

A selection of additional methods is also available:

In [30]:
sbea.methods()
  1. 'ora'
  2. 'safe'
  3. 'gsea'
  4. 'samgs'
  5. 'ebm'
  6. 'mgsa'
  7. 'gsa'
  8. 'padog'
  9. 'globaltest'
  10. 'roast'
  11. 'camera'
  12. 'gsva'

Exercise: Carry out a GO overrepresentation analysis for the all.eset and air.eset. How many significant gene sets do you observe in each case?

Network-based enrichment analysis

Having found gene sets that show enrichment for differential expression, we are now interested whether these findings can be supported by known regulatory interactions.

For example, we want to know whether transcription factors and their target genes are expressed in accordance to the connecting regulations (activation/inhibition). Such information is usually given in a gene regulatory network derived from specific experiments or compiled from the literature (Geistlinger et al., 2013 for an example).

There are well-studied processes and organisms for which comprehensive and well-annotated regulatory networks are available, e.g. the RegulonDB for E. coli and Yeastract for S. cerevisiae.

However, there are also cases where such a network is missing or at least incomplete. A basic workaround is to compile a network from regulations in the KEGG database.

We can download all KEGG pathways of a specified organism (here: Homo sapiens) via

But for demonstration purposes, we use a selection of already downloaded human KEGG pathways:

In [31]:
pwys <- file.path(data.dir, "hsa_kegg_pwys.zip")
hsa.grn <- compile.grn.from.kegg(pwys)
head(hsa.grn)
FROMTOTYPE
35693570+
34583459+
34583460+
19501956+
19502064+
19503480+

Signaling pathway impact analysis (SPIA) is a network-based enrichment analysis method, which is explicitly designed for KEGG signaling pathways Tarca et al., 2009. The method evaluates whether expression changes are propagated across the pathway topology in combination with ORA.

In [ ]:
spia.all <- nbea(method="spia", eset=all.eset, gs=hsa.gs, grn=hsa.grn, alpha=0.2)
gs.ranking(spia.all)

More generally applicable is gene graph enrichment analysis (GGEA), which evaluates consistency of interactions in a given gene regulatory network with the observed expression data Geistlinger et al., 2011.

In [ ]:
ggea.all <- nbea(method="ggea", eset=all.eset, gs=hsa.gs, grn=hsa.grn)
gs.ranking(ggea.all)

A selection of additional network-based methods is also available:

In [ ]:
nbea.methods()

Note #1: As network-based enrichment methods typically do not involve sample permutation but rather network permutation, thus avoiding DE re-computation, they can likewise be applied to RNA-seq data.

Note #2: Given the various enrichment methods with individual benefits and limitations, combining multiple methods can be beneficial, e.g. combined application of a set-based and a network-based method. This has been shown to filter out spurious hits of individual methods and to reduce the outcome to gene sets accumulating evidence from different methods Geistlinger et al., 2016, Alhamdoosh et al., 2017.

The function comb.ea.results implements the straightforward combination of results, thereby facilitating seamless comparison of results across methods. For demonstration, we use the ORA and GSEA results for the ALL dataset from the previous section:

In [ ]:
res.list <- list(ora.all, gsea.all)
comb.res <- comb.ea.results(res.list)
gs.ranking(comb.res)

Exercise: Carry out SPIA and GGEA for the air.eset and combine the results. How many gene sets are rendered significant by both methods?

Genomic region enrichment analysis

Microarrays and next-generation sequencing are also widely applied for large-scale detection of variable and regulatory genomic regions, e.g. single nucleotide polymorphisms, copy number variations, and transcription factor binding sites.

<img src="https://github.com/waldronlab/BrownCOBRE2018/blob/master/notebooks_day2/ENCODE.png?raw=true", alt="ENCODE image", style="width:600px">

Such experimentally-derived genomic region sets are raising similar questions regarding functional enrichment as in gene expression data analysis.

Of particular interest is thereby whether experimentally-derived regions overlap more (enrichment) or less (depletion) than expected by chance with regions representing known functional features such as genes or promoters.

The regioneR package implements a general framework for testing overlaps of genomic regions based on permutation sampling. This allows to repeatedly sample random regions from the genome, matching size and chromosomal distribution of the region set under study. By recomputing the overlap with the functional features in each permutation, statistical significance of the observed overlap can be assessed.

In [ ]:
suppressPackageStartupMessages(library(regioneR))

To demonstrate the basic functionality of the package, we consider the overlap of gene promoter regions and CpG islands in the human genome. We expect to find an enrichment as promoter regions are known to be GC-rich. Hence, is the overlap between CpG islands and promoters greater than expected by chance?

We use the collection of CpG islands described in Wu et al., 2010 and restrict them to the set of canonical chromosomes 1-23, X, and Y.

In [ ]:
cpgHMM <- toGRanges("http://www.haowulab.org/software/makeCGI/model-based-cpg-islands-hg19.txt")
cpgHMM <- filterChromosomes(cpgHMM, chr.type="canonical")
cpgHMM <- sort(cpgHMM)
cpgHMM

Analogously, we load promoter regions in the hg19 human genome assembly as available from UCSC:

In [ ]:
promoters <- toGRanges("http://gattaca.imppc.org/regioner/data/UCSC.promoters.hg19.bed")
promoters <- filterChromosomes(promoters, chr.type="canonical")
promoters <- sort(promoters)
promoters

To speed up the example, we restrict analysis to chromosomes 21 and 22. Note that this is done for demonstration only. To make an accurate claim, the complete region set should be used (which, however, runs considerably longer).

In [ ]:
cpg <- cpgHMM[seqnames(cpgHMM) %in% c("chr21", "chr22")]
prom <- promoters[seqnames(promoters) %in% c("chr21", "chr22")]

Now, we are applying an overlap permutation test with 100 permutations (ntimes=100), while maintaining chromosomal distribution of the CpG island region set (per.chromosome=TRUE). Furthermore, we use the option count.once=TRUE to count an overlapping CpG island only once, even if it overlaps with 2 or more promoters.

This takes about 2 minutes on a standard laptop. It also takes too much memory for the machines used by the workshop, so the command is commented out and the object loaded from file instead.

In [ ]:
# pt <- overlapPermTest(cpg, prom, genome="hg19", ntimes=100, per.chromosome=TRUE, count.once=TRUE)
download.file("https://www.dropbox.com/s/dlqq0m99wpu5xab/BrownCOBREDay2Session3_pt.rds?raw=1", destfile="BrownCOBREDay2Session3_pt.rds")
pt <- readRDS("BrownCOBREDay2Session3_pt.rds")
pt
In [ ]:
summary(pt[[1]]$permuted)

The resulting permutation p-value indicates a significant enrichment. Out of the 2859 CpG islands, 719 overlap with at least one promoter. In contrast, when repeatedly drawing random regions matching the CpG islands in size and chromosomal distribution, the mean number of overlapping regions across permutations was 117.7 $\pm$ 11.8.

Note #1: The function regioneR::permTest allows to incorporate user-defined functions for randomizing regions and evaluating additional measures of overlap such as total genomic size in bp.

Note #2: The LOLA package implements a genomic region ORA, which assesses genomic region overlap based on the hypergeometric distribution using a library of pre-defined functional region sets.