pair.permanova: Conduct pairwise PerMANOVAs.

Description Usage Arguments Details Value Author(s) Examples

View source: R/pair.permanova.R

Description

This function conducts PerMANOVAs for all pairs of levels for a single factor.

Usage

1
pair.permanova(x, f, nits = 999)

Arguments

x

Community matrix.

f

Factor to be used.

nits

Number of iterations to be used for each PerMANOVA.

Details

This is a high level function built on the adonis function in the vegan package.

Value

The function returns a matrix of p-values for the comparisons.

Author(s)

Matthew K. Lau

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x, f, nits = 999) 
{
    require(vegan)
    f. <- sort(unique(f))
    out <- list()
    p.out <- array(NA, dim = c(length(f.), length(f.)))
    rownames(p.out) <- colnames(p.out) <- f.
    h <- 1
    for (i in 1:length(f.)) {
        k <- i + 1
        for (j in k:length(f.)) {
            if (i != j & j <= length(f.)) {
                print(paste(f.[i], f.[j], sep = " vs "))
                y <- x[f == f.[i] | f == f.[j], ]
                yf <- factor(f[f == f.[i] | f == f.[j]])
                out[[h]] <- as.matrix(adonis(y ~ yf)$aov.tab, 
                  permutations = nits)
                p.out[i, j] <- out[[h]][1, dim(out[[h]])[2]]
                names(out)[h] <- paste(f.[i], f.[j], sep = " vs ")
                h <- h + 1
            }
            else {
            }
        }
    }
    out <- list(f.tables = out, p.mat = p.out)
    return(out)
  }

ECGen/ComGenR documentation built on July 23, 2021, 11:44 p.m.