pathfindR - An R Package for Pathway Enrichment Analysis Utilizing Active Subnetworks

Ege Ulgen

2018-06-10

pathfindR is an R package for pathway enrichment analysis of gene-level differential expression/methylation data utilizing active subnetworks. The package also enables hierarchical clustering of the enriched pathways. The method is described in detail in Ulgen E, Ozisik O, Sezerman OU. 2018. pathfindR: An R Package for Pathway Enrichment Analysis Utilizing Active Subnetworks. bioRxiv. https://doi.org/10.1101/272450

Our motivation to develop this package was that direct pathway enrichment analysis of differential RNA/protein expression or DNA methylation results may not provide the researcher with the full picture. That is to say; pathway enrichment of only the list of significant genes may not be informative enough to explain the underlying disease mechanisms.

An active subnetwork is defined as a group of interconnected genes in a protein-protein interaction network (PIN) that contains most of the significant genes. Therefore, these active subnetworks define distinct disease-associated sets of genes, whether discovered through differential expression analysis or discovered because of being in interaction with a significant gene.

Therefore, we propose to leverage information from a PIN to identify distinct active subnetworks and then perform pathway enrichment analyses on these subnetworks. Briefly, this workflow first maps the significant genes onto a PIN and finds active subnetworks. Next, pathway enrichment analyses are performed using each gene set of the identified active subnetworks. Finally, these enrichment results are summarized and returned as a data frame. This workflow is implemented as the function run_pathfindR() and further described in the “Enrichment Workflow” section of this vignette.

This process usually yields a great number of enriched pathways with related biological functions. We therefore implemented a pairwise distance metric (as proposed by Chen et al. [1]) between pathways and based on this distance metric, also implemented hierarchical clustering of the pathways through a shiny app, allowing dynamic partitioning of the dendrogram into relevant clusters. Details of clustering and partitioning of pathways are presented in the “Pathway Clustering” section of this vignette.

Enrichment Workflow

The overview of the enrichment workflow is presented in the figure below:

For this workflow, the wrapper function run_pathfindR() is used. This function takes in a data frame consisting of Gene Symbol, log-fold-change and adjusted-p values. The first 6 rows of an example input dataset (of rheumatoid arthritis differential-expression) can be found below:

suppressPackageStartupMessages(library(pathfindR))
data("RA_input")
knitr::kable(head(RA_input))
Gene.symbol logFC adj.P.Val
FAM110A -0.6939349 0.0000034
RNASE2 1.3535210 0.0000101
S100A8 1.5448338 0.0000347
S100A9 1.0280904 0.0002270
TEX261 -0.3236549 0.0002270
ARHGAP17 -0.6919441 0.0002716

Executing the workflow is straightforward (but takes several minutes):

RA_output <- run_pathfindR(RA_input)

The user may want to change certain arguments of the function:

# to change the output directory
RA_output <- run_pathfindR(RA_input, output = "new_directory")

# to change the PIN (default = Biogrid)
RA_output <- run_pathfindR(RA_input, pin_name = "IntAct")
# to use an external PIN of user's choice
RA_output <- run_pathfindR(RA_input, pin_name = "/path/to/myPIN.sif")

# available gene sets are KEGG, Reactome, BioCarta, GO-BP, GO-CC and GO-MF
# default is KEGG
# to change the gene sets used for enrichment analysis
RA_output <- run_pathfindR(RA_input, gene_sets = "BioCarta")

# to change the active subnetwork search algorithm (default = "GR", i.e. greedy algorithm)
# for simulated annealing:
RA_output <- run_pathfindR(RA_input, search_method = "SA")

# to change the number of iterations (default = 10)
RA_output <- run_pathfindR(RA_input, iterations = 5) 

# to manually specify the number processes used during parallel loop by foreach
# defaults to the number of detected cores 
RA_output <- run_pathfindR(RA_input, n_processes = 2)

# to report the non-DEG active subnetwork genes
RA_output <- run_pathfindR(RA_input, list_active_snw_genes = TRUE)

