knitr::opts_chunk$set(warning = FALSE, message = FALSE, fig.width = 7, fig.height = 5, cache = T) library(tidyverse) library(useful) library(taigr) library(cdsrgsea) library(cdsrplots)
cdsrgsea contains lightweight wrappers around useful gene set enrichment functions
library(devtools) devtools::install_github("broadinstitute/cdsr_gsea")
The package can then be loaded by calling
library(cdsrgsea)
gene_sets <- cdsrgsea::load_gene_sets()
Loads a list of gene sets in term2gene format from taiga. These gene sets are drawn from the Enrichr and MSigDB libraries.
gene_sets <- cdsrgsea::load_gene_sets()
gene_sets %>% names() %>% head()
gene_sets$Hallmark %>% head()
run_hyper
runs overrepresentation analysis based on the hypergeometric distribution. The function excepts either a small list of significant genes or a table with gene level stats as input. If a table is provided the gene_var
, rank_var
, and n_genes
parameters are used to define a small list of significant genes.
As an example we will load the results of a differential expression anlyses comparing Nutlin treated cells to DMSO treated cells.
nutlin <- read_csv("./nutlin.csv") nutlin %>% head()
genes <- nutlin %>% arrange(-logFC) %>% head(100) %>% .[["Gene"]] genes %>% head()
hyper_res <- cdsrgsea::run_hyper(genes,gene_sets$Hallmark,universe = nutlin$Gene) hyper_res
hyper_res <- cdsrgsea::run_hyper(nutlin,gene_sets$Hallmark,gene_var = "Gene", rank_var = "logFC",dir = "pos",n_genes = 100) hyper_res
run_gsea
runs gene set enrichment analysis using the fgseaMultilevel
method from the fgsea
package. The function excepts a table with gene level stats. The dir
parameter indicates whether to return positive gene sets, negative gene sets, or both.
gsea_res <- cdsrgsea::run_gsea(nutlin,gene_sets$Hallmark,gene_var = "Gene", rank_var = "logFC",dir = "both") gsea_res
This package is designed to be used with the plotting functions in cdsr_plots
make_gsea_bar
cdsrplots::make_gsea_bar(hyper_res,dir = "pos")
make_gsea_dot
cdsrplots::make_gsea_dot(gsea_res,dir = "both")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.