DA.per: Permutation test of user-defined test statistic

View source: R/DA.per.R

DA.perR Documentation

Permutation test of user-defined test statistic

Description

Test significance of multiple features with a binary predictor with a permutation scheme.

Usage

DA.per(
  data,
  predictor,
  paired = NULL,
  relative = TRUE,
  p.adj = "fdr",
  testStat = function(case, control) {     log2((mean(case) + 1)/(mean(control) + 1)) },
  testStat.pair = function(case, control) {     log2(mean((case + 1)/(control + 1))) },
  noOfIterations = 10000,
  margin = 50
)

Arguments

data

Either a matrix with counts/abundances, OR a phyloseq object. If a matrix/data.frame is provided rows should be taxa/genes/proteins and columns samples

predictor

The predictor of interest. Factor, OR if data is a phyloseq object the name of the variable in sample_data(data) in quotation

paired

For paired/blocked experimental designs. Either a Factor with Subject/Block ID for running paired/blocked analysis, OR if data is a phyloseq object the name of the variable in sample_data(data) in quotation

relative

Logical. Should data be normalized to relative abundances. Default TRUE

p.adj

Character. P-value adjustment. Default "fdr". See p.adjust for details

testStat

Function. Function for the test statistic. Should take two vectors as arguments. Default is a log fold change: log2((mean(case abundances)+1)/(mean(control abundances)+1))

testStat.pair

Function. Function for test statistic for paired analysis. Should take two vectors as arguments. Default is a log fold change: log2(mean((case abundances+1)/(control abundances+1)))

noOfIterations

Integer. Iterations for permutations. Default 10000

margin

Numeric. Margin for when to stop iterations if p-value is high and unlikely to become low

Details

Modified version of the one from: https://microbiomejournal.biomedcentral.com/articles/10.1186/s40168-016-0208-8. P-values are now two-sided, and test statistic is a simple log fold change

A paired permutation test is implemented specifically for this package. The test is similar to the original, but with a different test statistic and permutation scheme. The permutations are constrained in the paired version such that the predictor is only permuted within each level of the paired argument (e.g. subjects). The test statistic first finds the log-ratio between the two predictor levels (e.g. case and control) for each level of the paired argument and the final statistic is the mean of these log-ratios.

Value

A data.frame with with results.

Examples

# Creating random count_table and predictor
set.seed(4)
mat <- matrix(rnbinom(1000, size = 0.1, mu = 500), nrow = 100, ncol = 10)
rownames(mat) <- 1:100
pred <- c(rep("Control", 5), rep("Treatment", 5))

# Running permutation test on each feature
res <- DA.per(data = mat, predictor = pred)

Russel88/DAtest documentation built on March 24, 2022, 3:50 p.m.