fisherTests {bsseq} | R Documentation

## Compute Fisher-tests for a BSseq object

### Description

A function to compute Fisher-tests for an object of class `BSseq`.

### Usage

    fisherTests(BSseq, group1, group2, lookup = NULL,
      returnLookup = TRUE, mc.cores = 1, verbose = TRUE)

### Arguments

`BSseq` | An object of class `BSseq`.
`group1` | A vector of sample names or indexes for the ‘treatment’ group.
`group2` | A vector of sample names or indexes for the ‘control’ group.
`lookup` | A ‘lookup’ object, see details.
`returnLookup` | Should a ‘lookup’ object be returned, see details.
`mc.cores` | The number of cores used. Note that setting `mc.cores` to a value greater than 1 is not supported on MS Windows, see the help page for `mclapply`.
`verbose` | Should the function be verbose.

### Details

This function computes row-wise Fisher's exact tests. It uses an internal lookup table so rows which forms equivalent 2x2 tables are group together and only a single test is computed. If `returnLookup` is `TRUE` the return object contains the lookup table which may be feed to another call to the function using the `lookup` argument.

If `group1`, `group2` designates more than 1 sample, the samples are added together before testing.

This function can use multiple cores on the same computer.

This test cannot model biological variability.

### Value

if `returnLookup` is `TRUE`, a list with components `results` and `lookup`, otherwise just the `results` component. The `results` (component) is a matrix with the same number of rows as the `BSseq` argument and 2 columns `p.value` (the unadjusted p-values) and `log2OR` (log2 transformation of the odds ratio).

### Author(s)

Kasper Daniel Hansen khansen@jhsph.edu

### See Also

fisher.test for information about Fisher's test. mclapply for the `mc.cores` argument.

### Examples

    M <- matrix(1:9, 3,3)
    colnames(M) <- c("A1", "A2", "A3")
    BStest <- BSseq(pos = 1:3, chr = c("chr1", "chr2", "chr1"),
                    M = M, Cov = M + 2)
    results <- fisherTests(BStest, group1 = "A1", group2 = "A2",
                           returnLookup = TRUE)
    results

    #-------------------------------------------------------------------------------
    # An example using a HDF5Array-backed BSseq object
    #
    library(HDF5Array)
    # See ?SummarizedExperiment::saveHDF5SummarizedExperiment for details
    hdf5_BStest <- saveHDF5SummarizedExperiment(x = BStest,
                                                dir = tempfile())
    results <- fisherTests(hdf5_BStest,
                           group1 = "A1",
                           group2 = "A2",
                           returnLookup = TRUE)
    results

[Package bsseq version 1.18.0 Index]