permutation_correlation_test: Perform a permutation correlation test on every row of a...

View source: R/permutation.R

permutation_correlation_testR Documentation

Perform a permutation correlation test on every row of a matrix

Description

Compute a correlation value for every row of X against the vector y and n random permutations of y. If the number of possible permutations is less than the the argument n_perm then an exact test is performed instead. In both cases the function returns a data.frame of the original data with additional columns for the test statistic, empirical p-value, and FDR corrected empirical p-value.

Usage

permutation_correlation_test(X, y, n_perm = 10000, n_core = 1, ...)

Arguments

X

numeric matrix or data.frame that can be converted to a numeric matrix

y

numeric vector of values to correlate with rows of X

n_perm

integer. The desired number of permutations to sample from. Default (10,000)

n_core

integer. The number of cores to use for processing. Default (1)

...

Additional arguments to pass to 'cor' function

Examples

# generate example data
X <- matrix(runif(1e3 * 10), nrow = 1e3, ncol = 10)
y <- 1:10
dimnames(X) <- list(paste("feature", 1:1e3, sep = "."), paste("sample", 1:10, sep = "."))

# correlate each row of X with 1,000 random permutations of vector y
res <- permutation_correlation_test(X, y, n_perm = 1e3, n_core = 8, method = "spearman")

head(res)

jcalendo/coriell documentation built on March 5, 2025, 5:42 a.m.