pathfindR is a tool for enrichment analysis via active subnetworks. The package also offers functionalities to cluster the enriched terms and identify representative terms in each cluster, to score the enriched terms per sample and to visualize analysis results.
The functionalities of pathfindR is described in detail in Ulgen E, Ozisik O, Sezerman OU. 2019. pathfindR: An R Package for Comprehensive Identification of Enriched Pathways in Omics Data Through Active Subnetworks. Front. Genet. https://doi.org/10.3389/fgene.2019.00858
The observation that motivated us to develop
pathfindR was that direct enrichment analysis of differential RNA/protein expression or DNA methylation results may not provide the researcher with the full picture. That is to say: enrichment analysis of only a list of significant genes alone may not be informative enough to explain the underlying disease mechanisms. Therefore, we considered leveraging interaction information from a protein-protein interaction network (PIN) to identify distinct active subnetworks and then perform enrichment analyses on these subnetworks.
An active subnetwork can be defined as a group of interconnected genes in a PIN that predominantly consists of significantly altered genes. In other words, active subnetworks define distinct disease-associated sets of interacting genes, whether discovered through the original analysis or discovered because of being in interaction with a significant gene.
The active-subnetwork-oriented enrichment analysis approach of pathfindR can be summarized as follows: Mapping the input genes with the associated p values onto the PIN (after processing the input), active subnetwork search is performed. The resulting active subnetworks are then filtered based on their scores and the number of significant genes they contain. This filtered list of active subnetworks are then used for enrichment analyses, i.e. using the genes in each of the active subnetworks, the significantly enriched terms (pathways/gene sets) are identified. Enriched terms with adjusted p values larger than the given threshold are discarded and the lowest adjusted p value (over all active subnetworks) for each term is kept. This process of
active subnetwork search + enrichment analyses is repeated for a selected number of iterations, performed in parallel. Over all iterations, the lowest and the highest adjusted-p values, as well as number of occurrences over all iterations are reported for each significantly enriched term in the resulting data frame. An HTML report containing the results is also provided containing links to the visualizations of the enriched terms. This active-subnetwork-oriented enrichment approach is demonstrated in the section Active-subnetwork-oriented Enrichment Analysis of this vignette.
The enrichment analysis usually yields a great number of enriched terms whose biological functions are related. Therefore, we implemented two clustering approaches using a pairwise distance matrix based on the kappa statistics between the enriched terms (as proposed by Huang et al. 1). Based on this distance metric, the user can perform either hierarchical (default) or fuzzy clustering of the enriched terms. Details of clustering and partitioning of enriched terms are presented in the Clustering Enriched Terms section of this vignette.
Other functionalities of pathfindR including:
For convenience, we provide the wrapper function
run_pathfindR() to be used for the active-subnetwork-oriented enrichment analysis. The input for this function must be a data frame consisting of the columns containing:
Change Values (optional) and
p values. The example data frame used in this vignette (
input_df) is the dataset containing the differentially-expressed genes for the GEO dataset GSE15573 comparing 18 rheumatoid arthritis (RA) patients versus 15 healthy subjects.
The first 6 rows of the example input data frame are displayed below:
For a detailed step-by-step explanation and an unwrapped demonstration of the active-subnetwork-oriented enrichment analysis, see the vignette Step-by-Step Execution of the pathfindR Enrichment Workflow
Executing the workflow is straightforward (but does typically take several minutes):
This subsection demonstrates some (selected) useful arguments of
run_pathfindR(). For a full list of arguments, see
?run_pathfindR or visit our GitHub wiki.
run_pathfindR() uses the input genes with p-values < 0.05. To change this threshold, use
run_pathfindR() creates a directory named
"pathfindR_Results" under the current working directory for writing the output files. To change the output directory, use
"this_is_my_output_directory" under the current working directory.
In essence, this argument is treated as a path so it can be used to create the output directory anywhere. For example, to create the directory
"~/Desktop" and run the analysis there, you may run:
Note: If the output directory (e.g.
"my_dir") already exists,
run_pathfindR()creates and works under
"my_dir(1)". If that exists also exists, it creates
"my_dir(2)"and so on. This was intentionally implemented so that any previous pathfindR results are not overwritten.
The active-subnetwork-oriented enrichment analyses can be performed on any gene sets (biological pathways, gene ontology terms, transcription factor target genes, miRNA target genes etc.). The available gene sets in pathfindR are “KEGG”, “Reactome”, “BioCarta”, “GO-All”, “GO-BP”, “GO-CC” and “GO-MF” (all for Homo sapiens). For changing the default gene sets for enrichment analysis (hsa KEGG pathways), use the argument
run_pathfindR() filters the gene sets by including only the terms containing at least 10 and at most 300 genes. To change the default behavior, you may change
Note that increasing the number of terms for enrichment analysis may result in significantly longer run time.
If the user prefers to use another gene set source, the
gene_sets argument should be set to
"Custom" and the custom gene sets (list) and the custom gene set descriptions (named vector) should be supplied via the arguments
custom_descriptions, respectively. See
?fetch_gene_set for more details and Analysis with Custom Gene Sets for a simple demonstration.
For details on obtaining organism-specific Gene Sets and PIN data, see the vignette Obtaining PIN and Gene Sets Data.
run_pathfindR() adjusts the enrichment p values via the “bonferroni” method and filters the enriched terms by adjusted-p value < 0.05. To change this adjustment method and the threshold, set
For the active subnetwork search process, a protein-protein interaction network (PIN) is used.
run_pathfindR() maps the input genes onto this PIN and identifies active subnetworks which are then be used for enrichment analyses. To change the default PIN (“Biogrid”), use the
pin_name_path argument can be one of “Biogrid”, “STRING”, “GeneMania”, “IntAct”, “KEGG”, “mmu_STRING” or it can be the path to a custom PIN file provided by the user.
NOTE: the PIN is also used for generating the background genes (in this case, all unique genes in the PIN) during hypergeometric-distribution-based tests in enrichment analyses. Therefore, a large PIN will generally result in better results.
Currently, there are three algorithms implemented in pathfindR for active subnetwork search: Greedy Algorithm (default, based on Ideker et al. 2), Simulated Annealing Algorithm (based on Ideker et al. 3) and Genetic Algorithm (based on Ozisik et al. 4). For a detailed discussion on which algorithm to use see this wiki entry
Because the active subnetwork search algorithms are stochastic,
run_pathfindR() may be set to iterate the active subnetwork identification and enrichment steps multiple times (by default 1 time). To change this number, set
run_pathfindR() uses a parallel loop (using the package
foreach) for performing these iterations in parallel. By default, the number of processes to be used is determined automatically. To override, change
run_pathfindR() returns a data frame of enriched terms. Columns are:
list_active_snw_genes, default is
change value> 0, if the
change columnwas provided) in the input involved in the given term’s gene set, comma-separated. If change column was not provided, all affected input genes are listed here.
change value< 0, if the
change columnwas provided) in the input involved in the given term’s gene set, comma-separated
The first 2 rows of the output data frame of the example analysis on the rheumatoid arthritis gene-level differential expression input data (
RA_input) is shown below:
|hsa04714||Thermogenesis||2.503010||1||0.0322581||1e-07||1e-07||NDUFA1, NDUFB3, UQCRQ, COX6A1, COX7A2, COX7C||ADCY7, CREB1, KDM1A, SMARCA4, ACTG1, ACTB, ARID1A, MTOR|
|hsa04130||SNARE interactions in vesicular transport||4.529257||1||0.0241935||1e-07||1e-07||STX6||STX2, BET1L, SNAP23|
run_pathfindR() also produces a graphical summary of enrichment results for top 10 enriched terms, which can also be later produced by
You may also disable plotting this chart by setting
plot_enrichment_chart=FALSE and later produce this plot via the function
The function also creates an HTML report
results.html that is saved in the output directory. This report contains links to two other HTML files:
This document contains the table of the active subnetwork-oriented enrichment results (same as the returned data frame). By default, each enriched term description is linked to the visualization of the term, with the gene nodes colored according to their change values. If you choose not to create the visualization files, set
visualize_enriched_terms = FALSE.
This document contains the table of converted gene symbols. Columns are:
During input processing, gene symbols that are not in the PIN are identified and excluded. For human genes, if aliases of these missing gene symbols are found in the PIN, these symbols are converted to the corresponding aliases (controlled by the argument
convert2alias). This step is performed to best map the input data onto the PIN.
The document contains a second table of genes for which no interactions were identified after checking for alias symbols (so these could not be used during the analysis).
The wrapper function
cluster_enriched_terms() can be used to perform clustering of enriched terms and partitioning the terms into biologically-relevant groups. Clustering can be performed either via
fuzzy method using the pairwise kappa statistics (a chance-corrected measure of co-occurrence between two sets of categorized data) matrix between all enriched terms.
cluster_enriched_terms() performs hierarchical clustering of the terms (using \(1 - \kappa\) as the distance metric). Iterating over \(2,3,...n\) clusters (where \(n\) is the number of terms),
cluster_enriched_terms() determines the optimal number of clusters by maximizing the average silhouette width, partitions the data into this optimal number of clusters and returns a data frame with cluster assignments.
|1||hsa04714||Thermogenesis||2.503010||1||0.0322581||1e-07||1e-07||NDUFA1, NDUFB3, UQCRQ, COX6A1, COX7A2, COX7C||ADCY7, CREB1, KDM1A, SMARCA4, ACTG1, ACTB, ARID1A, MTOR||1||Representative|
|3||hsa00190||Oxidative phosphorylation||2.976083||1||0.0241935||1e-07||1e-07||NDUFA1, NDUFB3, UQCRQ, COX6A1, COX7A2, COX7C, ATP6V1D, ATP6V0E1||ATP6V0E2||1||Member|
|1||hsa04714||Thermogenesis||2.503010||1||0.0322581||0.0000001||0.0000001||NDUFA1, NDUFB3, UQCRQ, COX6A1, COX7A2, COX7C||ADCY7, CREB1, KDM1A, SMARCA4, ACTG1, ACTB, ARID1A, MTOR||1||Representative|
|2||hsa04130||SNARE interactions in vesicular transport||4.529257||1||0.0241935||0.0000001||0.0000001||STX6||STX2, BET1L, SNAP23||2||Representative|
|4||hsa04064||NF-kappa B signaling pathway||2.930696||1||0.0564516||0.0000001||0.0000001||LY96||PRKCQ, CARD11, TICAM1, IKBKB, PARP1, UBE2I, CSNK2A2||3||Representative|
|10||hsa03013||RNA transport||2.576991||1||0.0241935||0.0000034||0.0000034||NUP214||NUP62, NUP93, RANGAP1, UBE2I, SUMO3, GEMIN4, EIF2S3, EIF2B1, EIF4A3, RNPS1, SRRM1||4||Representative|
|11||hsa04722||Neurotrophin signaling pathway||2.849978||1||0.0564516||0.0000066||0.0000066||SH2B3, CRKL, FASLG, CALM3, CALM1, ABL1, MAGED1, IRAK2, IKBKB||5||Representative|
|12||hsa03040||Spliceosome||3.607788||1||0.0645161||0.0000077||0.0000077||SF3B6, LSM3, BUD31||SNRPB, SF3B2, U2AF2, PUF60, SNU13, DDX23, EIF4A3, HNRNPA1, PCBP1, SRSF8, SRSF5||6||Representative|
|17||hsa05230||Central carbon metabolism in cancer||2.166167||1||0.0241935||0.0000312||0.0000312||HK3||PDHA1, PDHB, MTOR||7||Representative|
|20||hsa05130||Pathogenic Escherichia coli infection||2.372468||1||0.0483871||0.0001086||0.0001086||TLR5, GAPDH, CLDN9||ARF1, ACTG1, ACTB, SLC9A3R1, TUBB, ABL1, ITGB1, IKBKB, FASLG||8||Representative|
|26||hsa04110||Cell cycle||1.506709||1||0.0241935||0.0002381||0.0002381||RBL2, ABL1, HDAC1, CDKN1C, ANAPC1||9||Representative|
|30||hsa03010||Ribosome||1.720820||1||0.0080645||0.0007479||0.0007479||MRPS18C, RPS24, MRPL33, RPL26, RPL31, RPL39||RPLP2||10||Representative|
|38||hsa03420||Nucleotide excision repair||4.061562||1||0.0080645||0.0013233||0.0013233||GTF2H5, POLE4||XPC, RPA1, POLD2||12||Representative|
|51||hsa05202||Transcriptional misregulation in cancer||2.185168||1||0.0161290||0.0035608||0.0035608||MMP9, DDIT3||HDAC1, SIN3A, BCL11B, SLC45A3, EWSR1, IL2RB, TAF15, ASPSCR1||13||Representative|
|79||hsa04120||Ubiquitin mediated proteolysis||1.636483||1||0.0161290||0.0223077||0.0223077||TRIP12||UBE2G1, UBE2I, HERC1, PIAS3, ANAPC1||14||Representative|
|92||hsa04650||Natural killer cell mediated cytotoxicity||0.593117||1||0.0080645||0.0406276||0.0406276||LCP2, FASLG||15||Representative|
After clustering, you may again plot the summary enrichment chart and display the enriched terms by clusters:
For details, see
term_gene_heatmap() can be used to visualize the heatmap of genes that are involved in the enriched terms. This heatmap allows visual identification of the input genes involved in the enriched terms, as well as the common or distinct genes between different terms. If the input data frame (same as in
run_pathfindR()) is supplied, the tile colors indicate the change values.
See the vignette Visualization of pathfindR Enrichment Results for more details.
The visualization function
term_gene_graph() (adapted from the “Gene-Concept network visualization” by the R package
enrichplot) can be utilized to visualize which genes are involved in the enriched terms. The function creates a term-gene graph which shows the connections between genes and biological terms (enriched pathways or gene sets). This allows for the investigation of multiple terms to which significant genes are related. This graph also enables visual determination of the degree of overlap between the enriched terms by identifying shared and/or distinct significant genes.
See the vignette Visualization of pathfindR Enrichment Results for more details.
UpSet plots are plots of the intersections of sets as a matrix. This function creates a ggplot object of an UpSet plot where the x-axis is the UpSet plot of intersections of enriched terms. By default (i.e.,
method = "heatmap"), the main plot is a heatmap of genes at the corresponding intersections, colored by up/down regulation (if
genes_df is provided, colored by change values). If
method = "barplot", the main plot is bar plots of the number of genes at the corresponding intersections. Finally, if
method = "boxplot" and
genes_df is provided, then the main plot displays the boxplots of change values of the genes at the corresponding intersections.
See the vignette Visualization of pathfindR Enrichment Results for more details.
score_terms() can be used to calculate the agglomerated z score of each enriched term per sample. This allows the user to individually examine the scores and infer how a term is overall altered (activated or repressed) in a given sample or a group of samples.
## 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 scores for representative terms ## and plot heat map using term descriptions score_matrix <- score_terms(enrichment_table = RA_clustered[RA_clustered$Status == "Representative", ], exp_mat = RA_exp_mat, cases = cases, use_description = TRUE, # default FALSE label_samples = FALSE, # default = TRUE case_title = "RA", # default = "Case" control_title = "Healthy", # default = "Control" low = "#f7797d", # default = "green" mid = "#fffde4", # default = "black" high = "#1f4037") # default = "red"