Learn R Programming

brainGraph (version 0.55.0)

corr.matrix: Calculate correlation matrix and threshold

Description

This function does a column-by-column correlation of a given data frame, and will threshold the matrix based on a given density; e.g. 0.1 if you want to keep only the 10% strongest correlations.

Usage

corr.matrix(dat, thresh = NULL, density = 0.1, exclusions = NULL, ...)

Arguments

dat
Matrix or data frame of the columns to correlate
thresh
Absolute correlation value to threshold by
density
Keeps the top X% of correlations
exclusions
Vector of indices (columns) to exclude (optional)
...
Other arguments to be passed to rcorr

Value

  • A list with the following components:
  • RCorrelation coefficients (default: Pearson).
  • PAssociated p-values.
  • r.threshBinary matrix indicating correlations that are above a certain threshold.
  • thresholdThe threshold used.

Details

If you wish to exclude regions from your analysis, you can give the indices of their columns. Also returns the p-values. Essentially a wrapper for rcorr, with some added functionality to work with this type of data more easily. By default, the Pearson correlation coefficients are calculated, but can return Spearman by passing an additional argument.

See Also

rcorr