getTopCorrelationPairs: Get Top Correlation Pairs from a Correlation Matrix

View source: R/EnrichmentAnalysis.R

getTopCorrelationPairsR Documentation

Get Top Correlation Pairs from a Correlation Matrix

Description

Extracts the top positively and negatively correlated variable pairs from a correlation matrix.

Usage

getTopCorrelationPairs(corMat, nTop = 5)

Arguments

corMat

A square numeric matrix representing correlations between variables. Should have row and column names.

nTop

An integer specifying the number of top positive and negative correlation pairs to return. Defaults to 5.

Value

A list with two data frames:

topPositive

Data frame of the top nTop most positively correlated variable pairs.

topNegative

Data frame of the top nTop most negatively correlated variable pairs.

Examples

# Generate a random correlation matrix
set.seed(123)
mat <- matrix(rnorm(100), ncol = 10)
corMat <- cor(mat)
result <- getTopCorrelationPairs(corMat, nTop = 3)
result$topPositive
result$topNegative


eisascience/scCustFx documentation built on June 2, 2025, 3:59 a.m.