Learn R Programming

coRNAi (version 1.22.0)

cortestmatrices: Function to extract correlations and corresponding p-values from interaction matrix.

Description

This is a wrapper function for cor.test, given a matrix of interaction values, correlations and corresponding p-values for the genewise interaction profiles are calculated.

Usage

cortestmatrices(mat, method = c("pearson", "kendall", "spearman"))

Arguments

mat
mat interaction matrix
method
character deciding which correlation method should be used

Value

List of two matrices
cor.matrix
matrix with correlations
p.matrix
matrix with p-values

See Also

cor.test

Examples

Run this code
## simulate data with 2 genes with similar profiles

mat = matrix(rnorm(100*100,0,1),100,100)
pr = sample(2:10,100,replace=TRUE)
mat[1:2,] = mat[1:2,] + matrix(pr,ncol=100,nrow=2,byrow=TRUE)
mat = mat+t(mat)
diag(mat) = NA
dimnames(mat)=list(1:100,1:100)
res = cortestmatrices(mat,method="spearman")
cors= res[[1]]
ps = res[[2]]
print(which(ps==min(ps,na.rm=TRUE),arr.ind=TRUE))

Run the code above in your browser using DataLab