knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

enrichr.db

The goal of enrichr.db is to provide the data from Enrichr in a format that makes it easy to access the gene sets programmatically from R.

The current Enrichr release included is from 2019-01-23.

Installation

You can install the released version of enrichr.db from Github with:

if (!requireNamespace("remotes", quietly = TRUE))
  install.packages("remotes")
remotes::install_url("https://github.com/labsyspharm/enrichr.db/releases/download/v0.1/enrichr.db_0.1.tar.gz")

Example

This is a basic example which shows how to query the gene set database and use the gene sets for enrichment analysis using fgsea.

Querying the database

library(tidyverse)
library(enrichr.db)

# Finding all libraries that have something to do with drug treatments
drug_gene_sets <- enrichr_terms %>%
  filter(grepl("drug", library, ignore.case = TRUE))

This gives a data frame of gene set libraries. The gene sets are in the data column of the data frame and are implemented as lists. Each list element is a gene set and contains a vector of HGCN gene symbols.

knitr::kable(drug_gene_sets %>% mutate(data = paste0("<", map_int(data, length), " gene sets>")))

We can have a look a the first five gene sets in the Drug_Perturbations_from_GEO_2014 library. We can print the first 10 genes of each gene set.

print(
  # Drug_Perturbations_from_GEO_2014 is the first library
  drug_gene_sets$data[[1]] %>%
    head(n = 5) %>%
    map(head, n = 10)
)

Enrichment analysis

We can use the gene sets in the data column directly for gene set enrichment analysis using fgsea. Again, we're using the first library that we found (Drug_Perturbations_from_GEO_2014).

library(fgsea)

# Making random fake expression results
genes <- Reduce(union, drug_gene_sets$data[[1]])
expression_res <- setNames(
  rnorm(length(genes), 0, 0.5),
  genes
)

enrichment_res <- fgseaMultilevel(
  pathways = drug_gene_sets$data[[1]],
  stats = expression_res,
  sampleSize = 101,
  minSize = 15
)
knitr::kable(
  enrichment_res %>%
    arrange(padj) %>%
    select(-leadingEdge) %>%
    head()
)

Funding

We gratefully acknowledge support by NIH Grant 1U54CA225088-01: Systems Pharmacology of Therapeutic and Adverse Responses to Immune Checkpoint and Small Molecule Drugs.



clemenshug/enrichr.db documentation built on July 23, 2019, 8:08 a.m.