This R package provides a fast and efficient method for functional enrichment analysis, optimized for speed and designed for use in interactive applications, such as Shiny apps.
Quick example
To run a Shiny app demonstration of fenr directly from GitHub, enter the following command in your R console:
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("fenr")
Usage
The initial step involves downloading functional term data. fenr supports data downloads from Gene Ontology, Reactome, KEGG, and WikiPathways. Custom ontologies can also be used, provided they are converted into an appropriate format (refer to the prepare_for_enrichment function for more information). The command below downloads functional terms and gene mapping from Gene Ontology (GO) for yeast:
go <- fetch_go(species = "sgd")
This command returns a list with two tibbles containing term information (term_id and term_name) and gene-term mapping (term_id and gene_symbol). We convert this data into an object suitable for fast functional enrichment. exmpl_all is an example of gene background provided by the package, which contains a vector with gene symbols related to all detections in an experiment.
The go_terms object is a data structure containing all mappings in a quickly accessible form. From this point on, you can use go_terms to perform multiple functional enrichments on various gene selections. For example, if exmpl_all is a vector with all background gene symbols and exmpl_sel is a vector with genes of interest (both provided by the package), you can perform functional enrichment analysis using:
N_with: The number of features (genes) associated with this term in the background of all genes.
n_with_sel: The number of features associated with this term in the selection.
n_expect: The expected number of features associated with this term under the null hypothesis (terms are randomly distributed).
enrichment: The ratio of observed to expected.
odds_ratio: The effect size, represented by the odds ratio from the contingency table.
ids: The identifiers of features with the term in the selection.
p_value: The raw p-value from the hypergeometric distribution.
p_adjust: The p-value adjusted for multiple tests using the Benjamini-Hochberg approach.
Interactive Example
A small Shiny app is included in the package to demonstrate the usage of fenr in an interactive environment. All time-consuming data loading and preparation tasks are performed before the app is launched.
yeast_de is the result of differential expression (using edgeR) on a subset of 6+6 replicates from Gierlinski et al. (2015).
The function fetch_terms_for_example uses fetch_* functions from fenr to download and process data from GO, Reactome and KEGG. You can view the step-by-step process by examining the function code on GitHub. The object term_data is a named list of fenr_terms objects, one for each ontology.
After completing the slow tasks, you can start the Shiny app by running:
enrichment_interactive(yeast_de, term_data)
To quickly see how fenr works an example can be loaded directly from GitHub:
Fast functional enrichment
Maintainer: Marek Gierlinski (M.Gierlinski@dundee.ac.uk)
This R package provides a fast and efficient method for functional enrichment analysis, optimized for speed and designed for use in interactive applications, such as Shiny apps.
Quick example
To run a Shiny app demonstration of
fenrdirectly from GitHub, enter the following command in your R console:Installation
fenrcan be installed usingUsage
The initial step involves downloading functional term data.
fenrsupports data downloads from Gene Ontology, Reactome, KEGG, and WikiPathways. Custom ontologies can also be used, provided they are converted into an appropriate format (refer to theprepare_for_enrichmentfunction for more information). The command below downloads functional terms and gene mapping from Gene Ontology (GO) for yeast:This command returns a list with two tibbles containing term information (
term_idandterm_name) and gene-term mapping (term_idandgene_symbol). We convert this data into an object suitable for fast functional enrichment.exmpl_allis an example of gene background provided by the package, which contains a vector with gene symbols related to all detections in an experiment.The
go_termsobject is a data structure containing all mappings in a quickly accessible form. From this point on, you can use go_terms to perform multiple functional enrichments on various gene selections. For example, ifexmpl_allis a vector with all background gene symbols andexmpl_selis a vector with genes of interest (both provided by the package), you can perform functional enrichment analysis using:The result is a tibble:
The columns are as follows
N_with: The number of features (genes) associated with this term in the background of all genes.n_with_sel: The number of features associated with this term in the selection.n_expect: The expected number of features associated with this term under the null hypothesis (terms are randomly distributed).enrichment: The ratio of observed to expected.odds_ratio: The effect size, represented by the odds ratio from the contingency table.ids: The identifiers of features with the term in the selection.p_value: The raw p-value from the hypergeometric distribution.p_adjust: The p-value adjusted for multiple tests using the Benjamini-Hochberg approach.Interactive Example
A small Shiny app is included in the package to demonstrate the usage of
fenrin an interactive environment. All time-consuming data loading and preparation tasks are performed before the app is launched.yeast_deis the result of differential expression (usingedgeR) on a subset of 6+6 replicates from Gierlinski et al. (2015).The function
fetch_terms_for_exampleusesfetch_*functions fromfenrto download and process data from GO, Reactome and KEGG. You can view the step-by-step process by examining the function code on GitHub. The objectterm_datais a named list offenr_termsobjects, one for each ontology.After completing the slow tasks, you can start the Shiny app by running:
To quickly see how
fenrworks an example can be loaded directly from GitHub: