Last data update: 2014.03.03

R: Function to extract correlations and corresponding p-values...
cortestmatricesR Documentation

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

Author(s)

Elin Axelsson

See Also

cor.test

Examples

## 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))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(coRNAi)
Loading required package: cellHTS2
Loading required package: RColorBrewer
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: genefilter
Loading required package: splots
Loading required package: vsn
Loading required package: hwriter
Loading required package: locfit
locfit 1.5-9.1 	 2013-03-22
Loading required package: grid
Loading required package: limma

Attaching package: 'limma'

The following object is masked from 'package:BiocGenerics':

    plotMA

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/coRNAi/cortestmatrices.Rd_%03d_medium.png", width=480, height=480)
> ### Name: cortestmatrices
> ### Title: Function to extract correlations and corresponding p-values from
> ###   interaction matrix.
> ### Aliases: cortestmatrices
> 
> ### ** Examples
> 
> ## 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))
  row col
2   2   1
1   1   2
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>