Git Product home page Git Product logo

fgsea's Introduction

Travis-CI Build Status AppVeyor Build Status codecov

fgsea

An R-package for fast preranked gene set enrichment analysis (GSEA). The package implements a special algorithm to calculate the empirical enrichment score null distributions simultaneously for all the gene set sizes, which allows up to several hundred times faster execution time compared to original Broad implementation. See the preprint for algorithmic details.

Full vignette can be found here: http://bioconductor.org/packages/devel/bioc/vignettes/fgsea/inst/doc/fgsea-tutorial.html

Installation

library(devtools)
install_github("ctlab/fgsea")

Quick run

Loading libraries

library(data.table)
library(fgsea)
library(ggplot2)

Loading example pathways and gene-level statistics:

data(examplePathways)
data(exampleRanks)

Running fgsea (should take about 10 seconds):

fgseaRes <- fgsea(pathways = examplePathways, 
                  stats    = exampleRanks,
                  minSize  = 15,
                  maxSize  = 500)

The head of resulting table sorted by p-value:

pathway                                 pval   padj   log2err  ES      NES     size
5990979_Cell_Cycle,_Mitotic             1e-10  4e-09  NA       0.5595  2.7437  317
5990980_Cell_Cycle                      1e-10  4e-09  NA       0.5388  2.6876  369
5990981_DNA_Replication                 1e-10  4e-09  NA       0.6440  2.6390  82
5990987_Synthesis_of_DNA                1e-10  4e-09  NA       0.6479  2.6290  78
5990988_S_Phase                         1e-10  4e-09  NA       0.6013  2.5069  98
5990990_G1_S_Transition                 1e-10  4e-09  NA       0.6233  2.5625  84
5990991_Mitotic_G1-G1_S_phases          1e-10  4e-09  NA       0.6285  2.6256  101
5991209_RHO_GTPase_Effectors            1e-10  4e-09  NA       0.5249  2.3712  157
5991454_M_Phase                         1e-10  4e-09  NA       0.5576  2.5491  173
5991502_Mitotic_Metaphase_and_Anaphase  1e-10  4e-09  NA       0.6053  2.6331  123

As you can see fgsea has a default lower bound eps=1e-10 for estimating P-values. If you need to estimate P-value more accurately, you can set the eps argument to zero in the fgsea function.

fgseaRes <- fgsea(pathways = examplePathways, 
                  stats    = exampleRanks,
                  eps      = 0.0,
                  minSize  = 15,
                  maxSize  = 500)

head(fgseaRes[order(pval), ])
pathway                                          pval      padj      log2err  ES      NES     size
5990979_Cell_Cycle,_Mitotic                      4.44e-26  1.70e-23  1.3267   0.5595  2.7414  317
5990980_Cell_Cycle                               5.80e-26  1.70e-23  1.3189   0.5388  2.6747  369
5991851_Mitotic_Prometaphase                     8.50e-19  1.66e-16  1.1239   0.7253  2.9674  82
5992217_Resolution_of_Sister_Chromatid_Cohesion  1.50e-17  2.19e-15  1.0769   0.7348  2.9482  74
5991454_M_Phase                                  1.10e-14  1.29e-12  0.9865   0.5576  2.5436  173
5991599_Separation_of_Sister_Chromatids          3.01e-14  2.94e-12  0.9653   0.6165  2.6630  116

One can make an enrichment plot for a pathway:

plotEnrichment(examplePathways[["5991130_Programmed_Cell_Death"]],
               exampleRanks) + labs(title="Programmed Cell Death")

enrichment.png

Or make a table plot for a bunch of selected pathways:

topPathwaysUp <- fgseaRes[ES > 0][head(order(pval), n=10), pathway]
topPathwaysDown <- fgseaRes[ES < 0][head(order(pval), n=10), pathway]
topPathways <- c(topPathwaysUp, rev(topPathwaysDown))
plotGseaTable(examplePathways[topPathways], exampleRanks, fgseaRes, 
              gseaParam=0.5)

fgsea's People

Contributors

assaron avatar vdsukhov avatar pinguinson avatar nturaga avatar toledoem avatar hpages avatar huerqiang avatar vobencha avatar chrismiddleton avatar kant avatar llrs avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.