For a full list of arguments, see ?run_pathfindR.

The workflow consists of the following steps :

After input testing, the program attempts to convert any gene symbol that is not in the PIN to an alias symbol that is in the PIN. Next, active subnetwork search is performed via the selected algorithm. The available algorithms for active subnetwork search are:

Next, pathway enrichment analyses are performed using the genes in each of the active subnetworks. For this, up-to-date information on genes contained in each human KEGG pathway was retrieved with the help of the R package KEGGREST on Feb 26, 2018. These data are available in genes_by_pathway and pathways_list.

During enrichment analyses, pathways with adjusted-p values larger than the enrichment_threshold (an argument of run_pathfindR(), defaults to 0.05) are discarded. The results of enrichment analyses over all active subnetworks are combined by keeping only the lowest adjusted-p value for each pathway.

This process of active subnetwork search and enrichment analyses is repeated for a selected number of iterations (indicated by the iterations argument of run_pathfindR()), which is performed in parallel via the R package foreach.

The wrapper function returns a data frame that contains the lowest and the highest adjusted-p values for each enriched pathway, as well as the numbers of times each pathway is encountered over all iterations. The first two rows of the example output of the pathfindR-enrichment workflow (performed on the rheumatoid arthritis data RA_output) is shown below:

data("RA_output")
knitr::kable(head(RA_output, 2))
ID Pathway Fold_Enrichment occurrence lowest_p highest_p Up_regulated Down_regulated
hsa03040 Spliceosome 28.81102 10 1.1e-06 1.50e-06 SF3B6, LSM3, BUD31 SNRPB, SF3B2, U2AF2, PUF60, HNRNPA1, PCBP1, SRSF5, SRSF8, SNU13, DDX23, EIF4A3
hsa05130 Pathogenic Escherichia coli infection 48.39947 10 1.5e-05 1.83e-05 LY96, TLR5 ABL1, ITGB1, TUBB, ACTB, ACTG1

The function also creates an HTML report results.html that is saved in a directory, by default named pathfindr_Results but can be changed by changing the argument output_dir, under the current working directory. This report contains links to two other HTML files:

1. all_pathways.html

This document contains a table of the active subnetwork-oriented pathway enrichment results. Each enriched pathway name is linked to the visualization of that pathway, with the gene nodes colored according to their log-fold-change values. This table contains the same information as the returned data frame. Columns are:

2. genes_table.html

This document contains a table of converted gene symbols. Columns are:

The document contains a second table of genes for which no interactions were identified (after checking for alias symbols).

Pathway Clustering

For this workflow, the wrapper function choose_clusters() is used. This function first calculates the pairwise distances between the pathways in the input data frame, automatically determining the gene sets used for analysis. This step uses the distance metric described by Chen et al. [1]. By default, the function clusters the pathways using this distance matrix, automatically determines the optimal number of clusters by maximizing the average silhouette width and returns a data frame with cluster assignments:

