Learn R Programming

influential (version 2.3.0)

fcor: Fast correlation and mutual rank analysis

Description

This function calculates Pearson/Spearman correlations between all pairs of features in a matrix/dataframe much faster than the base R cor function. It is also possible to simultaneously calculate mutual rank (MR) of correlations as well as their p-values and adjusted p-values. Additionally, this function can automatically combine and flatten the result matrices. Selecting correlated features using an MR-based threshold rather than based on their correlation coefficients or an arbitrary p-value is more efficient and accurate in inferring functional associations in systems, for example in gene regulatory networks.

Usage

fcor(
  data,
  na_to_zero = TRUE,
  method = "spearman",
  mutualRank = TRUE,
  mutualRank_mode = "unsigned",
  pvalue = FALSE,
  adjust = "BH",
  flat = TRUE
)

Value

Depending on the input data, a dataframe or list including cor (correlation coefficients), mr (mutual ranks of correlation coefficients), p (p-values of correlation coefficients), and p.adj (adjusted p-values).

Arguments

data

a numeric dataframe/matrix (features on columns and samples on rows).

na_to_zero

logical, whether to convert NAs to 0 in the output (default) or not.

method

a character string indicating which correlation coefficient is to be computed. One of "pearson" or "spearman" (default).

mutualRank

logical, whether to calculate mutual ranks of correlations or not.

mutualRank_mode

a character string indicating whether to rank based on "signed" or "unsigned" (default) correlation values. In the "unsigned" mode, only the level of a correlation value is important and not its sign (the function ranks the absolutes of correlations). Options are "unsigned", and "signed".

pvalue

logical, whether to calculate p-values of correlations or not.

adjust

p-value correction method (when pvalue = TRUE), a character string including any of "BH" (default), "bonferroni", "holm", "hochberg", "hommel", or "none".

flat

logical, whether to combine and flatten the result matrices or not.

See Also

p.adjust and graph_from_data_frame

Examples

Run this code
if (FALSE) {
set.seed(1234)
data <- datasets::attitude
cor <- fcor(data = data)
}

Run the code above in your browser using DataLab