RVenn (version 1.1.0)

# enrichment_test: Perform an enrichment test.

## Description

Calculate the p-value of occurrence of an overlap between two sets by chance.

## Usage

```# S4 method for Venn
enrichment_test(venn, set1, set2, univ = "all",
n = 10000, seed = 42)```

## Arguments

venn

(Required) A `Venn` object.

set1

(Required) The name or the index of the set of interest.

set2

(Required) The name or the index of the set to be checked whether enriched in `set1`.

univ

(Optional) Population size. Default is "all", implying the union of all the sets in the `Venn` object will be used. Another set as the whole population can be assigned as well.

n

(Optional) Number of randomly generated sets. Default is 10,000 and minimum is 1,000.

seed

(Optional) An integer passed to set.seed function. It is used to fix a seed for reproducibly random number generation. Default is 42.

## Value

Returns a list containing the probability (Significance) of occurrence of an overlap between two sets by chance and the number of occurrences (Overlap_Counts) in randomly generated sets.

## Details

This type of analysis can also be performed by hypergeometric test or Fisher's exact test. Here, the approach is similar to that described in (Austin et al., 2016). Briefly, the test is based on randomly generation of sets with equal size to `set1` from the background (universal) set. After creating n (default is 10,000) random sets, the overlap between these and `set2` is calculated to make a null distribution. When this distribution is true, the probability of seeing an overlap at least as extreme as what was observed (overlap between `set1` and `set2`) will be returned as the p-value.

## Examples

Run this code
``````# NOT RUN {
set1 = c(1:20, letters[1:10])
set2 = letters[-26]
univ = unique(c(set1, set2, 21:200))
venn = Venn(list(set1, set2, univ))
e = enrichment_test(venn, 1, 2)
e\$Significance
# }
``````

Run the code above in your browser using DataCamp Workspace