data("RA_output")
RA_clustered <- choose_clusters(RA_output)
#> Calculating pairwise distances between pathways
#> 
#> Clustering pathways
#> 
#> Calculating the optimal number of clusters (based on average silhouette width)
#> 
#> The maximum average silhouette width was 0.38 for k = 16 
#> 
#> Returning the resulting data frame
## First 2 rows of clustered pathways data frame
knitr::kable(head(RA_clustered, 2))
ID Pathway Fold_Enrichment occurrence lowest_p highest_p Up_regulated Down_regulated Cluster Status
4 hsa04722 Neurotrophin signaling pathway 96.28947 3 0.0000506 0.0006648 CRKL, FASLG, SH2B3, ABL1, MAGED1, IRAK2, IKBKB, CALM1, CALM3 1 Representative
8 hsa05418 Fluid shear stress and atherosclerosis 83.79389 1 0.0010623 0.0010623 GSTO1, TXN, MMP9 KLF2, ACTB, ACTG1, SUMO3, IKBKB, CALM1, CALM3 1 Member
## The 16 representative pathways
knitr::kable(RA_clustered[RA_clustered$Status == "Representative", ])
ID Pathway Fold_Enrichment occurrence lowest_p highest_p Up_regulated Down_regulated Cluster Status
4 hsa04722 Neurotrophin signaling pathway 96.28947 3 0.0000506 0.0006648 CRKL, FASLG, SH2B3, ABL1, MAGED1, IRAK2, IKBKB, CALM1, CALM3 1 Representative
32 hsa03022 Basal transcription factors 130.09778 3 0.0293148 0.0293148 GTF2B, GTF2H5 TAF1L, TAF4, TAF15 2 Representative
13 hsa05012 Parkinson’s disease 82.84528 2 0.0028122 0.0028122 NDUFA1, NDUFB3, UQCRQ, COX6A1, COX7A2, COX7C SLC25A5, VDAC1, UBE2G1 3 Representative
15 hsa04022 cGMP-PKG signaling pathway 66.02707 2 0.0042559 0.0042559 NFATC3, SRF, ATP2A2, CREB1, ADCY7, SLC25A5, VDAC1, CALM1, CALM3 4 Representative
3 hsa03013 RNA transport 11.89366 10 0.0000419 0.0017152 NUP214 GEMIN4, EIF4A3, RNPS1, SRRM1, NUP62, NUP93, UBE2I, RANGAP1, SUMO3, EIF2S3, EIF2B1 5 Representative
7 hsa04064 NF-kappa B signaling pathway 97.57333 1 0.0008372 0.0008372 LY96 IKBKB, PRKCQ, CARD11, TICAM1, PARP1, UBE2I 6 Representative
1 hsa03040 Spliceosome 28.81102 10 0.0000011 0.0000015 SF3B6, LSM3, BUD31 SNRPB, SF3B2, U2AF2, PUF60, HNRNPA1, PCBP1, SRSF5, SRSF8, SNU13, DDX23, EIF4A3 7 Representative
2 hsa05130 Pathogenic Escherichia coli infection 48.39947 10 0.0000150 0.0000183 LY96, TLR5 ABL1, ITGB1, TUBB, ACTB, ACTG1 8 Representative
21 hsa00020 Citrate cycle (TCA cycle) 261.35714 4 0.0077542 0.0077542 MDH2, PDHA1, PDHB 9 Representative
39 hsa00970 Aminoacyl-tRNA biosynthesis 197.78378 2 0.0381108 0.0381108 IARS, SARS, YARS 10 Representative
27 hsa05110 Vibrio cholerae infection 21.44469 6 0.0197403 0.0223247 ATP6V0E1, ATP6V1D ARF1, ATP6V0E2, ACTB, ACTG1, PDIA4 11 Representative
31 hsa03460 Fanconi anemia pathway 149.34694 2 0.0254529 0.0254529 RPA1, TELO2, MLH1 12 Representative
5 hsa03420 Nucleotide excision repair 190.90435 3 0.0000986 0.0000986 GTF2H5, POLE4 POLD2, RPA1, XPC 13 Representative
26 hsa03050 Proteasome 170.18605 4 0.0176234 0.0176234 PSMD7, PSMB10 14 Representative
33 hsa00270 Cysteine and methionine metabolism 146.36000 3 0.0293148 0.0293148 MRI1, MAT2B, AHCYL2, DNMT1, GOT1, MDH2 15 Representative
24 hsa04130 SNARE interactions in vesicular transport 182.95000 3 0.0166367 0.0166367 STX10, STX6 BET1L, SNAP23, STX2 16 Representative

# to display the heatmap of pathway clustering
RA_clustered <- choose_clusters(RA_output, plot_heatmap = TRUE)
#> Calculating pairwise distances between pathways

#> Clustering pathways
#> 
#> Calculating the optimal number of clusters (based on average silhouette width)
#> 
#> The maximum average silhouette width was 0.38 for k = 16 
#> 
#> Returning the resulting data frame

