permutation_test: Perform a permutation test on 2 tables

Description Usage Arguments Details Value Examples

View source: R/permutation.R

Description

The goal of this function is to calculate the values of a test performed by FUN after each of sample_count permutations.

Usage

1
permutation_test(table1, table2, sample_size, sample_count, FUN, ...)

Arguments

table1

The first table.

table2

The second table.

sample_size

The number of element to draw for each table.

sample_count

The number of permutations.

FUN

The function to use to compare the 2 table. First two params must be numeric vector and the return must be a single numeric value.

...

Extra param for FUN.

Details

Each round of the permutation test, two new matrices will be randomly sampled from using the combination of the two original tables. The means of each columns will be calculated to produce the vectors that will be sent FUN.

Value

A vector of numeric corresponding to the result of each permutation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
# Get some tables
mg <- get_demo_metagene()
mg$produce_table()
tab <- mg$get_table()
tab <- tab[which(tab$region == "list1"),]
tab1 <- tab[which(tab$design == "align1_rep1"),]
tab2 <- tab[which(tab$design == "align2_rep2"),]

# Perform permutation test
sample_size <- min(nrow(tab1), nrow(tab2))
FUN = function(a, b) { mean(a) - mean(b) } # Dummy function for demo purpose
# A sample_count >= 1000 should be used in a real analysis
permutation_results <- permutation_test(m1, m2, sample_size = sample_size,
                                       sample_count = 10, FUN = FUN)

## End(Not run)

metagene documentation built on Nov. 8, 2020, 5:37 p.m.