hyperg: Hypergeometric (gene set enrichment) tests on character...

Description Usage Arguments Value Author(s) See Also Examples

Description

This function performs a hypergeometric test for over- or under-representation of significant ‘genes’ amongst those assayed in a universe of genes. It provides an interface based on character vectors of identifying member of gene sets and the gene universe.

Usage

1
2
hyperg(assayed, significant, universe,
    representation = c("over", "under"), ...)

Arguments

assayed

A vector of assayed genes (or other identifiers). assayed may be a character vector (defining a single gene set) or list of character vectors (defining a collection of gene sets).

significant

A vector of assayed genes that were differentially expressed. If assayed is a character vector, then significant must also be a character vector; likewise when assayed is a list.

universe

A character vector defining the universe of genes.

representation

Either “over” or “under”, to indicate testing for over- or under-representation, respectively, of differentially expressed genes.

...

Additional arguments, unused.

Value

When invoked with a character vector of assayed genes, a named numeric vector providing the input values, P-value, odds ratio, and expected number of significantly expressed genes.

When invoked with a list of character vectors of assayed genes, a data frame with columns of input values, P-value, odds ratio, and expected number of significantly expressed genes.

Author(s)

Martin Morgan mtmorgan@fhcrc.org with contributions from Paul Shannon.

See Also

hyperGTest for convenience functions using Bioconductor annotation resources such as GO.db.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
set.seed(123)

## artifical sets -- affy probes grouped by protein family
library(hgu95av2.db)
map <- select(hgu95av2.db, keys(hgu95av2.db), "PFAM")
sets <- Filter(function(x) length(x) >= 10, split(map$PROBEID, map$PFAM))

universe <- unlist(sets, use.names=FALSE)
siggenes <- sample(universe, length(universe) / 20)  ## simulate
sigsets <- Map(function(x, y) x[x %in% y], sets, MoreArgs=list(y=siggenes))

result <- hyperg(sets, sigsets, universe)
head(result)

Example output

Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: AnnotationDbi
Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: IRanges
Loading required package: S4Vectors

Attaching package: 'S4Vectors'

The following object is masked from 'package:base':

    expand.grid

Loading required package: Matrix

Attaching package: 'Matrix'

The following object is masked from 'package:S4Vectors':

    expand

Loading required package: org.Hs.eg.db


'select()' returned 1:many mapping between keys and columns
        assayed significant universe representation            p     odds
PF00001     211           9    11806           over   0.01357584 2.512915
PF00002      42           5    11806           over 3.439682e-07 42.83053
PF00003      19           1    11806           over   0.03016146 36.32407
PF00004      41           2    11806           over  0.008857134  15.4188
PF00005      61           2    11806           over   0.03954921 6.714163
PF00007      13           1    11806           over   0.01422775  81.8125
          expected
PF00001   3.771049
PF00002  0.1494156
PF00003 0.03057767
PF00004  0.1423852
PF00005  0.3151787
PF00007 0.01431476

Category documentation built on Nov. 8, 2020, 10:58 p.m.