View source: R/make.cor.matrix.R
make.cor.matrix | R Documentation |
This function estimates a correlation matrix returning wither the correlation estimates or their p-values
make.cor.matrix(wdata, cor_method = "kendall", minN = 50, var2return = "cor")
wdata |
the metabolite data matrix. samples in row, metabolites in columns |
cor_method |
defaulted to "kendall" this is the correlation method to use in the function cor.test() |
minN |
sefaulted to 50, this is the minimum number of observations that must be available in pairs to perform analysis |
var2return |
sefaulted to "cor", other option is "pvalue" is a the flag indicating which estimate to return from the function. |
a matrix of correlation estimates or p-values
cmat = matrix(1, 4, 4 ) cmat[1,] = c(1, 0.8, 0.6, 0.2) cmat[2,] = c(0.8, 1, 0.7, 0.5) cmat[3,] = c(0.6, 0.7, 1, 0.6) cmat[4,] = c(0.2, 0.5, 0.6,1) ## simulate some correlated data (multivariable random normal) set.seed(1110) ex_data = MASS::mvrnorm(n = 250, mu = c(5, 45, 25, 15), Sigma = cmat ) ## return correlation estimates cor_mat = make.cor.matrix(ex_data, var2return = "cor") ## return p-values cor_mat = make.cor.matrix(ex_data, var2return = "pvalue")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.