# to display the dendrogram and clusters
RA_clustered <- choose_clusters(RA_output, plot_dend = TRUE)
#> Calculating pairwise distances between pathways
#> 
#> Clustering pathways
#> 
#> Calculating the optimal number of clusters (based on average silhouette width)

#> The maximum average silhouette width was 0.38 for k = 16 
#> 
#> Returning the resulting data frame

# to change agglomeration method (default = "average")
RA_clustered <- choose_clusters(RA_output, agg_method = "centroid")
#> Calculating pairwise distances between pathways
#> 
#> Clustering pathways
#> 
#> Calculating the optimal number of clusters (based on average silhouette width)
#> 
#> The maximum average silhouette width was 0.36 for k = 14 
#> 
#> Returning the resulting data frame

Alternatively, manual selection of the height at which to cut the dendrogram can be performed. For this, the user should set the auto parameter to FALSE. Via a shiny app, presented as an HTML document, the hierarchical clustering dendrogram is visualized. In this HTML document, the user can select the agglomeration method and the distance value at which to cut the tree. The dendrogram with the cut-off value marked with a red line is dynamically visualized and the resulting cluster assignments of the pathways along with annotation of representative pathways (chosen by smallest lowest p value) are presented as a table. This table can be saved as a csv file by pressing the button Get Pathways w\ Cluster Info. Example usage:

choose_clusters(RA_output, auto = FALSE)

Pathway Scores per Sample

The function calculate_pw_scores can be used to calculate the pathway scores per sample. This allows the user to individually examine the scores and infer whether a pathway is activated or repressed in a given sample.

For a set of pathways \(P = \{P_1, P_2, ... , P_k\}\), where each \(P_i\) contains a set of genes, i.e. \(P_i = \{g_1, g_2, ...\}\), the pathway score matrix \(PS\) is defined as:

\(PS_{p,s} = \frac{1}{k} \sum_{g \in P_p} GS_{g,s}\) for each pathway \(p\) and for each sample \(s\).

\(GS\) is the gene score per sample matrix and is defined as: \(GS_{g,s} = (EM_{g,s} - \bar{x}_g) / sd_g\) where \(EM\) is the expression matrix (columns are samples, rows are genes), \(\bar{x}_g\) is the mean expression value of the gene and \(sd_g\) is the standard deviaton of the expression values for the gene.

An example application is provided below:

## Pathway data frame
pws_table <- pathfindR::RA_clustered
# selecting "Representative" pathways for clear visualization
pws_table <- pws_table[pws_table$Status == "Representative", ]

## Expression matrix
exp_mat <- pathfindR::RA_exp_mat

## Vector of "Case" IDs
cases <- c("GSM389703", "GSM389704", "GSM389706", "GSM389708", 
           "GSM389711", "GSM389714", "GSM389716", "GSM389717", 
           "GSM389719", "GSM389721", "GSM389722", "GSM389724", 
           "GSM389726", "GSM389727", "GSM389730", "GSM389731", 
           "GSM389733", "GSM389735")

## Calculate pathway scores and plot heatmap
score_matrix <- calculate_pw_scores(pws_table, exp_mat, cases)

[1] Chen YA, Tripathi LP, Dessailly BH, Nyström-persson J, Ahmad S, Mizuguchi K. Integrated pathway clusters with coherent biological themes for target prioritisation. PLoS ONE. 2014;9(6):e99030. 10.1371/journal.pone.0099030

[2] Ideker T, Ozier O, Schwikowski B, Siegel AF. Discovering regulatory and signalling circuits in molecular interaction networks. Bioinformatics. 2002;18 Suppl 1:S233-40.

[3] Ozisik O, Bakir-Gungor B, Diri B, Sezerman OU. Active Subnetwork GA: A Two Stage Genetic Algorithm Approach to Active Subnetwork Search. Current Bioinformatics. 2017; 12(4):320-8. 10.2174/1574893611666160527100444