correlationTest: Correlation of each row of a matrix or MRexperiment object

View source: R/correlationTest.R

correlationTestR Documentation

Correlation of each row of a matrix or MRexperiment object

Description

Calculates the (pairwise) correlation statistics and associated p-values of a matrix or the correlation of each row with a vector.

Usage

correlationTest(
  obj,
  y = NULL,
  method = "pearson",
  alternative = "two.sided",
  norm = TRUE,
  log = TRUE,
  cores = 1,
  override = FALSE,
  ...
)

Arguments

obj

A MRexperiment object or count matrix.

y

Vector of length ncol(obj) to compare to.

method

One of 'pearson','spearman', or 'kendall'.

alternative

Indicates the alternative hypothesis and must be one of 'two.sided', 'greater' (positive) or 'less'(negative). You can specify just the initial letter.

norm

Whether to aggregate normalized counts or not - if MRexperiment object.

log

Whether or not to log2 transform the counts - if MRexperiment object.

cores

Number of cores to use.

override

If the number of rows to test is over a thousand the test will not commence (unless override==TRUE).

...

Extra parameters for mclapply.

Value

A matrix of size choose(number of rows, 2) by 2. The first column corresponds to the correlation value. The second column the p-value.

See Also

correctIndices

Examples


# Pairwise correlation of raw counts
data(mouseData)
cors = correlationTest(mouseData[1:10,],norm=FALSE,log=FALSE)
head(cors)

mat = MRcounts(mouseData)[1:10,]
cormat = as.matrix(dist(mat)) # Creating a matrix
cormat[cormat>0] = 0 # Creating an empty matrix
ind = correctIndices(nrow(mat))
cormat[upper.tri(cormat)][ind] = cors[,1] 
table(cormat[1,-1] - cors[1:9,1])

# Correlation of raw counts with a vector (library size in this case)
data(mouseData)
cors = correlationTest(mouseData[1:10,],libSize(mouseData),norm=FALSE,log=FALSE)
head(cors)


HCBravoLab/metagenomeSeq documentation built on March 17, 2024, 3:21 p.m.