crossCorr: Cross Correlations

Description Usage Arguments Details Value Examples

View source: R/crossCorr.R

Description

Perform pairwise correlations formatted for BART

Usage

1
2
3
crossCorr(x, y, by = NULL, by.name = NULL, description = "X vs Y",
  x.var = "X", y.var = "Y", method = "pearson", order.by = "p",
  decreasing = TRUE)

Arguments

x

A numeric matrix or data frame.

y

A second numeric matrix or data frame with the same number of rows as x.

by

Default is NULL. A grouping vector with length equal to nrow(x). Allows correlation by group (e.g. time).

by.name

Default is NULL. String denoting the name of the grouping factor.

description

String giving description of what's being correlated. Default is "X vs Y".

x.var

String denoting type of variables in x. Default is "X".

y.var

String denoting type of variables in y. Default is "Y".

method

Default is set to "pearson". The alternatives are "spearman" and "kendall".

order.by

Order by p-value ("p") or correlation value ("r"). Default is "p".

decreasing

logical. Should the sort be increasing or decreasing? Default is TRUE.

Details

This function uses the corr.test function in the pysch package to find the correlations and p-values. It then formats the results in a tall format for BART.

Value

corrs Tall data frame of correlations and p-values.

corr.files A data frame obtained by cbind(by,x,y).

corr.names A string denoting the description of the variables being correlated.

x.var String denoting type of variables in x.

y.var String denoting type of variables in y.

corr.method One of "pearson", "spearman", or "kendall".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Example data
data(tb.flow)

# Format expression data to align with flow data
gene.data <- data.frame(t(tb.expr[1:100, ]))
rownames(gene.data) <- paste0(tb.design$monkey_id, "_", tb.design$timepoint)
flow.data <- data.frame(t(tb.flow))
flow.data <- flow.data[match(rownames(gene.data), rownames(flow.data), nomatch = 0), ]
gene.data <- gene.data[match(rownames(flow.data), rownames(gene.data), nomatch = 0), ]

# Create time variable
time <- tb.flow.des$timepoint[match(rownames(flow.data),tb.flow.des$columnname,nomatch = 0)]

# Run correlations and format for BART
corrs <- crossCorr(x = gene.data, y = flow.data, by = time, by.name = "days", 
                   description = "Genes vs Flow", x.var = "Genes", 
                   y.var = "Flow", method = "spearman")

genBart documentation built on May 2, 2019, 9:13 a.m.