MantelCor {evolqg} | R Documentation |
Compare matrices via Mantel Correlation
Description
Calculates correlation matrix correlation and significance via Mantel test.
Usage
MantelCor(cor.x, cor.y, ...)
## Default S3 method:
MantelCor(
cor.x,
cor.y,
permutations = 1000,
...,
landmark.dim = NULL,
withinLandmark = FALSE,
mod = FALSE
)
## S3 method for class 'list'
MantelCor(
cor.x,
cor.y = NULL,
permutations = 1000,
repeat.vector = NULL,
parallel = FALSE,
...
)
## S3 method for class 'mcmc_sample'
MantelCor(cor.x, cor.y, ..., parallel = FALSE)
MatrixCor(cor.x, cor.y, ...)
## Default S3 method:
MatrixCor(cor.x, cor.y, ...)
## S3 method for class 'list'
MatrixCor(
cor.x,
cor.y = NULL,
permutations = 1000,
repeat.vector = NULL,
parallel = FALSE,
...
)
## S3 method for class 'mcmc_sample'
MatrixCor(cor.x, cor.y, ..., parallel = FALSE)
Arguments
cor.x |
Single correlation matrix or list of correlation matrices. If single matrix is supplied, it is compared to cor.y. If list is supplied and no cor.y is supplied, all matrices are compared. If cor.y is supplied, all matrices in list are compared to it. |
cor.y |
First argument is compared to cor.y. Optional if cor.x is a list. |
... |
additional arguments passed to other methods |
permutations |
Number of permutations used in significance calculation. |
landmark.dim |
Used if permutations should be performed maintaining landmark structure in geometric morphometric data. Either 2 for 2d data or 3 for 3d data. Default is NULL for non geometric morphomotric data. |
withinLandmark |
Logical. If TRUE within-landmark correlations are used in the calculation of matrix correlation. Only used if landmark.dim is passed, default is FALSE. |
mod |
Set TRUE to use mantel in testing modularity hypothesis. Should only be used in MantelModTest. |
repeat.vector |
Vector of repeatabilities for correlation correction. |
parallel |
if TRUE computations are done in parallel. Some foreach back-end must be registered, like doParallel or doMC. |
Value
If cor.x and cor.y are passed, returns matrix Pearson correlation coefficient 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.
Note
If the significance is not needed, MatrixCor provides the correlation and skips the permutations, so it is much faster.
Author(s)
Diogo Melo, Guilherme Garcia
References
http://en.wikipedia.org/wiki/Mantel_test
See Also
KrzCor
,RandomSkewers
,mantel
,RandomSkewers
,TestModularity
, MantelModTest
Examples
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(cor.list, repeat.vector = reps)
c4 <- RandomMatrix(10)
MantelCor(cor.list, c4)
## Not run:
#Multiple threads can be used with some foreach backend library, like doMC or doParallel
library(doMC)
registerDoMC(cores = 2)
MantelCor(cor.list, parallel = TRUE)
## End(Not run)