Learn R Programming

evolqg (version 0.1-7)

MantelCor: Compare matrices via Mantel Correlation

Description

Calculates correlation matrix correlation and significance via Mantel test.

Usage

MantelCor(cor.x, cor.y, ...)

## S3 method for class 'default': MantelCor(cor.x, cor.y, permutations = 1000, mod = FALSE, ICV = FALSE, ...)

## S3 method for class 'list': MantelCor(cor.x, cor.y = NULL, permutations = 1000, repeat.vector = NULL, mod = FALSE, ICV = FALSE, parallel = FALSE, ...)

MatrixCor(cor.x, cor.y, ...)

## S3 method for class 'default': MatrixCor(cor.x, cor.y, ...)

## S3 method for class 'list': MatrixCor(cor.x, cor.y = NULL, permutations = 1000, repeat.vector = NULL, mod = FALSE, parallel = FALSE, ...)

Arguments

cor.x
Single correlation matrix or list of correlation matrices.

If single matrix is suplied, it is compared to cor.y.

If list is suplied and no cor.y is suplied, all matrices are compared.

If cor.y is suplied, all matrices in list are compared to it.

cor.y
First argument is compared to cor.y. Optional if cor.x is a list.
...
aditional arguments passed to other methods
permutations
Number of permutations used in significance calculation.
mod
Set TRUE to use mantel in testing modularity hypothesis. Will return AVG+, AVG- and AVG Ratio based on binary hipotesis matrix.
ICV
Indicates if modularity hypothesis test should use AVG Index instead of AVG Ratio. Ignored if mod is FALSE.
repeat.vector
Vector of repeatabilities for correlation correction.
parallel
if TRUE computations are done in parallel. Some foreach backend must be registered, like doParallel or doMC.

Value

  • If cor.x and cor.y are passed, returns matrix pearson correlation and significance via Mantel permutations.

    If cor.x is a list of matrices and cor.y is passed, same as above, but for all matrices in cor.x.

    If only cor.x is passed, a matrix of MantelCor average values and probabilities of all comparisons. If repeat.vector is passed, comparison matrix is corrected above diagonal and repeatabilities returned in diagonal.

References

http://en.wikipedia.org/wiki/Mantel_test

See Also

KrzCor,RandomSkewers,mantel,RandomSkewers,TestModularity

Examples

Run this code
c1 <- RandomMatrix(10, 1, 1, 10)
c2 <- RandomMatrix(10, 1, 1, 10)
c3 <- RandomMatrix(10, 1, 1, 10)
MantelCor(cov2cor(c1), cov2cor(c2))

cov.list <- list(c1, c2, c3)
cor.list <- llply(list(c1, c2, c3), cov2cor)

MantelCor(cor.list)

# For repeatabilities we can use MatrixCor, which skips the significance calculation
reps <- unlist(lapply(cov.list, MonteCarloRep, 10, MatrixCor, correlation = TRUE))
MantelCor(llply(cor.list, repeat.vector = reps))

c4 <- RandomMatrix(10)
MantelCor(cor.list, c4)

#Multiple threads can be used with some foreach backend library, like doMC or doParallel
#library(doParallel)
##Windows:
#cl <- makeCluster(2)
#registerDoParallel(cl)
##Mac and Linux:
#registerDoParallel(cores = 2)
#MantelCor(cor.list, parallel = TRUE)

Run the code above in your browser using DataLab